How to Set up a "Perpetual" Up/Down Elevator? [HeXen Format]

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
ReX
Posts: 1584
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace
Contact:

How to Set up a "Perpetual" Up/Down Elevator? [HeXen Format]

Post by ReX »

It's been a while since I created scripts and I'm a little rusty. Using HeXen format I need to create an elevator that moves up and down perpetually, while stopping at the various floors. Here's what I am trying to set up:

1. An elevator that moves between 4 levels (call them L0, L1, L2, L3)
2. The elevator starts at L0 and automatically starts moving up to L1 upon map start
3. The elevator pauses at L1 before automatically moving up to L2
4. The elevator pauses at L2 before automatically moving up to L3
5. The elevator pauses at L3 before automatically moving down to L2
6. The elevator pauses at L2 before automatically moving down to L1
7. The elevator pauses at L1 before automatically moving down to L0
8. The elevator pauses at L0 before repeating steps 2 to 7

I know how to implement all steps except the part in Step 8, where the process repeats itself. I have looked at the FOR, WHILE, and UNTIL examples in the wiki but I'm obviously missing something.

I'd appreciate any help. Thanks.
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: How to Set up a "Perpetual" Up/Down Elevator? [HeXen Format]

Post by Blue Shadow »

You can setup a while loop like the following to execute a block of code repeatedly:

Code: Select all

while (true)
{
	// Looping code goes here.
}
User avatar
ReX
Posts: 1584
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace
Contact:

Re: How to Set up a "Perpetual" Up/Down Elevator? [HeXen Format]

Post by ReX »

@Blue Shadow: Thanks for the guidance. I'm off to implement it.
Post Reply

Return to “Scripting”