View Full Version : Eventhandler vs editor init
Soul_Assassin
Aug 31 2009, 21:47
I have the following very annoying problem:
- The random number and marking script is (A.sqf) hooked up via the config eventhandler init. It works perfectly.
There is a second script (B.sqf) which allows you to set a custom number/markings via some parameters in the editor init. This script works fine too, this was checked by putting the param line into a trigger init and then driving into the trigger.
The problem arises as the eventhandler is run AFTER the editor init line. So the numbers are set correctly through B and then instantly randomised through A rendering putting params in the init in the editor virtually useless. How do I bypass this?
Defunkt
Aug 31 2009, 22:00
I did something like this for ArmA 1 but parsed the unit name to set the texture and number, so like: T72_DESERT_067. You could get script A.sqf to do the same or fallback to random numbers if the name doesn't match that pattern.
An easy way would be to have your script wait until after the eventhandler is finished. This can easily be done by using variables, but it might not be the best method of archiving this.
Anyways, here's a rough sketch of what to do:
In your eventhandler, add the following line at the end of the file:
_vehicle setVariable ["initDone",true];
In the init script put this line right after you've initialized the variables:
waitUntil { !isNil call compile "_vehicle getVariable ""initDone"";" };
What this does.. the eventhandler sets the variable initDone to true, and the init-line scripts waits for exactly that until it continues executing.
You might have to redo the script commands a bit here and then, due to the time and the amount of alcohol ;)
Anyways, you should get the idea ;)
Soul_Assassin
Sep 1 2009, 18:54
It didnt work :(
putting this line:
waitUntil { !isNil call compile "_vehicle getVariable ""initDone"";" };
makes B even in the trigger not work. Is there really no way to reverse the order? How retarded is that? It used to be fine in OFP and ArmA1
It used to be fine in OFP and ArmA1
it was like that in OFP and Arma1.
One way is to call the scripts in a different way. In your config init event, use the call command to execute the code. That way it will kick in straight away.
From your mission editor init event, use execVM or Spawn. So the script will only be called after the config init event.
Soul_Assassin
Sep 2 2009, 14:54
execVM is used for both currently, thnx UNN ill give it a try. So the Syntax of the EH init should be:
_bmdinit = loadfile "BMDInit.sqf"; call compile _bmdinit;
is that about right?
Well this will do ok:
init="_this call compile preProcessFile ""BMDInit.sqf""";
Assuming there is nothing in BMDInit.sqf that won't work with the call command.
Soul_Assassin
Sep 2 2009, 22:43
UNN u the man :) !
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.