Product Chat / Is there a way???

Author
Message
Rector
4
Years of Service
User Offline
Joined: 11th May 2019
Location: Manchester
Posted: 24th Mar 2022 12:25
Is there a way to control a sound with a switch and if so how?

So for instance, if an alarm is sounding, how do I stop the alarm using a switch?
Processor i9-9900k CPU@ 3.60GHZ
Ram 32GB
Windows 10 64bit
GeForce RTX 2060
PM
bluemeenie195
5
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 24th Mar 2022 16:09
Yes, you can do that with Lua in Classic and visual scripting or lua in Max.
PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 26th Mar 2022 05:40 Edited at: 26th Mar 2022 05:53
Yes this is totally possible using an if activated check. This allows you to do most of the work within the editor itself by adding the name of the entity to target under "IfUsed" in the properties.

We already have the switch Lua there for you in stock.

The alarm script however you would have to make yourself... it would look something like this:

local alarm_on = {}
function alarm_init(e)
alarm_on[e] = 0
LoopSound(e,0)
end

function alarm_main(e)
if g_Entity[e]['activated'] == 1 then
if alarm_on[e] == 0 then
LoopSound(e,0)
alarm_on[e] = 1
elseif alarm_on[e] == 1 then
StopSound(e,0)
alarm_on[e] = 0
end
SetActivated(e,0)
end
end

Not sure if that works, but that's basically the jist of it.
Store Assets - Store Link
Free Assets - Resource Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960

Login to post a reply

Server time is: 2024-05-04 11:21:43
Your offset time is: 2024-05-04 11:21:43