Tic-toc

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Grizzlyadamz
Posts: 2
Joined: Fri Nov 30, 2012 8:39 am

Tic-toc

Post by Grizzlyadamz »

How would one set up a soundeffect that plays continuously, tic-tocing away into perpetuity?

At the moment I'm banging two timers together, trying to alternately activate scripts that look something like
function playderp()
playSound("click_down")
activate timer_1
end
If I continue attempting to activate a timer through a script, (which in turn is being activated via pressure plate), might I eventually bring honor to my family? Or is this pursuit ultimately inefficient, or worse, ineffective?
Thank you for your time, ( ;) )
User avatar
Phitt
Posts: 442
Joined: Tue Aug 14, 2012 9:43 am

Re: Tic-toc

Post by Phitt »

You don't need to activate the timer again and again. Once activated it will run until you deactivate it. Don't think it would cause any performance issues to do this, but if you really want the sound to play forever (without ever stopping throughout the whole play time) a looping sound may be better.
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Tic-toc

Post by antti »

As far as performance goes, your approach is completely fine but just as an exercise, here's an alternative solution that might be a little simpler since it's just a single function and a single timer that is always on (note: untested code):

Code: Select all

tic = true
function ticking()
  if tic then
    playSound("click_down")
  else
    playSound("click_up")
  end
  tic = not tic        -- this flips the boolean from true to false and vice versa so that a different sound is played next time the function is called
end
edit: on a second look, I'm actually not sure if I understood the question so I don't know if this was what you wanted to accomplish... :?
Steven Seagal of gaming industry
Grizzlyadamz
Posts: 2
Joined: Fri Nov 30, 2012 8:39 am

Re: Tic-toc

Post by Grizzlyadamz »

I wanted to alternate between the two sounds, and my total experience with audio files to date is zero. However, SUCCESS!

The one-shot pressure plate activates Script 1, the starter
T-DAY:
Script 1
-plays a toc, or clickdown.
-activates timer 1, a 2s interval bugger linked to Script 2, TOC, which begins it's job in 2 seconds.
-activates timer 2, a 1s interval gizmo that is linked to script 3, ignition
T-DAY+1
Script 3
-plays a tic, or clickup.
-activates timer 3, a 2s interval whatchamacallit linked to script 4, TIC, which begins it's job in 2 seconds.
-deactivates timer 2, who the hell needs it anyway. Timer 2 dies a slow, excruciating death in the darkness.
T-DAY+2
TOC, Script 2, comes online like the hand of death, beginning it's relentless di-second countdown to infinity.
T-DAY+3
TIC, script 4, clinches the noose, partitioning the raw power of TOC into slightly-less-insurmountable 1-second pieces. Your fate has been sealed.

here's a copy of the incredibly esoteric guts:
SpoilerShow
Script1
function starter()
playSound("click_up")
timer_1:activate()
timer_2:activate()
end

--timer_1 activates
Script2
function playtoc()
playSound("click_up")
end

--timer_2 activates timer_3 and
Script3
function ignition()
playSound("click_down")
timer_2:deactivate()
end

--Timer 3 activates
function playtic()
playSound("click_down")
end
-edit
Yeah, I think you understood good sir, many thanks. The booleans eh? I SHOULD HAVE KNOWN.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Tic-toc

Post by Komag »

antti wrote:As far as performance goes, your approach is completely fine but just as an exercise, here's an alternative solution that might be a little simpler since it's just a single function and a single timer that is always on (note: untested code):

Code: Select all

tic = true
function ticking()
  if tic then
    playSound("click_down")
  else
    playSound("click_up")
  end
  tic = not tic        -- this flips the boolean from true to false and vice versa so that a different sound is played next time the function is called
end
Ooo, I like knowing about "not" to flip a boolean like that, very useful and easier than setting up various "if then"s
Finished Dungeons - complete mods to play
Post Reply