Post new topic    
Liquid Metal Slime
Send private message
Sound Effect Continuously Repeating 
 PostTue Jan 05, 2010 4:10 am
Send private message Reply with quote
Hey guys,

I have part of a script that uses a sound effect and it seems to repeat itself over and over again (or until another sound effect is playing). Not sure what
to do here. I'm using the latest official release of the engine for everything.
Code:
      if (pposx == npc x(1) ,and, pposy==npc y(1)) then (
                play sound (3,false,false)
         alter NPC (1,NPCstat:move type,npcmovetype:standstill)

                alter npc (1,NPCstat:picture,3)
                death := true
           )

Cornbread Chemist
Liquid Metal King Slime
Send private message
 
 PostTue Jan 05, 2010 4:07 pm
Send private message Reply with quote
Your usage of "play sound" seems to be correct, so I am guessing that the whole "if" statement is being rapidly re-evaluated over and over again in a loop.

Maybe something like this would work?

Code:

if (pposx == npc x(1) ,and, pposy==npc y(1)) then (
   if(already played == false) then(
      play sound (3)
      already played := true
      alter NPC (1,NPCstat:move type,npcmovetype:standstill)
      alter npc (1,NPCstat:picture,3)
      death := true
   )
)else(
  already played := false
)
Liquid Metal Slime
Send private message
 
 PostTue Jan 05, 2010 6:17 pm
Send private message Reply with quote
Thanks for the tip. I did something like this and it worked:

Code:
      if (pposx == npc x(1) ,and, pposy==npc y(1)) then (
         if (alreadyplayed == false) then (
                   play sound (3,false,false)
                   alreadyplayed := true
                )
         alter NPC (1,NPCstat:move type,npcmovetype:standstill)
                alter npc (1,NPCstat:picture,3)
                death := true
              )

Cornbread Chemist
Display posts from previous: