Aller au contenu

Photo

what's wrong with this code?


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

#1
gordonbrown82

gordonbrown82
  • Members
  • 544 messages
Hi all. I was wondering about this code that i put in the area script place:

#include "events_h"
#include "wrappers_h"
#include "utility_h"
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    switch(nEventType)
    {
         case EVENT_TYPE_AREALOAD_POSTLOADEXIT:
         {
             object OHero = GetHero();
     DisplayFloatyMessage(OHero, "loaded", FLOATY_MESSAGE, 16777125, 30.0);
       CreateItemOnObject(R"item.uti", OHero);
            break;
         }
    }
    HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
    }

i was hoping that this would display a floaty message and create an object on the player after i loaded the module in the game but nothing happens. the functions are activated from conversation so i'm not sure what's wrong here.

#2
thebigMuh

thebigMuh
  • Members
  • 98 messages
Hold on a second.



You said you put this in the area script place, and it looks like an area script, and then you said you wanted the item to spawn when you load the module.



Do you want the item to spawn when the player enters a specific area? Or do you want to make the item appear if he enters the game with the module loaded?



Ciao, muh!

#3
gordonbrown82

gordonbrown82
  • Members
  • 544 messages
yes the latter i want the item to appear when the player enters the game with the module loaded.

#4
thebigMuh

thebigMuh
  • Members
  • 98 messages
Ah-ha!

Then you don't want an area script, you want a module script. There's actually a really good and simple tutorial on how to do just that here:

social.bioware.com/5339/blog/576/

It will also make sure that you get only 1 item, and not an additional copy every time you load a game.

Ciao, muh!

Modifié par thebigMuh, 14 janvier 2010 - 08:59 .


#5
gordonbrown82

gordonbrown82
  • Members
  • 544 messages
well the point was to see if EVENT_TYPE_AREALOAD_POSTLOADEXIT was working or how it was working.

#6
elys

elys
  • Members
  • 458 messages
If you just want the code to be executed when the module is enabled, you can just use something like this inside your module script:

void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
if ((nEventType == EVENT_TYPE_MODULE_START ) || (nEventType == EVENT_TYPE_MODULE_LOAD ))
{
//Put the code you want to execute when the module is activated here
//If you want the code to only run once for all, use a plot or a variable to store/check for the handled state.
}
}

Modifié par elys, 14 janvier 2010 - 09:23 .


#7
Craig Graff

Craig Graff
  • Members
  • 608 messages

gordonbrown82 wrote...

well the point was to see if EVENT_TYPE_AREALOAD_POSTLOADEXIT was working or how it was working.


It only works if your script is attached to the area (and both the script and area export successfully). It's also important to note that if you already entered the area in your game, then changed the area script, you will need to reload a game where you hadn't yet entered the area or the area list.

#8
thebigMuh

thebigMuh
  • Members
  • 98 messages
What I was wondering...



If I have a save game where I've already entered an area from a module, then load that savegame with the module disabled, save again, and then reenable the module - does the "dirty" data from the module persist in the game, or can I effectively erase everything I ever did in a module by loading a game without it?



(what a sentence O_o)



Ciao, muh!

#9
elys

elys
  • Members
  • 458 messages
What will remain is the eventual change you've made to existing core/single player datas.
But any data defined in your module such as variables, plots, items,etc will be gone.

Modifié par elys, 14 janvier 2010 - 10:29 .