Jump to content

ZDoom scripting question


ReX

Recommended Posts

These questions are for you ZDooM scripting wizards out there (you know who you are -- Wild Man, Tarin, etc.)

1. I've created a force-field using the Wild Man's tutorial (i.e., one line that repels the player with damage, another that is impassible that turns passable after a switch has been turned off.) The line that repels also triggers some text on the screen (e.g., "Ouch! Have to turn off the field generator.") and is repeatable. How do I set it up so that the whole text appears only the first time the player tries to cross the line, but after the first time only "Ouch!" is printed? I know there's some syntax involved (e.g., if player has not tried to cross line print "aaaaa", else print "bbbbb"), but what is it?

2. How do I set up a switch that requires a key to run a script? (i.e. if player has red key run script, else print "You need a red key to activate this object".)

Share this post


Link to post

int FirstHit; // var for first time the player moves into the line

scrpit 1 (void)
{
if(FirstHit == 0) {
print(s:"Ouch! Have to turn off the field generator.");
FirstHit=1;
}
else print(s:"Ouch!");

.
. // your other stuff here
.
.
}


I'm not sure if it is possible to make a script only run with a certain key in ZDooM, but it should be possible with ST. Or does it work?

Share this post


Link to post

You can use a little workaround for the key thing: make a script that sets a variable when the key is picked up and check for that variable when the player wants to execute the script. has he picked the key up before you can execute the script, else print "you need a [some color] key!".

Share this post


Link to post

This week's DEN will have a better Forece Field in it than the original tut I did. Also, DEN will also be part of IcarusWeb so you can look for it there as well.

Share this post


Link to post

Forgot to answer your key question. From the Zdoom docs:

83:ACS_LockedExecute (script, map, s_arg1, s_arg2, lock)
script Script to execute
map Map which contains the script
s_arg1 First argument passed to the script
s_arg2 Second argument passed to the script
lock Required key, if any (see key types)


Executes the specified script if the player has the right key. A map value of zero indicates that the script is on the current map. If the script is on a different map, then the execution of the script will be delayed until the player enters the map that contains it. Only one copy of a script can be running at a time when started with this special.

If the specified script was previously executed but then suspended, then execution will begin at the point immediately after where it was suspended instead of starting over again at the beginning.

Share this post


Link to post
Guest
This topic is now closed to further replies.
×
×
  • Create New...