Page 1 of 1

Insert message into log with lua?

Posted: Sat Sep 01, 2018 2:46 pm
by Whicker
Is there a way to insert a message via lua into the log without a pop-up/special message?

I am playing around with using a single lua event to handle scoring and it works well except I am using Unit Destroyed as a trigger, and Weapons fall into that category, so my log has lots of Unit Destroyed Events showing when they are really just weapons not actual units. I could turn off Display in Log, but then I wouldn't get anything in the log. I'd like to just insert a log line item as I see fit, just like print works in the lua history - so maybe print_log("message here").

I do have a print statement that prints to the lua history log which is fine for me as I use that constantly but other people probably wouldn't use it.

RE: Insert message into log with lua?

Posted: Sat Sep 01, 2018 2:54 pm
by Whicker
I do see that the game is already generating a message saying:

8:45:27 PM - 8:45:27 PM - Grim #1 (MQ-9B Reaper-ER Blk 5 UAV) has been destroyed!

I am so used to looking for blue colored messages I don't see that one so easily, plus I would like to customize it with the score change, and not have it lost in all the red messages.

There have been other times I would like to insert a custom log message without creating a pop up/special message.

RE: Insert message into log with lua?

Posted: Sat Sep 01, 2018 10:34 pm
by michaelm75au
Have you tried adding a condition to exclude weapons? And/or turn off the 'display in log' if so, and turn on if not?
Haven't tried it but might be an option.

RE: Insert message into log with lua?

Posted: Sun Sep 02, 2018 12:05 am
by Whicker
I am excluding weapons in the script, but the trigger is any unit destroyed. So the action shows in the log, but then the script sees it is a weapon and exits.

The more I played with it the less I felt like I needed the log message... I use the luahistory log and love that, and I can do anything I want in there. I use it as a 2nd log file when playing.

Conditions... I've been ignoring those and haven't seen them in use yet. But that does sound like an option - I have been wanting to exclude stuff from a trigger and was going to suggest having some sort of way to do that in the Trigger UI. But maybe conditions are the thing to do that.



RE: Insert message into log with lua?

Posted: Sun Sep 02, 2018 1:02 am
by michaelm75au
I think condition events are under-rated; rarely see them used in events. Probably the thing I don't like about them is the logged message each time the condition fails; this can mess up the log a bit.
If they are suppressed, then you can't tell if the event itself fired.