Jump to content
  • 0

How to make script usable more than once


Redfive11

Question

Im using GZdoom, doom builder, doom in hexen format, and slade.

 

Hello! Thank you for helping me answer my question.

I recently got back into doom modding and I got stuck on this feature for my map,

so basically I want the player to have to pick up two "key" weapons before he can exit his apartment.

How i've done this is by checking the players inventory in a script every time he presses "E" on his front door, and if he has both items he can leave to the next map.

But, here's my problem: The script will only run once, not every time he presses "E" on the door to check for the items.

How can I fix this?

 

Code:

Spoiler

script 1 OPEN {
    ConsoleCommand("screenblocks 12");
    ClearInventory();
    GiveInventory("Fist", 1);
    Line_SetBlocking (1,BLOCKF_PLAYERS,1);
    SetMusic("D_BATH");
    print(s:"ahhh");
    delay(100);
    ActivatorSound("FLUSH",127);
    print(s:"*FLSHHH*");
    delay(25);
    ChangeFloor(1,"FWATER1");
    delay(10);
    Line_SetBlocking (1,0,BLOCKF_PLAYERS);
}

 

*some more non-important code here*

 

script 8 (void) {
        if (CheckInventory("Keys")) {
            ActivatorSound("DOOROPEN",127);
            print(s:"Leaving...");
            delay(30);
            ClearInventory();
            GiveInventory("Fist", 1);
            Exit_Normal(0);
        }
        else {
            print(s:"I need to get my keys before I go out.\nOh yeah, also my to-do list.");
        }
}

 

 

Ive tried everything I could find and have scoured the Zdoom wiki, pls help.

 

Edited by Redfive11

Share this post


Link to post

5 answers to this question

Recommended Posts

  • 0
8 minutes ago, RonnieJamesDiner said:

Unfortunately the OP mentioned they were using Doom in Hexen Format, so there's no option for setting a Repeatable Action flag.

Not true. Doom-in-Hexen does have a repeatable lindef action flag.
image.png.e5464626cc60ada1df5d4be086b281dc.png

Share this post


Link to post
  • 0
33 minutes ago, Redfive11 said:

Im using GZdoom, doom builder, doom in hexen format, and slade.

 

Hello! Thank you for helping me answer my question.

I recently got back into doom modding and I got stuck on this feature for my map,

so basically I want the player to have to pick up two "key" weapons before he can exit his apartment.

How i've done this is by checking the players inventory in a script every time he presses "E" on his front door, and if he has both items he can leave to the next map.

But, here's my problem: The script will only run once, not every time he presses "E" on the door to check for the items.

How can I fix this?

 

Code:

  Reveal hidden contents

script 1 OPEN {
    ConsoleCommand("screenblocks 12");
    ClearInventory();
    GiveInventory("Fist", 1);
    Line_SetBlocking (1,BLOCKF_PLAYERS,1);
    SetMusic("D_BATH");
    print(s:"ahhh");
    delay(100);
    ActivatorSound("FLUSH",127);
    print(s:"*FLSHHH*");
    delay(25);
    ChangeFloor(1,"FWATER1");
    delay(10);
    Line_SetBlocking (1,0,BLOCKF_PLAYERS);
}

 

*some more non-important code here*

 

script 8 (void) {
        if (CheckInventory("Keys")) {
            ActivatorSound("DOOROPEN",127);
            print(s:"Leaving...");
            delay(30);
            ClearInventory();
            GiveInventory("Fist", 1);
            Exit_Normal(0);
        }
        else {
            print(s:"I need to get my keys before I go out.\nOh yeah, also my to-do list.");
        }
}

 

 

Ive tried everything I could find and have scoured the Zdoom wiki, pls help.

 

 

Make the door have a repeatable action.

Share this post


Link to post
  • 0

Unfortunately the OP mentioned they were using Doom in Hexen Format, so there's no option for setting a Repeatable Action flag. But yeah, Redfive11, if you were using UDMF instead of Hexen format, you could very simply attach this script to your door and then set the Repeatable Action flag on the linedef, and bingo bango bongo you're done. 

 

In Hexen format however, you could try a different approach. Give your door the (84) Script Execute with Result Action, and in the Script Number field, put the number of your script (in this case, 8).

 

Now, in your script, simply add SetResultValue(TRUE); to the if block, and SetResultValue(FALSE); to the else block, and it should work as intended. Here's the script:

 

script 8 (void)
{
        if (CheckInventory("Keys")) 
        {
            ActivatorSound("DOOROPEN",127);
            SetResultValue(TRUE);
            print(s:"Leaving...");
            delay(30);
            ClearInventory();
            GiveInventory("Fist", 1);
            Exit_Normal(0);
        }
        else 
        {
            print(s:"I need to get my keys before I go out.\nOh yeah, also my to-do list.");
            SetResultValue(FALSE);
        }
}

 

 

Share this post


Link to post
  • 0
2 minutes ago, Edward850 said:

Not true. Doom-in-Hexen does have a repeatable lindef action flag.
image.png.e5464626cc60ada1df5d4be086b281dc.png

 

Oh my god I'm blind... legally blind. Well, thank you. All this time I somehow never saw that. Learn something new everyday! 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...