TEMPEST.114 Posted October 9, 2022 Posted October 9, 2022 I've tried googling this and searching these forums but my keywords aren't bringing up results. I'm making a mission that has flags created/defined and set in the Mission Editor but I'd like to write a little script that changes the state or values of these flags that gets run on a timer, and then have - in the Mission Editor - the triggers based on those flags states. Is this possible or am I over thinking it?
Rudel_chw Posted October 9, 2022 Posted October 9, 2022 2) On a script, I can get the value of a Trigger Flag (for example Flag 60) with this piece: local temp = trigger.misc.getUserFlag('60') __________________ 3) And the reverse, I can alter the value of Flag 60 from within a script with: trigger.action.setUserFlag('60', temp) ______________ 1 For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra For Gaming: 34" Monitor - Ryzen 3600 - 32 GB DDR4 2400 - nVidia RTX2080 - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar Mobile: iPad Pro 12.9" of 256 GB
TEMPEST.114 Posted October 9, 2022 Author Posted October 9, 2022 20 minutes ago, Rudel_chw said: 2) On a script, I can get the value of a Trigger Flag (for example Flag 60) with this piece: local temp = trigger.misc.getUserFlag('60') __________________ 3) And the reverse, I can alter the value of Flag 60 from within a script with: trigger.action.setUserFlag('60', temp) ______________ thanks! So, correct me if I'm wrong. In the mission editor I create all the flags I'm interested in and then I can get them and manipulate them in the script but the Mission Editor always knows when the script has changed it automatically? I don't need to tell the Mission/Mission Editor to update its state when I've changed them in the script? One more silly question... I know flags can have a text name instead of a number (I think they're all strings in the backend right?) So can these text names have spaces in them? Is that okay?
cfrag Posted October 9, 2022 Posted October 9, 2022 5 hours ago, Elphaba said: In the mission editor I create all the flags I'm interested in and then I can get them and manipulate them in the script but the Mission Editor always knows when the script has changed it automatically? Flags are less complex than you probably fear - they are merely named value containers that are shared by every script that runs in the mission - and the main mission is also just a script; it's a script that you happen to use Mission Editor to set up. Mission Editor itself is not running while a mission runs. So if one of your scrips changes a flag, all other scripts (the main mission script included) can see the new value as soon as they look at it. There is no secret handshake involved, and it's thankfully very straightforward. 5 hours ago, Elphaba said: One more silly question... I know flags can have a text name instead of a number Thankfully, finally, YES! (so you can finally have a flag 'all enemies are dead' - this is rather new and has been a wish list item for years) 5 hours ago, Elphaba said: So can these text names have spaces in them? Is that okay? Yes. I recommend against it - you'll likely trip up yourself. I prefer camelCase - no blanks, but upper case for the next word 1
TEMPEST.114 Posted October 9, 2022 Author Posted October 9, 2022 46 minutes ago, cfrag said: Flags are less complex than you probably fear - they are merely named value containers that are shared by every script that runs in the mission - and the main mission is also just a script; it's a script that you happen to use Mission Editor to set up. Mission Editor itself is not running while a mission runs. So if one of your scrips changes a flag, all other scripts (the main mission script included) can see the new value as soon as they look at it. There is no secret handshake involved, and it's thankfully very straightforward. Thankfully, finally, YES! (so you can finally have a flag 'all enemies are dead' - this is rather new and has been a wish list item for years) Yes. I recommend against it - you'll likely trip up yourself. I prefer camelCase - no blanks, but upper case for the next word Thank you!
Recommended Posts