Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Redfive11

How to make script usable more than once

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.

 

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×