thestuntman 10 Posted July 1, 2013 I am trying to create a minefield using SHK_Pos script which returns random position. I have no troubles getting markers to show up as a test, and I am able to make triggers on these positions as well. The variable "p" below was originally a local variable but i was unable to use it as such as _trg%1 setTriggerStatements[""this"", ""_bomb = 'M_RPG32_F' createVehicle _p;"",""""]; setTriggerStatements knew nothing about "_p" it as it was out of scope for "_i" from 0 to 5 do { p = [getpos player,random 360,[5,random 50]] call SHK_pos; _mortarRound = "M_RPG32_F"; if (count p > 0) then { call compile format [" _m%1 = createMarker[""mySpot%1"",[p select 0,p select 1]]; _m%1 setMarkerShape ""ICON""; _m%1 setMarkerType ""HD_DOT""; _m%1 setmarkercolor ""colorred""; _m%1 setmarkerText ""%1""; _trg%1 = createTrigger[""EmptyDetector"",p]; _trg%1 setTriggerArea[5,5,0,false]; _trg%1 setTriggerActivation[""WEST"",""PRESENT"",true]; _trg%1 setTriggerStatements[""this"", ""_bomb = 'M_RPG32_F' createVehicle p;"",""""]; ",_i]; }; hint format["Pos: %1", p]; }; I made it work somewhat by making making the variable public, but the problem I am having is that the bomb is always being placed on the last trigger in the loop, and not on each trigger as intended. Is there a better way to get this to work? I want each new trigger to use the position returned by p = [getpos player,random 360,[5,random 50]] call SHK_pos; each iteration of the loop. all up i need the code to loop a certain number of times, getting a new random position each time from the script call, create a new trigger at each random position each loop, and have that trigger spawn a new bomb on the trigger location each time it is activated ---------- Post added at 08:53 ---------- Previous post was at 07:44 ---------- I have been able to get it working using _trg%1 setTriggerStatements[""this"", ""_bomb = 'M_RPG32_F' createVehicle (getPos thisTrigger);"",""""]; but I still feel there is a better way to do this. I'd like each trigger to keep a unique name in case i need to reference it in the future. I have been thinking of adding each trigger that gets created to an array to make them easier to access later Share this post Link to post Share on other sites