ajax Posted March 23, 2014 Posted March 23, 2014 When several scripts are running concurrently, there is a good chance that outText messages from one script will overwrite the outText message from another. It should be possible to prevent this by funneling the messages through a centralized outText dispatch function, much like the way Mist does it. The problem is that outText can be called by mission triggers, too. So... 1. Is there a way to intercept outText calls from mission triggers? 2. Is there a way to determine if a message is currently being displayed, and if so, can the display text be obtained by the script? Thanks,
Yurgon Posted March 25, 2014 Posted March 25, 2014 Too bad no one seems to know of a simple solution to the problem. 1. Is there a way to intercept outText calls from mission triggers? None that I know of (which sure doesn't mean there's no such way, I'm still a beginner with Lua and SSE; it just means I don't know of such a way). So unless that's possible, it would be necessary to use a script and perform the call "by hand" instead of simply using a trigger action "Message to all/coalition/country/group". Such messages would have to call a custom function, which is a wrapper around outText (ForCoalition/ForCountry/ForGroup) and which incorporates the logic required for pipelining/queuing. The downside is that all calls to any of the outText() functions would have to be rewritten, so this wouldn't work as a plug-in for arbitrary missions. 2. Is there a way to determine if a message is currently being displayed, and if so, can the display text be obtained by the script? Again, none that I know of. Also, I haven't looked at Mist's way of doing it, so it's entirely possible that Mist or another lib already contains some or all of this functionality. My approach would be to create my own wrapper functions, e.g. myOutText(), myOutTextForCoalition(), myOutTextForCountry() and myOutTextForGroup(). I would compile a list of all groups and their respective countries and coalitions (and probably try to only include groups with players). Each group would receive their own message queue. Therefore, myOutText(), myOutTextForCoalition() and myOutTextForCountry() would have to find all groups targeted by the messages. The actual message output would always use outTextForGroup(). Internally, the functions would need to know exactly how much time has passed since their last output started. If the desired delay has passed, the previous queue item can be deleted and the next queue item can be displayed for as long as was requested. Such a FIFO queue would require some tweaking, though, so I'd probably try to add multiple priorities (one queue per priority). Queues would then be displayed by order of priority so that a high priority "SAM launch 3 o'clock" wouldn't have to wait for previously queued normal priority "So, here's the story..." messages. It might also be a good idea for higher prioritized queues (or for a special "Alert" queue) to interrupt messages of a lower priority. Such interrupted messages would then need to be re-displayed as soon as possible. If all of this turned out to be too easy, I'd probably try to find a way to sync text and audio. The functions would therefore accept an optional audio-file parameter. If it is given, the audio-file will be played once as soon as the message gets displayed (and interrupted if the text-message gets interrupted). Another option would be to keep a back-log of one or multiple messages, so that new messages are displayed on top, and then below a "-----" kind of separator the previous X messages would be displayed. Well, creating such a message queuing mechanism sounds like a lot of fun and a good way to get further acquainted with Lua and the SSE environment. :thumbup: Unfortunately, it would take a lot of time (at least for me), so anyone feel free to go ahead. :D
ajax Posted March 25, 2014 Author Posted March 25, 2014 (edited) Thanks, Yurgon. I suspected there is no "easy" way to do this. I wonder, though, if you could define a new global outText function in your script and then manage all messages yourself. I'm thinking something like this: local oldOutText = trigger.action.outText -- save old function function trigger.action.outText(...) -- declare new global function -- do your message management -- then call old function oldOutText(...) end Edited March 25, 2014 by ajax spelling mistake
Recommended Posts