daishiknyte 10 Posted February 7, 2016 You can lose the trigger and handle the timing in the script itself. In init.sqf: [1] execVM "runScripts.sqf"; // Pass the debug value [0 or 1] In runScripts.sqf _debug = _this select 0; while {true} do { <your runScripts code here> if (_debug == 1) then { <debug action> }; sleep 1; }; Share this post Link to post Share on other sites
dreadedentity 278 Posted February 7, 2016 You really shouldn't have brought up a thread that died over 2 years ago, but since you did. None of that will work: if (CONDITION1) || (CONDITION2) then {COMMAND}; so would this work? No. Reason: After the "if" and condition, sqf is looking for "then", however you have || (OR). You will get a script error. Proper way is to put parenthesis around the entire statement: if (CONDITION1 || CONDITION2) then {code}; if (CONDITION1) then {Command} else{ if (CONDITION2) then {Command } else{ }; }; This will work, although it is very strangely formatted, even accounting for the loss of tabbing due to pasting it directly into the message box. //if CONDITION1 is true, run code and exit if block if (CONDITION1) then { code } else { //if CONDITION1 is false, execute "else" block, leading to a new if statement //if CONDITION2 is true, run code and exit if block if (CONDITION2) then { code } else { //if CONDITION2 is false, run other code and exit if block other code }; }; 1 Share this post Link to post Share on other sites
NecorB 1 Posted October 3, 2016 I can confirm the frustration from author. Following code exec both statements nBuilding = nearestBuilding position player; listRoadObjects = (position nBuilding) nearRoads 50; ; This line is abundant countRoadObjects = count listRoadobjects; if (countRoadObjects == 0) then { hint "No roads!"; } else { [] spawn {sleep 5; hint format ["%1", countRoadObjects]}; }; OUTPUT IS: (hint) No roads! 5 sec (hint) 7 Original "if then else" is (with my changes) a copy paste from https://community.bistudio.com/wiki/Control_Structures Is this outdated as to Arma3? Also, this code ls simplified from what I originally did for debug purposes (that's why the above looks a bit weird). I have tried everything I can think of. Still no alternative execution of code. Can't the condition check for Boolean value? !alive works. But (variable < x) does not. Why? Are both not Boolean? Share this post Link to post Share on other sites
R3vo 2654 Posted October 3, 2016 Cannot confirm your issue, works here as expected, tested with a simplified version of your code: countRoadObjects = 0; if (countRoadObjects == 0) then { hint "No roads!"; } else { [] spawn {sleep 5; hint format ["%1", countRoadObjects]}; }; Share this post Link to post Share on other sites
killzone_kid 1331 Posted October 3, 2016 I can confirm the frustration from author. Following code exec both statements nBuilding = nearestBuilding position player; listRoadObjects = (position nBuilding) nearRoads 50; ; This line is abundant countRoadObjects = count listRoadobjects; if (countRoadObjects == 0) then { hint "No roads!"; } else { [] spawn {sleep 5; hint format ["%1", countRoadObjects]}; }; OUTPUT IS: (hint) No roads! 5 sec (hint) 7 Original "if then else" is (with my changes) a copy paste from https://community.bistudio.com/wiki/Control_Structures Is this outdated as to Arma3? Also, this code ls simplified from what I originally did for debug purposes (that's why the above looks a bit weird). I have tried everything I can think of. Still no alternative execution of code. Can't the condition check for Boolean value? !alive works. But (variable < x) does not. Why? Are both not Boolean? How do you execute your code? Share this post Link to post Share on other sites
dr death jm 117 Posted October 3, 2016 ; This line is abundant maybe should be // is the only thing i see Share this post Link to post Share on other sites
MKD3 27 Posted October 4, 2016 Its pretty simple stuff, everyone here seems a bit confused.If (true) then {}; will do stuff... if (false) then {}; will not.So as long as you have defined a variable and it is true, then that syntax will work and do stuff. Your syntax is not wrong, something else is. Id turn on script errors and youll see what is wrong.In the mean time. ​_variable = 1; if (_variable == 1) then {hint '_variable is 1';} else {hint '_variable is not 1';}; Play with that and see what you can make of it. You should understand the syntax and how triggers work before trying to over complicate anything. Hope this helped Share this post Link to post Share on other sites
Greenfist 1863 Posted October 4, 2016 I can confirm the frustration from author. Following code exec both statements nBuilding = nearestBuilding position player; listRoadObjects = (position nBuilding) nearRoads 50; ; This line is abundant countRoadObjects = count listRoadobjects; if (countRoadObjects == 0) then { hint "No roads!"; } else { [] spawn {sleep 5; hint format ["%1", countRoadObjects]}; }; OUTPUT IS: (hint) No roads! 5 sec (hint) 7 Original "if then else" is (with my changes) a copy paste from https://community.bistudio.com/wiki/Control_Structures Is this outdated as to Arma3? Also, this code ls simplified from what I originally did for debug purposes (that's why the above looks a bit weird). I have tried everything I can think of. Still no alternative execution of code. Can't the condition check for Boolean value? !alive works. But (variable < x) does not. Why? Are both not Boolean? The problem is that you're execin the code as SQS which has a different syntax than SQF. Try the execvm command instead. Share this post Link to post Share on other sites
killzone_kid 1331 Posted October 4, 2016 The problem is that you're execin the code as SQS which has a different syntax than SQF. Try the execvm command instead. it will not run because in sqs ; is comment but in sqf it is end of expression and will error with that script. Share this post Link to post Share on other sites
Greenfist 1863 Posted October 4, 2016 it will not run because in sqs ; is comment but in sqf it is end of expression and will error with that script. Yeah. I figured he might notice and fix it since it was already mentioned here. Share this post Link to post Share on other sites
killzone_kid 1331 Posted October 4, 2016 Yeah. I figured he might notice and fix it since it was already mentioned here. I bet he is trying scripting on stable without -showScriptErrors as well. Share this post Link to post Share on other sites
R3vo 2654 Posted October 4, 2016 I bet he is trying scripting on stable without -showScriptErrors as well. Isn't that enabled by default in the editor? Share this post Link to post Share on other sites
NecorB 1 Posted October 7, 2016 I can confirm the frustration from author. Following code exec both statements nBuilding = nearestBuilding position player; listRoadObjects = (position nBuilding) nearRoads 50; ; This line is abundant countRoadObjects = count listRoadobjects; if (countRoadObjects == 0) then { hint "No roads!"; } else { [] spawn {sleep 5; hint format ["%1", countRoadObjects]}; }; OUTPUT IS: (hint) No roads! 5 sec (hint) 7 Original "if then else" is (with my changes) a copy paste from https://community.bistudio.com/wiki/Control_Structures Is this outdated as to Arma3? Also, this code ls simplified from what I originally did for debug purposes (that's why the above looks a bit weird). I have tried everything I can think of. Still no alternative execution of code. Can't the condition check for Boolean value? !alive works. But (variable < x) does not. Why? Are both not Boolean? Problem found (since a while back): In ArmaEdit I (since I have had a break from scripting and forgot) created "new script" from button, not drop down list. This (by my? default setting) created a .sqs, which I happily (and unknowingly to consequences) renamed to .sqf. And so yeah...BAD move! Strange behavior on executed code. Now scripting works as intended because I create a .sqf. (I did notice there was a problem since comment syntax // did not work but ; did. But the 'Aha' moment happened when going through https://forums.bistudio.com/topic/145056-arma-3-scripting-tutorial-for-noobs/):) (very good) Thx all. 1 Share this post Link to post Share on other sites
zonekiller 175 Posted October 8, 2016 if you have if (value == something) then {do whatever}; in a trigger then you should put value = something; in the Description.ext or somewhere that will be read before the trigger is read at mission start or the trigger will not know what value is.... Share this post Link to post Share on other sites
killzone_kid 1331 Posted October 9, 2016 if you have if (value == something) then {do whatever}; in a trigger then you should put value = something; in the Description.ext or somewhere that will be read before the trigger is read at mission start or the trigger will not know what value is.... description.ext is a mission config file, would you mind to elaborate on your idea a bit more? Share this post Link to post Share on other sites
Devastator_cm 434 Posted October 9, 2016 I did something in that way but used init.sqf and not description.ext Share this post Link to post Share on other sites
Belbo 462 Posted October 9, 2016 I highly recommend looking at the documentation: https://community.bistudio.com/wiki/Initialization_Order Variables that are queried in triggers have to be defined before triggers are initialized. Thus they have to be defined in a function with preInit = 1. Defining variables in description.ext (https://community.bistudio.com/wiki/PreProcessor_Commands#.23define) does not make these variables visible within scripts or triggers - as far as I know. Share this post Link to post Share on other sites