609_Relentov Posted April 9, 2015 Posted April 9, 2015 I'm having an issue with a small script statement - basically I have an infantry group that moves a short route, then I add a "Perform Command --> Run Script" on the last waypoint. I simply want a flag to be set to true: trigger.misc.setUserFlag(19, true) However, when I run the mission and the group moves to the last waypoint, I get the following error and DCS freezes until I click "OK": [string "trigger.misc.setUserFlag(19,1)"]:1: attempt to call field 'setUserFlag' (a nil value) stack traceback: [C]: in function 'setUserFlag' [string "trigger.misc.setUserFlag(19,1)"]:1: in main chunk I'm trying to understand what object/data type is nil... I'm used to Java where you typically have to instantiate an object and call a method of that object, but this is unclear. Any Lua experts have any tips for getting past this? Thanks! Relent
HiJack Posted April 9, 2015 Posted April 9, 2015 Isn't it supposed to be "trigger.action.setUserFlag"
609_Relentov Posted April 9, 2015 Author Posted April 9, 2015 (edited) Doh! Never mind, I just looked at the Hoggit DCS Wiki and realized I used the wrong object: It should be trigger.action.setUserFlag() not trigger.misc.setUserFlag() like getUserFlag is... (EDIT - thanks HiJack, you beat me to my self-correction :). I didn't originally notice the subtle difference as I just copy/pasted/modified trigger.misc.getUserFlag from another section - it works fine now...) Edited April 9, 2015 by 609_Relentov
ajax Posted April 9, 2015 Posted April 9, 2015 Also, I thought the function requires the flag to be a string, e.g. trigger.action.setUserFlag("19",1)
609_Relentov Posted April 9, 2015 Author Posted April 9, 2015 Also, I thought the function requires the flag to be a string, e.g. trigger.action.setUserFlag("19",1) It does, but apparently it casts the number to a string, as it worked fine having an unquoted number as that parameter.
Grimes Posted April 10, 2015 Posted April 10, 2015 Last I checked you can actually name them also... trigger.action.setUserFlag("bob",1) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Recommended Posts