16
Technical forum / Code called once appears to run twice
« on: October 23, 2009, 01:24:58 PM »
Hi all
I have code that I believe to have called once, that seems to run twice. An entity contained in a window makes the following call;
The script it's calling upon, CauldronMap.script, responds thus:
The window issues the command CauldronMap.DisableMap(); only once, as shown. However, the Game.Msg outputs show the routine is running twice, and I'd really rather it did as I thought I'd told it to.
Anybody got any ideas how I may be deluding myself this time?
Cheers
BTW - if the colours of this message are all wrong, it's not me - all I did was press the code button and insert the code between the anchors.
Blame it on the button.
I have code that I believe to have called once, that seems to run twice. An entity contained in a window makes the following call;
Code: [Select]
// Map thing
var CauldronMap = new Object("entities\CauldronCombine\CauldronMap.script");
CauldronCombine.S = false;
global Noel;
Game.Msg("On opening window, Noel.Map is: "+Noel.Map);
CauldronMap.DisableMap();
CauldronCombine.S = true;
//
The script it's calling upon, CauldronMap.script, responds thus:
Code: [Select]
method DisableMap()
{
// TEST CODE
if(CauldronCombine.Disable == null)
{
CauldronCombine.Disable = 1;
}
else
{
CauldronCombine.Disable = CauldronCombine.Disable + 1;
}
Game.Msg("Disable count: "+CauldronCombine.Disable);
//
var a = CauldronCombine.P;
var b = CauldronCombine.S;
var c = CauldronCombine.W;
var d = CauldronCombine.PS;
var e = CauldronCombine.SW;
if(a != true && b != true && c != true && d != true && e != true)
{
Game.Msg("At First, Noel.Map: "+Noel.Map);
CauldronCombine.First = true;
CauldronCombine.FirstMap = Noel.Map;
CauldronCombine.MapState = CauldronCombine.FirstMap;
}
else
{
CauldronCombine.First = false;
CauldronCombine.MapState = CauldronCombine.FirstMap;
}
Noel.Map = false;
}
The window issues the command CauldronMap.DisableMap(); only once, as shown. However, the Game.Msg outputs show the routine is running twice, and I'd really rather it did as I thought I'd told it to.
Anybody got any ideas how I may be deluding myself this time?

Cheers
BTW - if the colours of this message are all wrong, it's not me - all I did was press the code button and insert the code between the anchors.
