Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Xegethra

Switch with multiple "on" textures.

Recommended Posts

Hello there!

I'm wondering if switches can have multiple on textures that are chosen at random when a switch is pressed.

I have tried making switches before but could not make heads or tails with it, so I just ended up using Slade's method of making them which has been serving well so far.

But I can't find a way for it to randomise the on positions.

I tried doing it this way.


The bottom 5 textures are my switches and the bottom 4 are related to the same switch...as you can see I want that switch to have 4 on images where one is chosen randomly when pressed.

So far it only chooses the one texture and always sticks with it.

Thanks for any help if anyone knows what to do, I can't quite get it.

Share this post


Link to post

If you're making a map in zdoom doom in hexen format, you can do low level stuff like this with ACS. So like you have a switch that has an off texture, and when you switch it, you want it to randomly choose between 4 on textures? ACS can play sounds too, so I'd just not even use a conventional switch, just when you push it, have the code play the switch sound and choose among 4 random textures. I never worked with sounds in acs before but think it can do it.

Share this post


Link to post
gggmork said:

If you're making a map in zdoom doom in hexen format, you can do low level stuff like this with ACS.


I certainly am yes!

But if I have to ACS script I have to I guess, my previous attempt at such things hasn't really gone very well...I tried custom keys in the past but it didn't come to pass.

It'll be a slow thing for me to figure out if I have to ACS, I'll just have to figure out the wiki articles then as I can't find any concrete tutorials on it.

Share this post


Link to post

I just tested this and it works:
make new map in doombuilder 2, doom in hexen format
make big square 0 floor, 128 ceil
inside that, make 64x64 square 0 floor 0 ceiling
all textured as startan2
put player below 64x64 square
right click bottom line of 64x64 square, set:
action: 121, set line id: 1
click view/script editor, copy paste:

#include "zcommon.acs"
script 1 open{
    setlinespecial(1,acs_execute,2);
}

script 2(void){
    int r,t;
    r=random(0,2);
    if (r==0){t="ashwall2";}
    else if(r==1){t="ashwall4";}
    else{t="ashwall6";}
    setlinetexture(1,SIDE_FRONT,TEXTURE_TOP,t);
}
click compile top right.
This chooses a random texture among 3 types of ashwall. But there is no switch sound probably. I have no sound on this comp so cant test sound stuff. If I remember schwerpunk did sound stuff in monochrome mapping project so maybe pm him if he visits here regularly still, or change topic title to something like:
Switch with multiple "on" textures (Now need sound help)

Share this post


Link to post

Ahh thanks, I shall give this a go!



*Edit*

This worked brilliantly thanks!! I'll give you credit for the help in my map topic when I put up the next update.

Share this post


Link to post

You can also do that with arrays.

str sw2gothic[5] = { "SW2GTHC", "SW2GTHC1", "SW2GTHC2", "SW2GTHC3", "SW2GTHC4" };
Then in the script you use:
setlinetexture(l, SIDE_FRONT, TEXTURE_TOP, sw2gothic[random(0, 5)]);
I find that it's cleaner than using if/else if chains in the function itself. For ultimate nitpick:
#define NUMGOTHICSWITCHES 5
str sw2gothic[NUMGOTHICSWITCHES] = { "SW2GTHC", "SW2GTHC1", "SW2GTHC2", "SW2GTHC3", "SW2GTHC4" };
Then in the script you use:
setlinetexture(l, SIDE_FRONT, TEXTURE_TOP, sw2gothic[random(0, NUMGOTHICSWITCHES)]);
That way you can easily add or remove more random textures to your gothic switch by changing only the "definition" part of your ACS source, without touching the part with the actual code.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×