Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Code called once appears to run twice  (Read 3526 times)

0 Members and 1 Guest are viewing this topic.

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
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;

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?  ;D

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.
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Code called once appears to run twice
« Reply #1 on: October 23, 2009, 01:56:50 PM »

In the code you posted it's indeed called once. So it's probably called elsewhere. I'd recommend searching the whole project folder for "DisableMap" text occurences.

As for the syntax highlighting, if you press the code button, it inserts something like [ code] [ /code]. If you want to add nice syntax highlighting, all you need to do is add =script in the opening code tag. [ code=script] [ /code]
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Code called once appears to run twice
« Reply #2 on: October 23, 2009, 02:30:51 PM »

Hi Mnemonic

Thanks for your help on this. There are indeed other scripts that use this code, but they cannot have run because they're associated with inventory items we haven't found yet, so there can be nothing else calling it. The code is very specific to these inventory items - the windows only run from the inventory scripts and the items are not in inventory.

Any other thoughts?

BTW, thanks for the tip on the code button - will you be making that the default code the button produces?

Cheers

Noel
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Code called once appears to run twice
« Reply #3 on: October 23, 2009, 04:07:52 PM »

Hi Mnemonic

As a further test, I renamed the method to "Donkey". Now I know for certain there is nothing else in this game called "Donkey". And yes, it ran twice.

I know I've said it before and I'm (almost) always wrong but I'm beginning to worry it might be a Bug. Sorry to drop the 'B' bomb :)

Your thoughts?

Thanks   
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Code called once appears to run twice
« Reply #4 on: October 23, 2009, 04:54:44 PM »

No thoughts, not enough info. The first bit of code can be called multiple times as far as I can tell.
If you can provide a minimal repro project, then I can look into it. Until then it's way too vague, I'm afraid.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Code called once appears to run twice
« Reply #5 on: October 25, 2009, 12:44:01 PM »

insert a command Debug(); in the beginning of the code which seems to run twice for you. Then in Project Manager enable debugging console. If you do this the code will fall back into the debugger whenever this thing is reached and you can easily trace why (and from which place) it's going to be called.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
 

Page created in 0.018 seconds with 24 queries.