Linking sound to a switch
#1
Posted 29 June 2011 - 08:27 PM
im making my own vault with a security room and i want to have a switch in that room the flips on an alarm and some Klaxon
lights ive placed around the vault
what im trying to do is link the klaxon alarm sound so that when i activate the switch to turn the klaxon light on the siren
comes on as well. so far i cant seem to link the two correctly. because of this i also cant link the vault emergency light to it
either. so in short when i flip a switch the alarm light will spin but the sound with either be playing before i even have touched the switch or wont play at all and the light will not turn on and off with the switch as well. any help would be really great.
#2
Posted 30 June 2011 - 06:08 AM
you'd just needi haven't found anything on here about this or anything at all on the web.
im making my own vault with a security room and i want to have a switch in that room the flips on an alarm and some Klaxon
lights ive placed around the vault
what im trying to do is link the klaxon alarm sound so that when i activate the switch to turn the klaxon light on the siren
comes on as well. so far i cant seem to link the two correctly. because of this i also cant link the vault emergency light to it
either. so in short when i flip a switch the alarm light will spin but the sound with either be playing before i even have touched the switch or wont play at all and the light will not turn on and off with the switch as well. any help would be really great.
begin OnActivate
PlaySound soundname
end
to make it play whenever you activate the switch.or, if the sound is an ogg-file, this would be
PlaySound3D soundname(in some cases, i couldn't get this to play either though, maybe someone else knows about that)
or, if you have a switch with an on/off-animation, and just want it to play when you turn it on
begin OnActivate
if GetOpenState == 3 ; if switch is off
PlaySound soundname ; play sound
setopenstate 1 ; set switch to on (GetOpenState returns different values than SetOpenState uses)
elseif GetOpenState == 1 ; if switch is on
setopenstate 0 ; set switch to off
endif
end
and turning the light on/off would mostly mean having two copies of the same light in the same place, one on and one off, and always enabling the one you need and disabling the other one, there's various ways to do that, for example either with making one of the lights the switches linked ref and the other lights enabling parent (opposite), you'd then switch that on by
ref LightMaster
begin OnActivate
set LightMaster to GetLinkedRef ; sets your light-variable to the linked reference
Lightmaster.enable 0 ; and enables it (and light 2, if enable child/opposite disappears at same time)
end
or by making both of the lights persistant, giving them a name like lightOnREF and adding like
lightOnREF.enable 0 ; makes on-light appear
lightOffREF.disable 0 ; and off-light disappear - the 0 makes it pop in/out instead of fade
(and the other way around for turning off) to the above script (right where the setopenstate's are)
Edited by stevie70, 30 June 2011 - 06:15 AM.
#3
Posted 02 July 2011 - 01:23 AM
#4
Posted 03 July 2011 - 03:03 AM
#5
Posted 04 July 2011 - 10:31 PM
if you used the one that checks for the switches open state plus a switch that actually has and on/off animation state (check in preview window), i don't really see how this could be happening - could you please post the whole script you used 2 have a look at it...?ok i tried the script for the sound with an on off switch but my problem now is that after hitting the switch to turn the sound on if i hit it again to turn it off it just plays the sound again.
#6
Posted 06 July 2011 - 05:32 AM
begin OnActivate
if GetOpenState == 3
PlaySound QSTKlaxonA
SetOpenState 1
elseif GetOpenState == 1
SetOpenState 0
endif
end
im using the ElectricSwitch02
#7
Posted 06 July 2011 - 11:14 AM
hm, i don't see anything wrong with that - is the switch animation going where it should when you switch?Scn KlaxonAlarm
begin OnActivate
if GetOpenState == 3
PlaySound QSTKlaxonA
SetOpenState 1
elseif GetOpenState == 1
SetOpenState 0
endif
end
im using the ElectricSwitch02
and if so, and are you sure the sound plays AGAIN when you switch it off and not just KEEPS playing...? maybe the sound you picked just continues looping, if so, just make a non-looping copy and play that
#8
Posted 06 July 2011 - 02:47 PM
#9
Posted 12 July 2011 - 11:17 PM
sorry 4 late response, work... :-Pthe sound was playing over again when i switch it off and then back on, the sound would play again over-top of the sound but i did what you said and created a file where the sound doesn't loop and now the sound wont play at all when i flip the switch.
if you haven't solved that anyway meanwhile - have you tested the whole thing with a different sound (one that's definitely a one shot...?
#10
Posted 19 July 2011 - 03:20 AM



Sign In
Create Account
Back to top








