Linking a door with a switch to open/close

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
mcunha98
Lieutenant Colonel
Posts: 384
Joined: Sat Jan 17, 2004 1:52 am
Location: Brasil
Contact:

Linking a door with a switch to open/close

Post by mcunha98 »

Hi,

I make a map and have a idea of use a door (door, dont is rotationdoor) with two dispositives to open/close (one dispositive in each side (in/out) of door).

Exist a tutorial to show this technique ????
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

not to spam but i have question:

can you also name the switch (the switcch being on that can animate) door1 and have it animate when the trigger is fire?

[trigger connects to door and switch... hit trigger, switch animates and door turns]
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Sure. Just place you animated switch model wherever you want and give it a targetname of doorswitch.

Then, just give your trigger_use these additional values:

targetname: doorswitch_trigger
setthread: switchmove

Then, in your script:

Code: Select all


switchmove:

level.doorswitch_on = 0
$doorswitch_trigger waittill trigger

if (level.doorswitch_on == 0)
{
level.doorswitch_on = 1
$doorswitch playsound alarm_switch
$doorswitch anim on
end
}
if (level.doorswitch_on == 1)
{
level.doorswitch_on = 0
$doorswitch playsound alarm_switch
$doorswitch anim off
end
}

end

I'm pretty sure that should work. If it doesn't, I'll do some tweaking.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
User avatar
mcunha98
Lieutenant Colonel
Posts: 384
Joined: Sat Jan 17, 2004 1:52 am
Location: Brasil
Contact:

Post by mcunha98 »

Axion

Thanks for your indication, is very simple the tutorial, but very good !
My unique question, is possible make two triggers/targets for a unique door,

Code: Select all

------------------------------
|   t1       d               |
|            o               |
|            o               |
|            r        t2     |
------------------------------

User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Yes, it is possible.

I'm making a test map now to double check the scripting I posted earlier. When I'm finished I'll give you a link to download the example map if you'd like to study it.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

uhm i meant w/o a script... (not to bog you down with two tasks)
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Well, to my knowledge I don't think it's possible to command an animate_object to move without commanding it to do so through script commands.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

Here's a link to download the example map (Don't be fooled by the name, I added onto an already existing tutorial map of mine):

http://webzoom.freewebs.com/axion9/down ... torial.zip

If you want to play the map to test out the door, you'll have to load it like a single-player map. Open up the console and type the following:

map test_sit_tutorial

The hit enter and the map will load.

By the way, here is how I ended up scripting the door switches-

Code: Select all

switchmove1:


$doorswitch1_trigger waittill trigger


	iprintln "The door has been triggered!"	
	$doorswitch1_trigger nottriggerable
	$doorswitch1 anim turn
	$doorswitch1 playsound alarm_switch
	wait 3
	$doorswitch1_trigger triggerable	
	$doorswitch1 anim off
	goto switchmove1


end

switchmove2:


$doorswitch2_trigger waittill trigger


	iprintln "The door has been triggered!"	
	$doorswitch2_trigger nottriggerable
	$doorswitch2 anim turn
	$doorswitch2 playsound alarm_switch
	wait 3
	$doorswitch2_trigger triggerable	
	$doorswitch2 anim off
	goto switchmove2


end
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
User avatar
mcunha98
Lieutenant Colonel
Posts: 384
Joined: Sat Jan 17, 2004 1:52 am
Location: Brasil
Contact:

Post by mcunha98 »

Axion

I read your tutorial, really is very good.
But when i make the door, i have some questions:

1) I set the var "wait " to -1, none return, when i open the door using the trigger, if i press "E" again the door not close (never). Is possible control the open / close action using the switch ?

2) When i open the door, the default sound is the common sound of a door,how i play a specific sound of ubersound.scr while the door is opened.


Some to comment, exist a website with "scrolling doors" textures (gates or some like this) ????
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

Master-Of-Fungus-Foo-D wrote:not to spam but i have question:

can you also name the switch (the switcch being on that can animate) door1 and have it animate when the trigger is fire?

[trigger connects to door and switch... hit trigger, switch animates and door turns]
Im sure you can, Just change the anim from idle to on?
Does this sound close?
Image
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

mcunha98 wrote:
1) I set the var "wait " to -1, none return, when i open the door using the trigger, if i press "E" again the door not close (never). Is possible control the open / close action using the switch ?

2) When i open the door, the default sound is the common sound of a door,how i play a specific sound of ubersound.scr while the door is opened.


Some to comment, exist a website with "scrolling doors" textures (gates or some like this) ????
1) I believe that if you make the door lockable with the global/door_locked.scr, it's possible. If the door being closed = locked, then pressing the switch to unlock it would open the door. Pressing the switch again would lock the door, making it close. I don't know if it's possible to fit all of that into just two switches (my feeble scripting brain isn't sure), so you may need to have two sets of switches (One set to open the door, and the other set to lock the door).

2) *Edit* You can specify different sounds for the door in the entity dialogue box. You just need to get the aliases for the different sounds and then specify them.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
User avatar
mcunha98
Lieutenant Colonel
Posts: 384
Joined: Sat Jan 17, 2004 1:52 am
Location: Brasil
Contact:

Post by mcunha98 »

2) When i open the door, the default sound is the common sound of a door,how i play a specific sound of ubersound.scr while the door is opened.
You tell to i simply make a sound in script file using scriptmaker, and based into the ALIAS of sound, example "door_open", put in dialogue with key soundopen and the alias name ?
User avatar
Axion
Major General
Posts: 683
Joined: Mon Sep 29, 2003 5:14 am
Location: Northern California
Contact:

Post by Axion »

You would need to cache the sounds in your script.

Code: Select all

aliascache door_metal_open_move2 sound/mechanics/DoorMetalOpen_05.wav soundparms 1.2 0.2 0.8 0.2 160 1600 item loaded maps "dm obj
door_metal_open_move2 = the alias name. When you select the sounds you want for your door, you can give them your own alias names when you cache them in your script.

Once you cache all the sounds in your script, you would select your door in radiant and enter these key/values:

sound_move - The alias to the sound you've selected for when the door opens and closes

sound_locked - The alias to the sound that plays when the door is locked

You should also write your own custom ubersound.scr for your map and cache the sounds in there as well to avoid sound issues.
"The work of a thousand years is nothing but rubble."
- Dr. Carl Goerdeler (1943)
Visit my mapping site: http://www.freewebs.com/axion9
Image
User avatar
mcunha98
Lieutenant Colonel
Posts: 384
Joined: Sat Jan 17, 2004 1:52 am
Location: Brasil
Contact:

Post by mcunha98 »

Axion,

Thanks !!!!
You detailed the process in minimum items !
I will try put this changes in my map and return the result in this topic.
Post Reply