[SCRIPT] - For a Working Switch on a 3D floor

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
Post Reply
User avatar
DracoNoir
Posts: 46
Joined: Wed Oct 28, 2015 4:45 pm
Location: UK

[SCRIPT] - For a Working Switch on a 3D floor

Post by DracoNoir »

Howdy all.

A complete noob to ACS here so not really sure I should be offering advice to others, however I had a problem I couldn't find a complete solution for, figured out the solution and it seems to work ok for me. I'm sure there's a better, tidier and probably simpler way of doing it, but it might be a good basis for another beginner to work from (or to learn badly from :lol: ).

So, you've made a switch on a 3D floor using a simple LINEDEF action. It works, but it doesn't make a sound, the texture doesn't change to the 'activated' version and it can be operated from a level higher or lower than the switch itself (eg, on the floor below if the player lines up just right.).

Not Good! Well, for just 3 simple instalments of $9,999.95, you too can own a little piece of script that should sort all this out for you! Just kidding - here it is!

For the purposes of this tutorial, I am using the latest GZDB and the last OpenGL 2 version of GZDoom.

Code: Select all

script "3DFS1" (void) 
    {
    if ((getactorz(0)/65536)>445)
       {
        activatorsound("switches/normbtn",127);
        setlinetexture(7, SIDE_Front, TEXTURE_Middle, "sw2gray1");
        floor_raisebyvalue(264, 32, 422);
        CLEARLINESPECIAL();
        }
    }
A few notes:
Spoiler:
As I said, there'll undoubtedly be a much better way of doing this, but I'm very much a beginner, trying to pass on what I've learned =]
Last edited by DracoNoir on Sun Nov 29, 2015 3:42 pm, edited 1 time in total.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by Tormentor667 »

By the way, why does this behavd like that anyway? No sound? No changing texture? Seems like a bug to me...
User avatar
DracoNoir
Posts: 46
Joined: Wed Oct 28, 2015 4:45 pm
Location: UK

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by DracoNoir »

Not sure, someone will probably be along who can explain fully, but I think its because the linedefs technically have an inherited Special 160 from the control sector (ever try to change just one texture of a 3D floor's wall, only to have all of them change?) so maybe something to do with too many actions going on on one linedef? Just a guess... =]
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by Gez »

A switch is a linedef (okay) which has a switch texture (you're following me so far?) on one of the texture fields of its front sidedef.

So what you want to do is to have the linedef with the special have a switch texture. Easy-peasy! You can generally put it on the upper or on the lower texture, and it'll work. The only exception is if both upper and lower textures can be seen and shouldn't be switches; but you can always work around that by using more 3D floors...

Anyway, it's cool that you have a switch sound and all, but it'd be even cooler if the 3D floor switch actually showed a switch texture that updates... Well, it's easy as well! Go on the wiki for [wiki]Sector_Set3dFloor[/wiki] and take a better look at all these complicated and messy argument flag parameter stuff. What are those 16 and 32 flags?

Here's a very simple example wad. A small room with a floating cube with two switches. One of the switches raises the cube by two map units, the other lowers it by the same value. Both are infinitely repeatable. Zero script used. Enjoy!
Attachments
switch3D.zip
(960 Bytes) Downloaded 245 times
User avatar
DracoNoir
Posts: 46
Joined: Wed Oct 28, 2015 4:45 pm
Location: UK

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by DracoNoir »

Knew it would be you, Gez, or maybe scifista =]

That's a nice example, but the switches in your example CAN be operated from below the switch (ie the action linedef runs all the way from floor to ceiling of the parent sector). How do you then make it so the 3D floor switch can ONLY be operated from the same floor WITHOUT some sort of code to make sure the player is at the right height? Also, my switch texture does update (as the switch is only meant to actually be operated once).

Otherwise in the WAD I am building, the player would be able to skip part of the level should they happen to operate the switch from the floor below (unlikely unless they knew it was there, I know, but its only two lots of iddt =]).
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by Gez »

That's more complicated.

There is a feature for that ("check switch range" flag) but it doesn't work with 3D floors, unfortunately. (Or at least, it doesn't work with 3D floors yet.)
User avatar
DracoNoir
Posts: 46
Joined: Wed Oct 28, 2015 4:45 pm
Location: UK

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by DracoNoir »

So is the code I've put there an acceptable way of doing what I wanted or should I have done it a different way? To be honest, having to set the repeatable flag then removing the special entirely after the code ran correctly seems a bit of a clanky way of doing it, but I couldn't find a way to have the code reset the switch to 'unused' if the height check statement returned false.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by Gez »

Well I went there and made check switch range work with 3D floor switches built using the upper or lower texture system.
User avatar
ibm5155
Posts: 1268
Joined: Wed Jul 20, 2011 4:24 pm
Contact:

Re: [SCRIPT] - For a Working Switch on a 3D floor

Post by ibm5155 »

The way I did long time ago is just check the distance of the player from the switch, if it's too far away, do not active it, if not, active the script
Post Reply

Return to “Tutorials”