I have an odd problem that for the life of me I cant figure out. I have a struct containing an integer array and a function that initializes the arrays values.
Header:
struct stUserEvents
{
int eventqueue[NUMBER_EVENTS];
import void Initialise();
};
stUserEvents UserEvent;
script:
void stUserEvents::Initialise()
{
int intLoop=0;
while (intLoop<NUMBER_EVENTS)
{
this.eventqueue[intLoop]=eNoEvent;
intLoop++;
}
}
in game_start I have UserEvent.Initialise();
trouble is the values are not being set.
If I take out the integer array from the struct and place it in my script
int eventqueue[NUMBER_EVENTS];
void stUserEvents::Initialise()
{
int intLoop=0;
while (intLoop<NUMBER_EVENTS)
{
eventqueue[intLoop]=eNoEvent;
intLoop++;
}
}
the values are set.
Can anyone tell me what I am not seeing, I'm assuming its just down to my rusty skills and me just not getting some principle.
You're declaring the instance in the header, which creates a separate instance for each script. You need to do:
// header
import stUserEvents UserEvent;
// script
stUserEvents UserEvent;
export UserEvent;
Thanks Khris , that sorted it. I could have sworn Id tried using 'export' but I must have not included the 'import'.