OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Pirin on 06 May 2008, 00:44:58

Title: Can't get call compile to work for me
Post by: Pirin on 06 May 2008, 00:44:58
I've found several examples of call compile usage here, but none that resulted in the "compile" being an object, most were related to strings.  So it's not working for me.  I've asked others and the resounding answer has been "I don't know, call gives me headaches!"

Basically I test the side you're on, convert it to a string, then I want to create a trigger at a spawn point based on your side.  Or even just move you.  I just cannot get the code to work.  I keep getting an error saying "Got 0 elements, expected 3".

_sidestring = WEST and I have a marker named "WESTSPAWN" on the map.

Here's my code so far:

Code: [Select]
_side = side _unit;
_sidestring = format["%1", _side];

_objmarkername = call compile format ["%1SPAWN", _sidestring];
_pos = getmarkerpos _objmarkername;

player setPos _pos; // this doesn't error but it doesn't work either...

_trigger = createTrigger ["foad", _pos];  // this gives the following error.


This is the error the createTrigger gives: 

  Error position: <createTrigger [_triggername, _pos];
  Error 0 elements provided, 3 expected

How can I get _objmarkername to "be" the marker that exists so that I can properly get it's position please?  What am I doing wrong in what should be an easy bit of code, right?

Edit: I've also tried it this way, to no avail:

Code: [Select]
call compile format["_objmarkerName = %1SPAWN", _sidestring];
Title: Re: Can't get call compile to work for me
Post by: Mandoble on 06 May 2008, 01:25:25
Code: [Select]
_markername = format ["%1SPAWN", side _unit];
_pos = getmarkerpos _markername;

or simply:
Code: [Select]
_pos = getmarkerpos format ["%1SPAWN", side _unit];

Btw, first parameter of createTrigger command is not the name, but the type. Try:
Code: [Select]
_trigger = createTrigger ["EmptyDetector", _pos];
Title: Re: Can't get call compile to work for me
Post by: Wolfrug on 06 May 2008, 02:30:02
Hell, I dont see why you need to go messing with the format command even. Names of markers are strings anyway, so just using something like:

Code: [Select]
_pos = getmarkerpos ( (str (side _unit)) + "SPAWN");

To get the spawnmarkername should be more than enough. Although people tell me using the FORMAT command together with the side command might produce strange results...not sure if str makes any difference...

Try it!

Wolfrug out.
Title: Re: Can't get call compile to work for me
Post by: Pirin on 06 May 2008, 03:13:13
Excellent, thanks a lot!  I got the _pos working perfectly now.

For some reason the trigger isn't picking anything up though.  I'll deal with that after Ironman! :)  Thanks again.

Update:  Iron Man.. awesome!  Also got the trigger to work finally.  Guess there's a bit of a time delay or something?  Added in a sleep and it's working like a charm now.  Thanks a lot guys, I really appreciate it!