Skip to content

DelayCommand Apparently Not Working [Solved]

TarotRedhandTarotRedhand Member Posts: 1,481
edited April 2020 in Builders - Scripting
Context - Most current Retail version of the game. Win 10 64 bit.

I have a number of void functions that work fine if called directly but are apparently ignored when they are in a DelayCommand. This -
ResetToBlack(oArea);
works fine while this -
DelayCommand(3.0f, ResetToBlack(oArea));
seems to be ignored. In an effort to find out what is going on I put a SendMessageToPC() as the first instruction in ResetToBlack(). I see this message when I call ResetToBlack() directly but not when I try to use that function call as the second parameter for a DelayCommand(). From the BD client Options/Verify Game finds no problems either. Anyone got any idea what's going on.

Thanks.

TR
Post edited by TarotRedhand on

Comments

  • DazDaz Member Posts: 127
    What does ResetToBlack() do?
  • meaglynmeaglyn Member Posts: 151
    What object is the first script running as. Maybe it's not around anymore when the delay would fire.
  • FreshLemonBunFreshLemonBun Member Posts: 909
    It seems to still work as expected using the following script.
    void wrap()
    {
        SendMessageToPC(GetFirstPC(), "TEST DELAY SCRIPT");
    }
    
    void main()
    {
        DelayCommand(3.0f, wrap());
    }
    

    Like mentioned you should double check that the references are correct, make sure the object still exists and so on.
  • DJ_WoWDJ_WoW Member Posts: 51
    Gooday to ya,

    Whenever I use a DelayCommand to call a void/sub function I assign the command to be called by an area.

    AssignCommand(oArea, DelayCommand(3.0f, wrap());

    This may work for ya.

    DJ-WoW
  • TarotRedhandTarotRedhand Member Posts: 1,481
    Thanks guys. Especially thanks to @DJ_WoW. That worked. I don't know why it worked but it did. That is one to store for future reference.

    FWIW A friend of mine is working on a module for an 8 year old and I am scripting a very simple puzzle for them. These delays are critical for the solution to be apparent. The puzzle is simply this. There are 3 stones on the ground. On each stone there is a single letter coloured black. The letters are T, R and A and are used to spell one of these three words (determined by the contents of a local variable) - RAT or TAR or ART. They have to be clicked on, one at a time in the right order. If one is clicked on at the right time, the letter turns green. On the other hand, if it is not the right one the letter turns red for a short time before all coloured letters are recoloured to black. Once they are all green, the puzzle is solved.

    TR
  • meaglynmeaglyn Member Posts: 151
    It worked because the area still exists and the object you originally delayed on probably doesn't. Alternatively, the object delayed on has a really low priority and didn't get to run the command. That one seems less likely to me. I've read some old posts about that one but never personally hit it.

    Also, be mindful that the script function is now running as the area so depending on the script it may need to be modified at times. I don't think it is always a good idea to automatically always run delays on an area blindly.
  • FreshLemonBunFreshLemonBun Member Posts: 909
    It's possible for area instancing it wouldn't be a good idea, you can set it to other objects too but each time you change the caller. Usually you just need to make sure that the caller still exists and check the variables you pass to the function.
Sign In or Register to comment.