Aller au contenu

Photo

Scripting help!


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
EthrenDiak

EthrenDiak
  • Members
  • 79 messages
 I'm gonna state right off the bat that I am incompetent, to say the least, when it comes to scripting/programming.

Anyways, I'm having a slight problem with adding custom items through add-ins. I've followed werikk's tutorial, but I seem to have messed the script up. If you guys could look it over and tell me what's wrong, I'll worship your masterful hands for centuries. :whistle:

The script:

#include "utility_h"
#include "plt_my_custom_legends"

void main()
{

                if ( WR_GetPlotFlag( PLT_MY_CUSTOM_LEGENDS, CUSTOM_PLOT_LEGENDS_FLAG ) == TRUE
                return;
)


                event ev = GetCurrentEvent();
                int nEventType = GetEventType(ev);

                switch ( nEventType )
{

                             case EVENT_TYPE_MODULE_LOAD:
{
                             UT_AddItemToInventory(R"walker_boot.uti", 1);
                             UT_AddItemToInventory(R"walker_glove.uti", 1);
                             UT_AddItemToInventory(R"walker_robe.uti", 1);
                             UT_AddItemToInventory(R"walker_sword.uti", 1);

                             WR_SetPlotFlag( PLT_MY_CUSTOM_LEGENDS, CUSTOM_PLOT_LEGENDS_FLAG, TRUE

);

                    break;
}
         default:
         break;
}
}

Modifié par EthrenDiak, 10 décembre 2009 - 10:14 .


#2
Taleroth

Taleroth
  • Members
  • 9 136 messages
I haven't been deeply involved in coding in almost a decade. Scripting almost a year. So, I could be wrong.

if ( WR_GetPlotFlag( PLT_MY_CUSTOM_LEGENDS, CUSTOM_PLOT_LEGENDS_FLAG ) == TRUE
return;
)

Should probably be

if ( WR_GetPlotFlag( PLT_MY_CUSTOM_LEGENDS, CUSTOM_PLOT_LEGENDS_FLAG ) == TRUE)
     return;

Modifié par Taleroth, 10 décembre 2009 - 09:56 .


#3
EthrenDiak

EthrenDiak
  • Members
  • 79 messages
Thanks. A friend of mine also pointed out some more errors that I corrected. Still nothing, though.

#4
Taleroth

Taleroth
  • Members
  • 9 136 messages
It find it helps to ensure that your parenthesis and brackets and properly indented with the rest of it.  Helps you read it and make sure you're not missing some or putting them in the wrong place.

And let us know what error you're having. Does it not compile? Or does it compile, but you don't get the effect you want/expect?

Modifié par Taleroth, 10 décembre 2009 - 10:19 .


#5
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
Try this instead. I don't know if it will do what you want, but it should compile at least. If it doesn't, post the error and what line it's on.

#include "utility_h"
#include "plt_my_custom_legends"

void main()
{
                if ( WR_GetPlotFlag( PLT_MY_CUSTOM_LEGENDS, CUSTOM_PLOT_LEGENDS_FLAG ) == TRUE )
                {
                   return;
                }

                event ev = GetCurrentEvent();
                int nEventType = GetEventType(ev);

                switch ( nEventType )
                {
                             case EVENT_TYPE_MODULE_LOAD:
                             {
                                UT_AddItemToInventory(R"walker_boot.uti", 1);
                                UT_AddItemToInventory(R"walker_glove.uti", 1);
                                UT_AddItemToInventory(R"walker_robe.uti", 1);
                                UT_AddItemToInventory(R"walker_sword.uti", 1);

                                WR_SetPlotFlag( PLT_MY_CUSTOM_LEGENDS, CUSTOM_PLOT_LEGENDS_FLAG, TRUE );
                                break;
                             }
                }
}


Modifié par FalloutBoy, 10 décembre 2009 - 10:22 .


#6
EthrenDiak

EthrenDiak
  • Members
  • 79 messages
Honestly I have no idea. I export the folder as stated by the tutorial, and it appears on the Installed Content screen, but nothing happens ingame. I have neither the armor nor the weapons when I load it.

FalloutBoy: Thanks for the help, but it still doesn't work. :mellow: At current, my script is a copy/paste of the one you posted...

Update: When I export without dependent resources I get 2 failure notices:
18:34:05 - my_custom_legends.nss - Exporter FAILED for resource: my_custom_legends.nss
18:34:05 - my_custom_legends.nss - Unable to get the resource information for "my_custom_legends" of type "plo"
Might this be my problem?

Modifié par EthrenDiak, 10 décembre 2009 - 11:36 .


#7
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
It sounds like your plot either doesn't exist or it has errors. Do you have a plot named "my_custom_legends"? If not, you need to make it. Make sure it is named exactly "my_custom_legends" case-sensitive. Make sure your variable exists and is a main flag, not a defined flag. Export the plot and make sure that succeeds.

Modifié par FalloutBoy, 11 décembre 2009 - 12:07 .


#8
EthrenDiak

EthrenDiak
  • Members
  • 79 messages
I rewrote the script and added in some words I was missing from my identifiers. I can export with out any failures, but I get a different error message and still no items ingame.

19:23:24 - my_custom_legends.nss - my_custom_legends.nss(24): Variable defined without type (while compiling var_constants_h.nss)

I'm assuming this has something to do with the variable FalloutBoy mentioned?

Modifié par EthrenDiak, 11 décembre 2009 - 12:24 .


#9
EthrenDiak

EthrenDiak
  • Members
  • 79 messages
Never mind, I fixed it. I forgot to switch ALL the identifiers out with the new ones. :whistle: