A script that activates only if another has been activated.

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
mikenet2007
Posts: 340
Joined: Wed Jan 24, 2007 8:54 pm

A script that activates only if another has been activated.

Post by mikenet2007 »

I want a ceiling raise effect, only if another ceiling raise has been executed first.

Would it look something like this?

script 111 (void)
{
Ceiling_RaiseByValue (22, 70, 104);
}

script 112 (void)

{Ceiling_RaiseByValue (23, 70, 104);
if script 111 (void);
Terminate;
}


The terminate line I added because I want the second script to work only once. I haven't designed the area yet, I was wondering if someone could tell me if this is right so that when I get to it, I wont get stuck.

Thanks in advance, you guys have been awesome!
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: A script that activates only if another has been activat

Post by cocka »

OK and what will activate the script 111? Because if it's not called from for example a [wiki]UsePuzzleItem[/wiki] line then there is no point in using a script consisting of just ONE action special.
The terminate line I added because I want the second script to work only once.
terminate is for stopping running processes. It doesn't make sense putting it at the end of a script. It simply won't have any effect.

Code: Select all

bool raised;

script 111 (void)
{
	Ceiling_RaiseByValue (22, 70, 104);
	tagwait(22);
	raised = true;
}

script 112 (void)
{
	if(raised)
	{
		Ceiling_RaiseByValue (23, 70, 104);
		tagwait(23);
		ClearLinespecial(); // or if it is a thing then: SetThingSpecial(0, 0);
	}
	else
	{
		// here could be the groaning sound
	}
}
mikenet2007
Posts: 340
Joined: Wed Jan 24, 2007 8:54 pm

Re: A script that activates only if another has been activat

Post by mikenet2007 »

Thanks, I'll try this out soon. :)

Is the else line required or will it work without it? I didn't want anything to happen as an alternative.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: A script that activates only if another has been activat

Post by cocka »

Usually if you press the use button in front of a line having no special, then you'll hear a groaning sound. This is the normal behaviour, but it can be strange if there is no sound at all while you are "using" a wall.

Because in this case if you omit the else branch and press use button in front of the line having script 112 and you haven't raised the ceiling tagged 22 yet then simply nothing happens and won't be any sound.
mikenet2007
Posts: 340
Joined: Wed Jan 24, 2007 8:54 pm

Re: A script that activates only if another has been activat

Post by mikenet2007 »

It's when the player walks over a line that the script is activated, but I don't want the player knowing they're triggering anything, the line will be invisible.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: A script that activates only if another has been activat

Post by cocka »

OK then it can be omitted.
mikenet2007
Posts: 340
Joined: Wed Jan 24, 2007 8:54 pm

Re: A script that activates only if another has been activat

Post by mikenet2007 »

Thanks for the help, the script works like I need it to.
Locked

Return to “Editing (Archive)”