ENO Posted February 14, 2014 Posted February 14, 2014 Eh guys. I'm trying to test it out but I can't on my laptop for some reason... I'm wanting to add a radio item to help guys understand where they're at in the mission. I've been playing with the notion of increasing flag values when objectives are completed and adding radio items to state that this is happening. So flag 300 equals 1 I make a radio item that says "one group destroyed" with flag set 300 / 1. What I'm wanting to know is when flag 300 is 2 and "two groups destroyed"... will that override the former flag or do I need to actually turn the former flag off? Thanks in advance. I've never really been that great with adding radio items etc... so this is a bit on the new side. "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art
Robin_Hood Posted February 14, 2014 Posted February 14, 2014 You are talking about F10 Radio menu items, right ? Items there will stay as long as they are not removed. So if you want your 300/2 item to replace the former, you could do (the folowing is pseudo-code) If flag(300) = 2 then RemoveRadioItem("One group destroyed") and AddRadioItem("Two Groups destroyed") I hope I was clear enough and it answers your question. 2nd French Fighter Squadron
ENO Posted February 14, 2014 Author Posted February 14, 2014 (edited) Awesome. That's exactly what I need! Thanks! By pseudo code do you mean I can't just transfer that over or will it suffice (if I get the messages right) Edited February 14, 2014 by ENO "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art
Robin_Hood Posted February 14, 2014 Posted February 14, 2014 Yeah, I mean that it is just to show you the idea, it won't work as is. The real triggers panel would look like in the attached screenshot. Note that if the radio item is not really supposed to do stuff when used, you will want to make sure that the flag it sets is not used for anything else (in my example, when "Two groups destroyed" is selected in the in-game radio menu, it sets flag 1 = 1 ; this may not be desirable, obviously, if you are already using flag 1 somewhere). 1 2nd French Fighter Squadron
ENO Posted February 15, 2014 Author Posted February 15, 2014 Thanks Robin Hood. That's what I was thinking would be necessary but I was hoping there would be a more efficient way with a script. I guess either way there is some work involved and with cloning it should be minimal. Regards and rep for your time! "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art
Robin_Hood Posted February 15, 2014 Posted February 15, 2014 Oh, well you can certainly do that with a script, although it would essentially boil down to the same (removing item and adding the new one - I don't think there is a way to simply change the label). Also, I am just starting with the Scripting engine, and I am not sure how the flag-value checking would be done. Maybe a repeating function that runs every few seconds would do the trick. You might try something along these lines (I tried to comment the code so that hopefully it makes sense): function CheckObjectives () local groupsDestroyedFlag = trigger.misc.getUserFlag("yourFlag") -- assigns the flag value to the variable groupsDestroyedFlag missionCommands.removeItemForCoalition(Objectives) -- removes the current radio item Objectives = missionCommands.addCommandForCoalition(coalition.side.BLUE, groupsDestroyedFlag.." groups destroyed", nil, nil, nil) -- adding the radio item - it should show the flag value, and when triggered, do nothing (function nil) -- not sure if calling "nil" as a function works - at worst you could call a dummy function, though it would be very inelegant timer.scheduleFunction(CheckObjectives, nil, timer.getTime() + 5) -- will call the function again in 5 seconds, that should make it run periodically end Objectives = missionCommands.addCommandForCoalition(coalition.side.BLUE, groupsDestroyedFlag.." groups destroyed", nil, nil, nil) -- initialize the radio item (so that it doesn't return an error when it first tries to remove it timer.scheduleFunction(CheckObjectives, nil, timer.getTime() + 5) -- calling the function for the first time (with the same 5 seconds delay after the radio item was created) There might be a more efficient way, perhaps. I hope it helps, I'm just getting into scripting. 2nd French Fighter Squadron
dooom Posted February 15, 2014 Posted February 15, 2014 Mist handles this pretty elegantly as well ASUS Tuf Gaming Pro x570 / AMD Ryzen 7 5800X @ 3.8 / XFX Radeon 6900 XT / 64 GB DDR4 3200 "This was not in the Manual I did not read", cried the Noob" - BMBM, WWIIOL
Robin_Hood Posted February 15, 2014 Posted February 15, 2014 (edited) I must say that I haven't really looked into MiST yet, as I haven't really stumbled on something where it would help a lot, but a quick looked show that indeed, mist.scheduleFunction seems a good replacement for timer.scheduleFunction, as it accepts a function with more than one argument, and can be repeated automatically. Both of which are fairly easy to do manually, but it forces cumbersome code to be inserted. I suppose an EventHandler could be used also, like a world.event.S_EVENT_HIT maybe. But I must I haven't tried working with those yet. Edited February 15, 2014 by Robin_Hood 2nd French Fighter Squadron
Recommended Posts