Mangrove Jack Posted June 8, 2021 Share Posted June 8, 2021 I am trying to get the flag value of 4 random flags after mission start (using condition Time more than 40 seconds) and just have message on screen for 20 seconds. These represent 9%,25%, 33%, 90% random possibility. I found some code by Hardcard and was trying to adjust it but cannot get it to show. I also know little about LUA so would appreciate any help. Code I have so far: local function Flags_1() local FlagTable_1 = { -- This table contains flags 109, 125, 133, 190 Flag_109 = trigger.misc.getUserFlag ( '109' ), Flag_125 = trigger.misc.getUserFlag ( '125' ), Flag_133 = trigger.misc.getUserFlag ( '133' ), Flag_190 = trigger.misc.getUserFlag ( '190' ) } trigger.action.outText("Flag_109 value = "..FlagTable_1.Flag_109.."\nFlag_125 value = "..FlagTable_1.Flag_125.."\nFlag_133 value = "..FlagTable_1.Flag_133.. "\nFlag_190 value = "..FlagTable_1.Flag_190, 20,true) --This message will show the status of flags 109, 125, 133, 190 end I was getting values out with the following script message but it never changed value from "1" - so I guess it was just showing that flag was there? trigger.action.outText( 'Flag 125 Injured: ' .. trigger.misc.getUserFlag ( '125' ), 20 ) trigger.action.outText( 'Flag 133 Escaped: ' .. trigger.misc.getUserFlag ( '133' ), 20 ) Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB Link to comment Share on other sites More sharing options...
cfrag Posted June 8, 2021 Share Posted June 8, 2021 trigger.misc.getUserFlag does just that - it returns the current value of that flag. So I guess the next question is: how do you set the flags, and to which values? Perhaps it helps if you show us that as well, and then explain what you would have expected to see vs. what you are seeing (if I read you correctly, you are getting '1' across the board) Link to comment Share on other sites More sharing options...
Mangrove Jack Posted June 8, 2021 Author Share Posted June 8, 2021 That's correct cfag always get"1". Attached simple mission to show start and setting flags. I assume that if true then it equals "1" and false = "0" Test of Random Flag sets.miz Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB Link to comment Share on other sites More sharing options...
dark_wood Posted June 8, 2021 Share Posted June 8, 2021 Can you try same script without quotes on flag name, something like: Flag_109 = trigger.misc.getUserFlag ( 109 ), ? Link to comment Share on other sites More sharing options...
cfrag Posted June 8, 2021 Share Posted June 8, 2021 From what I can see in the miz, you are simply setting the flags via Flag ON, which will set it to 1, so this tracks with what you see. What did you try to accomplish, or phrased differently: what did you expect? Link to comment Share on other sites More sharing options...
cfrag Posted June 8, 2021 Share Posted June 8, 2021 Wait - I now see that you are using a Random condition to set the flags, so your question is probably: what is wrong with the random condition because it seems to always fire. Is that the question? Link to comment Share on other sites More sharing options...
Mangrove Jack Posted June 8, 2021 Author Share Posted June 8, 2021 Yes that is the question. I wanted to only set a flag (true/1) dependant on the random possibility. So flag 109 only has a 9% chance of being set on. I am starting to get the picture that that will not work with Random condition. Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB Link to comment Share on other sites More sharing options...
Mangrove Jack Posted June 8, 2021 Author Share Posted June 8, 2021 Ok so after reading up a bit am I correct is saying: Using simple Random condition and then checking value after a time span this was giving the Random Condition time to turn "True"? In a test I changed from 'Once' to Mission Start and it seems to be giving changing values. Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB Link to comment Share on other sites More sharing options...
cfrag Posted June 8, 2021 Share Posted June 8, 2021 From the hoggitworld docs, the Random Condition has a side effect you may have overlooked (see third line): Quote Think of condition "Random 50%" to be a coin flip. Each time the trigger is checked, the simulator flips the coin. If the coin lands on "heads" the condition will become true, and the action will execute. If the coin lands on "tails" the condition will remain false, and the trigger will be checked again until the condition true. Emphasis from the docs. This means that after 40 seconds, there is a great likelihood that all triggers have become true (1) since even at 9%, the Mission's had 40 shots at it. Link to comment Share on other sites More sharing options...
Mangrove Jack Posted June 8, 2021 Author Share Posted June 8, 2021 Yes that was the Doc I looked at and have changed from 'Once' to 'Mission Start' for the flag setting which depend on Random. Thanks Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB Link to comment Share on other sites More sharing options...
Hardcard Posted June 8, 2021 Share Posted June 8, 2021 @Mangrove Jack What are you using those flags for? What's the goal you're trying to achieve? [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Mangrove Jack Posted June 9, 2021 Author Share Posted June 9, 2021 Hardcard was trying to get various different % to generate true flags (some low % some high %) to then use flags as triggers for different scenario's/outcomes in a MP mission. Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts