pierremgi 4822 Posted August 22, 2017 1 hour ago, das attorney said: That's because I didn't write one. So, why did you piss off me with "that's already been suggested "? Share this post Link to post Share on other sites
das attorney 858 Posted August 22, 2017 Just now, pierremgi said: So, why did you piss off me with "that's already been suggested "? Calm down Pierre 1 Share this post Link to post Share on other sites
pierremgi 4822 Posted August 22, 2017 1 hour ago, scottb613 said: Pierre - I'm not sure I follow with the case stuff yet - I'm short of time but I'll read it over more carefully tonight... Just saying, the switch do { case (something still not defined): code } should be replaced by a defined case, true or false, but defined. Share this post Link to post Share on other sites
scottb613 263 Posted August 23, 2017 14 hours ago, pierremgi said: Just saying, the switch do { case (something still not defined): code } should be replaced by a defined case, true or false, but defined. Hi Pierre, OK - think I understand - it's more efficient ? I'll see if I can rework that part as well after clearing the remaining errors... Thanks... Regards, Scott Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 23, 2017 19 minutes ago, scottb613 said: Hi Pierre, OK - think I understand - it's more efficient ? I'll see if I can rework that part as well after clearing the remaining errors... Thanks... Regards, Scott I never used switch for anything, simple if then if then constructs are faster. That aside it's easy to return stuff with variable outcome using simple bool checks. In your case you're using to check if assets exist with [slick1,slick2,slick3,slick4] select {!isNil "_x"} which will return [slick1,slick3] array if only slick1 and slick3 exist in the mission. This output is not really helpful if you want to do certain things in case an individual slick exists or not. So you could use apply and set bool flags like this: [slick1,slick2,slick3,slick4] apply {!isNil "_x"} will return [true,false,true,false] if only slick1 and slick3 exist in the mission. Using this you can work from there like that: _output = [slick1,slick2,slick3,slick4] apply {!isNil "_x"}; _output params ["_slick1Exists","_slick2Exists","_slick3Exists","_slick4Exists"]; if (_slick1Exists) then {/*do stuff with slick1*/}; if (_slick2Exists) then {/*do stuff with slick2*/}; if (_slick3Exists) then {/*do stuff with slick3*/}; if (_slick4Exists) then {/*do stuff with slick4*/}; if (!_slick1Exists) then {/*do stuff if slick1 doesn't exist*/}; if (!_slick2Exists) then {/*do stuff if slick2 doesn't exist*/}; if (!_slick3Exists) then {/*do stuff if slick3 doesn't exist*/}; if (!_slick4Exists) then {/*do stuff if slick4 doesn't exist*/}; You could also do specific things for specific outcomes, i.e.: slick1 and slick2 exist but 3 and 4 don't, do something different if slick1 and slick3 exist and slick1 is dead. Stuff like that can be done using binary flags or bitflags implemented as functions by glorious @killzone_kid which basically give infinite possibilities on how to handle stuff. But that goes beyond this thread, heh. Cheers 1 Share this post Link to post Share on other sites
scottb613 263 Posted August 23, 2017 Hi Grumpy, Thanks as well - what started out as a simple question has turned into a pretty comprehensive learning experience for me... I'll keep all this in mind as I'm working on a few other scripts right now as well - and once I clear the errors - I'll go back through this one optimizing it a bit more... I still have more plans for this one as well - as once the "insertion" is over - there's the "extraction" to worry about... Much appreciated - sir... Regards, Scott Share this post Link to post Share on other sites
pierremgi 4822 Posted August 23, 2017 3 hours ago, scottb613 said: Hi Pierre, OK - think I understand - it's more efficient ? I'll see if I can rework that part as well after clearing the remaining errors... Thanks... Regards, Scott It was just to.. clean the error! 1 Share this post Link to post Share on other sites
scottb613 263 Posted August 23, 2017 Hi Pierre, Hah - sorry - yes - because without the "case" statement I don't need the test that throws the error on me... I see said the blind man... Let me see what I can do now that the coffee has kicked in... Regards, Scott Share this post Link to post Share on other sites
scottb613 263 Posted August 26, 2017 On 8/22/2017 at 11:38 AM, das attorney said: Upload it somewhere and I'll have a look for you Hi... I haven't had time to work on it yet - swapped out and tested with all vanilla - still throws the same two errors on the following two lines - yet actually seems to run properly: _slkArr = [slick1,slick2,slick3,slick4] select {!isNil "_x"}; _wpSlkUn synchronizeWaypoint _wpChkUn; Mission is ready to launch as is... You can 1-4 slicks with respective 1-4 chalks... You can 1-4 or no inbound waypoints... You can 1-4 or no outbound waypoints... You will insert chalks at marker labeled lz1, lz2, lz3, lz4... Fire trigger for Radio Alpha and the mission will run autonomously - no other action required... Debug switch at start of script - currently off... MISSION LINK: https://www.dropbox.com/s/y8g69dbw8ztpyyp/SCO_SctiptTestVan.Altis.zip?dl=0 //============================// // SLICKS - SCO Launch Script // //============================// // Note: Only tested in Single Player // Given: 1 to 4 helicopters preloaded with crew - units named in assets. // Given: Infantry squads (chalkx) will be loaded as cargo into helicopter (slickx) with respect to number when _loadChk = 1. // Given: Helicopters will assault LZ with defined helipads - drop troops - RTB to home helipads. // Given: User can define manual path with up to four inbound markers "inb1-inb4" if desired - else direct to LZ pad. // Given: User can define manual path with up to four outbound markers "out1-out4" if desired - else direct to BS pad. // Given: Example Flight Path - [BsPad1 -> inb1 -> inb2 -> inb3 -> inb4 -> LzPad1 -> out1 -> out2 -> BsPad1]. // Given: In order to have outbound waypoints work - you need at least one inbound waypoint specified. // Given: Even though helicopters are individual units - they will maintain a diamond formation along flight path. // Named Asset: [OPTIONAL] ("s1" - player unit) // Named Asset: ("slick1" - slick helo) ("slick2" - slick helo) ("slick3" - slick helo) ("slick4" - slick helo) // Named Asset: ("chalk1" - inf squad) ("chalk2" - inf squad) ("chalk3" - inf squad) ("chalk4" - inf squad) // Named Marker: ("lz1" - lz pad marker) ("lz2" - lz pad marker) ("lz3" - lz pad marker) ("lz4" - lz pad marker) // Named Marker: [OPTIONAL] ("inb1" - inbound marker) ("inb2" - inbound marker) ("inb3" - inbound marker) ("inb4" - inbound marker) // Named Marker: [OPTIONAL] ("out1" - outbound marker) ("out2" - outbound marker) ("out3" - outbound marker) ("out4" - outbound marker) // Classname: ("Land_HelipadEmpty_F" - invisible helipad) // Classname: ("Land_HelipadCircle_F" - visible helipad) Thanks... Regards, Scott Share this post Link to post Share on other sites
scottb613 263 Posted August 27, 2017 Hi Folks, Note: Update the above link for true VANILLA - realized initially I had some other content - now corrected... Also tried this: _slicks = [slick1,slick2,slick3,slick4,slick5] select {not isNil "_x" and {not isNull _x}}; diag_log _slicks; Same issue - had slick1-slick4 existing - slick5 did not - same error: Resulting array shows [slick1,slick2,slick3,slick4] - but throws ERROR slick5 is an "Undefined Variable" ? LOL - this seems like it should be an EASY task - identifying content that exists in the mission... Anytime I try to reference a global variable that doesn't exist I get the same error... Arrrgh - I've spent SOOO many hours on this... Thanks... Regards, Scott Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 27, 2017 Perhaps you can shed some light on why you're suddenly checking for another slick, namely slick5 if the original one was to check for 1-4? Are these vehicles getting deleted or are they prone to destruction? Do you spawn them or editor place them? Does the error reference any line? Doing this check doesn't throw an error for me, with no combination of deleted/destroyed slicks, not even when not placing any slick named objects at all. Is that a default arma error message? Maybe upload a video of it. Maybe someone else can check if this line shows any error with either existing slicks, no slicks at all and deleting slicks during runtime, then doing the check. From what I understand the command CAN NOT throw an error and return something at the same time. Could be wrong, at least I've never see something like this happen before. Please provide as much info as possible. Cheers Share this post Link to post Share on other sites
scottb613 263 Posted August 27, 2017 1 hour ago, Grumpy Old Man said: Perhaps you can shed some light on why you're suddenly checking for another slick, namely slick5 if the original one was to check for 1-4? Are these vehicles getting deleted or are they prone to destruction? Do you spawn them or editor place them? Does the error reference any line? Doing this check doesn't throw an error for me, with no combination of deleted/destroyed slicks, not even when not placing any slick named objects at all. Is that a default arma error message? Maybe upload a video of it. Maybe someone else can check if this line shows any error with either existing slicks, no slicks at all and deleting slicks during runtime, then doing the check. From what I understand the command CAN NOT throw an error and return something at the same time. Could be wrong, at least I've never see something like this happen before. Please provide as much info as possible. Cheers Hi GOM, LOL - thanks for your patience with me - I'm running this in the editor - instead of a full blown mission - perhaps that's why I am getting it ??? The error shows up on any line where I try to reference a nonexistent slick... I'm trying to make these scripts very modular - so I can slap them down anywhere - without having to edit a script... So - depending on the mission - the number of required slicks could vary... The vanilla mission I posted above has the concept... Slap down a few slicks and respective chalks - with some markers to reference desired path - wam bam - instant air assault on an LZ anywhere you want it... No messing with waypoints - the script handles the rest... Here's a screenshot (Shows the Error Message and the Contents of the ARRAY in the chat - slick5 is only referenced once in the whole script for testing and the error line referenced is the isNil statement posted above): https://www.dropbox.com/s/sspkd4c4s4ezhjn/arma3_x64 2017-08-27 10-47-52.png?dl=0 Thanks for your time !!! Regards, Scott Share this post Link to post Share on other sites
Lucullus 71 Posted August 27, 2017 You can only work with undefined variables if you put them in quotation marks. _slicks = [slick1,slick2,slick3,slick4,slick5] select {not isNil "_x"}; // doesn't work _slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x and {not isNull _x}}; // doesn't work, because isNull wants an object _slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x}; // ok 1 Share this post Link to post Share on other sites
scottb613 263 Posted August 27, 2017 You can only work with undefined variables if you put them in quotation marks. _slicks = [slick1,slick2,slick3,slick4,slick5] select {not isNil "_x"}; // doesn't work_slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x and {not isNull _x}}; // doesn't work, because isNull wants an object_slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x}; // ok Hi...OMG - is it that easy - I'll give it a shot...Funny - I had noticed that my getmarkerpos - needed the items in quotes - had meant to try it - LOL - oops...Thanks - I'll post when I have a minute to test...Regards,ScottSent from my iPad using Tapatalk Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 28, 2017 11 hours ago, Lucullus said: You can only work with undefined variables if you put them in quotation marks. _slicks = [slick1,slick2,slick3,slick4,slick5] select {not isNil "_x"}; // doesn't work _slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x and {not isNull _x}}; // doesn't work, because isNull wants an object _slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x}; // ok For some reason the first one works and returns the correct array of existing slicks, try it out yourself and check for errors, it doesn't throw any. Place 2 objects, name them slick1, slick3 and run the code. It will return [slick1,slick3]. This also works: [slick1,slick2,slick3,slick4,slick5] select {not isNil {_x}};//returns [slick1,slick3] if only slick1 and slick3 exist in mission showScriptErrors is enabled and I'm not getting any error using this line so it has to come from somewhere else. @scottb613 it would be best to not reference any non existing variables in the first place, why not rewrite your script into a smaller function that takes chopper, inbound and outbound markers and other stuff as input parameters and execute it for every chopper individually? You could also reference your choppers using setVariable, like this: //first choppers init field: this setVariable ["Slick",1,true]; //second choppers init field: this setVariable ["Slick",2,true]; //etc... //now to get all slicks _slicks = vehicles select {_x getVariable ["Slick",-1] > 0}; //returns [20fc0fea040# 2: heli_light_01_f.p3d,20fbf972040# 3: heli_light_01_f.p3d] Cheers 1 Share this post Link to post Share on other sites
pierremgi 4822 Posted August 28, 2017 See also https://community.bistudio.com/wiki/setVehicleVarName 1 Share this post Link to post Share on other sites
scottb613 263 Posted August 28, 2017 Hi Folks, Thanks so much for all the great responses and the wealth of information - I didn't get to test last night and as usual I won't be able to test now until next weekend... GOM - yeah - I don't understand why you don't see the error's and I do - I don't know how to change the logging level in ArmA so I am set to whatever the defaults are... I'll see if I can rewrite my code during the week taking into account all the information gleaned from the above posts... LOL - it's tough when you can't test your changes right away... Again - thank you one and all !!! Regards, Scott Share this post Link to post Share on other sites
Lucullus 71 Posted August 28, 2017 Hm, test with 1.74 in MP. slick3 and slick4 defined as objects on map. _slicks = [slick1,slick2,slick3,slick4,slick5] select {not isNil "_x"}; // [slick3,slick4] -> works, but throw an error _slicks = [slick1,slick2,slick3,slick4,slick5] select {not isNil {_x}}; // [slick3,slick4] -> works, but throw an error _slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x and {not isNull _x}}; // -> doesn't work, because isNull wants an object _slicks = ["slick1","slick2","slick3","slick4","slick5"] select {not isNil _x}; // ["slick3","slick4"] -> ok 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 28, 2017 I think I figured out why I wasn't getting any errors... I pasted the code into the debug console on current devbranch, no error shows up. [slick1,slick2,slick3,slick4,slick5] select {not isNil {_x}}; Then I spawned it: nul = [] spawn {[slick1,slick2,slick3,slick4,slick5] select {not isNil {_x}};}; and the error shows up... So it's the debug console that's buggy? Strange. Explains it then. Cheers 3 Share this post Link to post Share on other sites