The Grease Mage 0 Posted November 23, 2024 Howdy. I am moderately experienced with programming, but green to Arma scripting. I have a sector module placed in my editor, and a script in my mission directory "objectiveControl.sqf". In the "expression" attribute of the Sector module (ModuleSector_F), the description says that passed arguments are [<module>,<ownerSide>,<previousOwnerSide>] I would like to use the expression field to call a file or a function of my own, while passing and ultimately use those arguments for logic in the respective file or function. All attempts have given me "undefined ownerSide variable" or currently "local variable being used in global space".Sector expression: [] execVM "objectiveControl.sqf";objectiveControl.sqf code: params ["module","ownerSide","previousOwnerSide"]; hint(ownerSide); Share this post Link to post Share on other sites
Schatten 290 Posted November 24, 2024 Read carefully: https://community.bistudio.com/wiki/params Share this post Link to post Share on other sites
pierremgi 4906 Posted November 24, 2024 19 hours ago, The Grease Mage said: objectiveControl.sqf code: params ["module","ownerSide","previousOwnerSide"]; hint(ownerSide); Not HTML but sqf language! params ["_module","_ownerSide","_previousOwnerSide"]; // example for local variables so underscored at start hint str _ownerside; // you need to stringify what you want to hint (here a side). see: https://community.bistudio.com/wiki/Variables with all "see also" links. Then always pay attention for syntax of the Arma commands. Share this post Link to post Share on other sites
The Grease Mage 0 Posted November 24, 2024 mmm, I see. Very impressed I missed the big red box on the params wiki that says "All variables names must start with underscore". I took care of that and added "hint str" as well, but unfortunately it's back to giving me an "undefined _ownerSide variable" error.Sector module expression field: [] execVM "objectiveControl.sqf";objectiveControl.sqf: params ["_module","_ownerSide","_previousOwnerSide"]; hint str _ownerSide; per my advanced learning art of Trying Shit Without Even Knowing Why, I made another attempt.objectiveControl.sqf: params ["_module","_ownerSide","_previousOwnerSide"]; test = _this select 1; hint str test; but this just lands me an error saying I "tried to divide by zero", which apparently also appears if one tries to access an array element that isn't there. Still got more to learn about _this I guess. Share this post Link to post Share on other sites
Schatten 290 Posted November 24, 2024 Errors because you pass an empty array to the script. 1 Share this post Link to post Share on other sites
The Grease Mage 0 Posted November 24, 2024 Okay, I wasn't sure how much the module was handling for the passing of the arguments. I got it working fine now with this final version:Sector module expression field: [(_this select 0), (_this select 1), (_this select 2)] execVM "objectiveControl.sqf";objectiveControl.sqf: params ["_module","_ownerSide","_previousOwnerSide"]; hint str _ownerSide; Thanks for the help. Lmk any appropriate & popular places I could ask quick one-off noob questions. Like, "Some 'if' statement wiki examples have one semicolon, some have two. Is that a typo? What's up with that?" Share this post Link to post Share on other sites
Schatten 290 Posted November 24, 2024 2 minutes ago, The Grease Mage said: [(_this select 0), (_this select 1), (_this select 2)] execVM "objectiveControl.sqf"; You can simplify: _this execVM "objectiveControl.sqf"; 3 minutes ago, The Grease Mage said: Lmk any appropriate & popular places I could ask quick one-off noob questions. Like, "Some 'if' statement wiki examples have one semicolon, some have two. Is that a typo? What's up with that?" I think this forum is OK for such questions. You can also join Arma Discord. Share this post Link to post Share on other sites