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.
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 ).
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.
[*] Set your actionable Linedef's Action to 80 (Script), and enter the Script's name (here, 3DFS1, rename to whatever you want) in the box after checking "Use Script Name".
[*] Set these Linedef's flags to true (check the boxes): "Repeatable action", and then whichever method it will be activated by (eg, "When Player Presses Use").
[*] getactorz(0) gives the player's current height when the script is executed. Divide this by 65536 to get the height in map units. My switch is at a height of 450, so as
long as the player is higher than a few units below this, the switch will activate. I have no floors above it, so there is no need to add a 'less than' rule to make sure the switch isn't activated from above. Adjust this to suit your needs.
[*] The line's id (tag number) for setlinetexture should refer to the Linedef of the CONTROL SECTOR for your 3D floor with the 3D Floor Special 160. Set the line's tag to an unused tag and use this number where I have used 7 above. Set the SIDE_ to 'Front' or 'Back' and TEXTURE_ to 'Upper', 'Middle' or 'Lower' depending on how your switch is constructed. "sw2gray1" is the lit texture of my switch. Replace this with the texture name of the one you need.
[*] floor_raisebyvalue () is the function I wanted my switch to perform. Replace this with yours.
[*] Clearlinespecial removes the ability to activate this more than once. The line action is set to repeatable because if the player happens to active the line from somewhere they shouldnt, although the height check means the code won't run, the code wouldn't run again from the correct location if it wasn't. Of course, I don't want the floor to raise twice should the player use the switch again, so this bit of code makes the linedef dormant after the switch has been activated from the right place.
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.
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... =]
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!
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 =]).
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.)
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.
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