1
0
Fork 0

Updated DualControl: Improved initialization to avoid extra listeners on reset.

This commit is contained in:
Anders Gidenstam 2012-03-23 22:13:46 +01:00
parent 60305380be
commit 1855d0f9d1
2 changed files with 18 additions and 12 deletions

View file

@ -1,9 +1,8 @@
###############################################################################
## $Id$
##
## Nasal for copilot for dual control over the multiplayer network.
##
## Copyright (C) 2007 - 2011 Anders Gidenstam (anders(at)gidenstam.org)
## Copyright (C) 2007 - 2012 Anders Gidenstam (anders(at)gidenstam.org)
## This file is licensed under the GPL license version 2 or later.
##
###############################################################################
@ -169,12 +168,16 @@ var disconnect = func {
######################################################################
# Main loop singleton class.
var main = {
_initialized : 0,
init : func {
me.loopid = 0;
if (!me._initialized) {
me.loopid = 0;
setlistener("/ai/models/model-added", func {
settimer(func { me.activate(); }, 2);
});
me._initialized = 1;
}
me.active = 0;
setlistener("/ai/models/model-added", func {
settimer(func { me.activate(); }, 2);
});
print("Copilot dual control ... initialized");
settimer(func { me.activate(); }, 5);
},

View file

@ -1,9 +1,8 @@
###############################################################################
## $Id$
##
## Nasal for main pilot for dual control over the multiplayer network.
##
## Copyright (C) 2007 - 2011 Anders Gidenstam (anders(at)gidenstam.org)
## Copyright (C) 2007 - 2012 Anders Gidenstam (anders(at)gidenstam.org)
## This file is licensed under the GPL license version 2 or later.
##
###############################################################################
@ -37,12 +36,16 @@ var connect = func (copilot) {
######################################################################
# Main loop singleton class.
var main = {
_initialized : 0,
init : func {
me.loopid = 0;
if (!me._initialized) {
me.loopid = 0;
setlistener("/ai/models/model-added", func {
settimer(func { me.activate(); }, 2);
});
me._initialized = 1;
}
me.active = 0;
setlistener("/ai/models/model-added", func {
settimer(func { me.activate(); }, 2);
});
settimer(func { me.activate(); }, 5);
print("Pilot dual control ... initialized");
},