1
0
Fork 0

--prop:sim/multiplay/write-message-log=1 enables logging of MP messages

to $FG_HOME/mp-messages.log
This commit is contained in:
mfranz 2009-02-15 17:36:47 +00:00
parent efaa3d545d
commit b465bd27a8
3 changed files with 25 additions and 7 deletions

View file

@ -32,3 +32,4 @@ WRITE ALLOW $FG_HOME/*.sav
WRITE ALLOW $FG_HOME/Export/*
WRITE ALLOW $FG_HOME/state/*.xml
WRITE ALLOW $FG_HOME/aircraft-data/*.xml
WRITE ALLOW $FG_HOME/mp-message.log

View file

@ -104,7 +104,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
# enable/disable menu entries
menuEnable("fuel-and-payload", fdm == "yasim" or fdm == "jsb");
menuEnable("autopilot", props.globals.getNode("/autopilot/KAP140/locks") == nil);
menuEnable("multiplayer", getprop("/sim/multiplay/txport") or getprop("/sim/multiplay/rxport"));
menuEnable("multiplayer", multiplayer.is_active());
menuEnable("tutorial-start", size(props.globals.getNode("/sim/tutorials", 1).getChildren("tutorial")));
menuEnable("joystick-info", size(props.globals.getNode("/input/joysticks").getChildren("js")));

View file

@ -9,6 +9,8 @@
# 3) Allow chat messages to be written by the user.
var is_active = func getprop("/sim/multiplay/txport") or getprop("/sim/multiplay/rxport");
var check_messages = func {
foreach (var mp; values(model.callsign)) {
@ -48,13 +50,28 @@ var echo_message = func(callsign, msg) {
settimer(func {
# Call-back to ensure we see our own messages.
setlistener("/sim/multiplay/chat", func(n) {
echo_message(getprop("/sim/multiplay/callsign"), n.getValue());
});
if (is_active()) {
if (getprop("/sim/multiplay/write-message-log")) {
var ac = getprop("/sim/aircraft");
var cs = getprop("/sim/multiplay/callsign");
var (date, time) =_= split("T", getprop("/sim/time/gmt"));
var apt = airportinfo().id;
var file = string.normpath(getprop("/sim/fg-home") ~ "/mp-message.log");
var f = io.open(file, "a");
io.write(f, sprintf("\n-- %s -- %s -- %s -- %s -- '%s' --\n", date, time, apt, ac, cs));
setlistener("/sim/signals/exit", func io.write(f, "--END--\n") and io.close(f));
setlistener("/sim/messages/mp-plane", func(n) {
io.write(f, sprintf("%s: %s\n", getprop("/sim/time/gmt-string"), n.getValue()));
io.flush(f);
});
}
check_messages();
}
# check for new messages
check_messages();
# Call-back to ensure we see our own messages.
setlistener("/sim/multiplay/chat", func(n) {
echo_message(getprop("/sim/multiplay/callsign"), n.getValue());
});
}, 1);