Something a bit weird with the events system at mission start

The events system gets on my nerves at the best of days, but I noticed something particularly odd about it and decided to do some testing. In particular, event execution seems to start before the mission actually starts. I used the following code, started from the OnInit function.

Events.FadeTest={
	{
		{"Universe_Fade(1,0)",""},
	},{
		HW2_Wait(20),
	},{
		{"Universe_Fade(0,0)",""},
	},{
		HW2_Wait(20),
	},{
		{"Universe_Fade(1,0)",""},
	},{
		HW2_Wait(20),
	},{
		{"Universe_Fade(0,0)",""},
	},
}

So what this should do is start the game faded to black, fade back in after 20 seconds, then fade out 20 seconds later, and alternate a few times. The space between fades is right, so the clock is running at the right speed, but the first fade in happens at the 10 second mark, not the 20 second mark. So my only conclusion so far is that the event execution starts early. Perhaps there’s a different function besides oninit I should be firing my initial events from?

1 Like

Aren’t events usually fired from rules? Try:

function OnInit()
    ...
    Rule_AddInterval("FadeEvent", 0.1)
end

function FadeEvent()
    Rule_Remove("FadeEvent")
    Event_Start("FadeTest") -- or whatever the event call is
end

Universe_Fade also works outside of events… you can execute it in the init.

My Init from mission map:
image

@radar3301 My events are actually already being fired from just that kind of arrangement, I’d just forgotten it.

@b8factor My primary concern isn’t with the fade, it’s just used here for example’s sake. Though that’s a useful thing to keep in mind in general, because I’ve discovered that a fade done in an event will automatically end when the event ends.

2 Likes

That IS interesting. I ran into a few hiccups were certain functions (fade being one) that were acting strange. e.g. I had a fade out that was working fine and then all of a sudden a few builds later it faded instant even though it was suppose to fade in 10 seconds. I never figured it out.

If what you are saying is true then that may have had something to do with my problem.