Jump to content

Recommended Posts

Posted

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

Posted (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 by 609_Relentov
Posted
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...