Mirek 166 Posted October 16, 2017 Hi I have some markers named m_01 - m_20 on the map in the editor, each marker has different size and orientation. iam letting a script to choose from them by folowing function (selectRandom(allMapMarkers select { _x find "m_"== 0}) This function is used for randomly select an area (town, city, willage) to spawn AI. Now i want a function that would find out wich marker was selected by the function, and spawn a trigger that will use the marker area as the triger area, check if certain object is present in the area, and check if Blufor is detected by opfor n the area, if object is present and blufor is detected, i want the triger to fire. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted October 16, 2017 45 minutes ago, Mirek said: Hi I have some markers named m_01 - m_20 on the map in the editor, each marker has different size and orientation. iam letting a script to choose from them by folowing function (selectRandom(allMapMarkers select { _x find "m_"== 0}) This function is used for randomly select an area (town, city, willage) to spawn AI. Now i want a function that would find out wich marker was selected by the function, and spawn a trigger that will use the marker area as the triger area, check if certain object is present in the area, and check if Blufor is detected by opfor n the area, if object is present and blufor is detected, i want the triger to fire. Maybe I misunderstood, but selectRandom already returns the randomly selected marker fitting your 'select' conditions. It already returns one of "m_01" - "m_20" markers. Are you storing it in a variable? _myRndMarker = (selectRandom(allMapMarkers select { _x find "m_"== 0}); //do stuff to _myRndMarker Cheers Share this post Link to post Share on other sites
Mirek 166 Posted October 16, 2017 Well i have it like this: null = [[(selectRandom(allMapMarkers select { _x find "m_"== 0})],...... I have no idea what the null thing does so i vas afraid to change it. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted October 16, 2017 33 minutes ago, Mirek said: Well i have it like this: null = [[(selectRandom(allMapMarkers select { _x find "m_"== 0})],...... I have no idea what the null thing does so i vas afraid to change it. It's not some kind of magic. The whole "null =" or "0 =" stuff comes from ancient scripting guides made by someone with probably poor understanding or not enough afterthought (been there myself). It's a regular variable that holds information being put out on the right side of the equal ("=") sign. Dig through some scripting guides/pages to get a grasp of these things. You could name it anyway you seem fit, getting a hold of your own naming conventions early on is always a good idea: null = (selectRandom(allMapMarkers select { _x find "m_"== 0});//bad 0 = (selectRandom(allMapMarkers select { _x find "m_"== 0});//also bad marker1 = (selectRandom(allMapMarkers select { _x find "m_"== 0});//better but still not quite there MIR_mrk_randomMissionMarker = (selectRandom(allMapMarkers select { _x find "m_"== 0});//as good as it gets MIR stands for Mirek, mrk makes it obvious that this variable will hold a marker and then you can write whatever fits best to describe the value of the variable. This helps a ton if you need help from others and also when coming back to older projects, you know at first glance what that variable is holding and prevents you from digging through entire files. Cheers 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 16, 2017 Thank you very much kind sir. Share this post Link to post Share on other sites
Larrow 2820 Posted October 16, 2017 (edited) 55 minutes ago, Grumpy Old Man said: The whole "null =" or "0 =" stuff comes from ancient scripting guides made by someone with probably poor understanding or not enough afterthought I would not agree. I still do this to trap unwanted return values like a script handle or index from pushback. Whether its a local or global variable all depends on the context e.g local variable in global scope errors. Admittedly makes zero sense in the context here. 3 hours ago, Mirek said: Now i want a function that would find out wich marker was selected by the function, and spawn a trigger that will use the marker area as the triger area, check if certain object is present in the area, and check if Blufor is detected by opfor n the area, if object is present and blufor is detected, i want the triger to fire. As a marker in Arma is not a specific object and is only referenced by its STRING name you could do... _random = ( floor random 20 ) + 1; _marker = format[ "m_%1%2", [ "", "0" ] select ( _random < 10 ), _random ]; Or if you name your markers 1-20, leaving out the prefixed 0 on single figure numbers you can just use.. _marker = format[ "m_%1", ( floor random 20 ) + 1 ]; Then //BI function to create/modify a trigger based on a markers dimensions _trigger = [ objNull, _marker ] call BIS_fnc_triggerToMarker; _trigger setTriggerActivation [ "WEST", "EAST D", false ]; //West detected by East _trigger setTriggerStatements [ "this && yourObject inArea thisTrigger", //Condition "hint 'Trigger fired'", //OnActivation "" ]; Where yourObject is the object that needs to be in the trigger. Then just replace the hint with what ever you would like the trigger to do. Edited October 16, 2017 by Larrow 1 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 16, 2017 Thanks ill try to work out something when i come home from work, and post the result here. Share this post Link to post Share on other sites
Mirek 166 Posted October 16, 2017 Hmm Frustrating. I tried to change the code and name the Null thingy. mrk_l = [[selectRandom (allMapMarkers select { _x find "l_" == 0})...................... then i add _randPos = [mrk_l , 0, 100, 12, 0, 0.3, 0] call BIS_fnc_findSafePos; and now iam getting "undefined variable mrk_l" error. How can i get undefined variable? the variable is clearly defined just line above. Share this post Link to post Share on other sites
TheGeneral2899 19 Posted October 17, 2017 You're trying to get it to find a marker, but the first parameter is asking for an object. Try changing to: _randPos = [getMarkerPos mrk_l , 0, 100, 12, 0, 0.3, 0] call BIS_fnc_findSafePos; Just a guess from an initial glance. I think the mrk_1 variable is storing a marker right? So you'd need to getMarkerPos. 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 17, 2017 2 hours ago, TheGeneral2899 said: You're trying to get it to find a marker, but the first parameter is asking for an object. Try changing to: _randPos = [getMarkerPos mrk_l , 0, 100, 12, 0, 0.3, 0] call BIS_fnc_findSafePos; Just a guess from an initial glance. I think the mrk_1 variable is storing a marker right? So you'd need to getMarkerPos. Ah, stupid me! You are probably correct mister. Thank you. Edit: Just tried it and it didnt work it still says that the variable is undefined. :-( But still thanks. Share this post Link to post Share on other sites
kauppapekka 27 Posted October 17, 2017 On 16.10.2017 at 8:22 PM, Mirek said: Hmm Frustrating. I tried to change the code and name the Null thingy. mrk_l = [[selectRandom (allMapMarkers select { _x find "l_" == 0})...................... Hard to say what you are trying to store into the variable, if anything at all, as you don't have the whole line in there? But as grumpy said this is how you store a random marker into that variable, minus one too many (. mrk_1 = selectRandom (allMapMarkers select { _x find "m_"== 0}); Share this post Link to post Share on other sites
Mirek 166 Posted October 18, 2017 Whole line goes like: mrk_l = [[(selectRandom(allMapMarkers select { _x find "l_"== 0})],[3,2,70],[1,2,90],[1,1,50],[0,0],[1,30],[0,0],[0,0,1000,EAST,FALSE]] call EOS_Spawn; Iam using it to randomly select a marker on wich bangabobs ocupation script spawns enemies. Then i want to find out wich of the markers was selected, and spawn an object and a trigger there. Share this post Link to post Share on other sites
Larrow 2820 Posted October 18, 2017 EOS_spawn does not return a reference to the marker used, so you will need to choose your marker outside of the function call to be able to use it afterwards. mrk_l = selectRandom(allMapMarkers select { _x find "l_"== 0}); null = [[mrk_l],[3,2,70],[1,2,90],[1,1,50],[0,0],[1,30],[0,0],[0,0,1000,EAST,FALSE]] call EOS_Spawn; 1 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 18, 2017 Thank you man, i will ry it. Share this post Link to post Share on other sites
Mirek 166 Posted October 18, 2017 it works. I have this: mrk_xl = selectRandom(allMapMarkers select { _x find "xl_"== 0}); null = [[mrk_xl],[8,1],[6,3],[2,2,90],[2,40],[4,90],[1,1,25],[0,2,1000,EAST,False]] call EOS_Spawn; _randPos = [getMarkerPos mrk_xl , 0, 100, 12, 0, 0.3, 0] call BIS_fnc_findSafePos; _radio1 = "INS_WarfareBUAVterminal" createVehicle _randPos; An id spawns the thingy allright. Thank you wery wery much! 1 Share this post Link to post Share on other sites