Modding Help Is there a way to get a status to play a sound?

Discussion in 'Starbound Modding' started by The Observer, Oct 11, 2014.

  1. The Observer

    The Observer Phantasmal Quasar

    What it says on the tin. Is there anything I can put into the .lua, statuseffect or animator files to get it to play a sound when inflicted?
     
  2. The | Suit

    The | Suit Agent S. Forum Moderator

  3. The Observer

    The Observer Phantasmal Quasar

    Hmm, doesn't seem to be working. Can anyone suggest me as to what's wrong? I'm pretty new to LUA.

    Here's my code, with the change in line 4:

    Code:
    function init()
      animator.setParticleEmitterOffsetRegion("drips", mcontroller.boundBox())
      animator.setParticleEmitterActive("drips", true)
      mcontroller.playImmediateSound("sfx/objects/redalert.wav")
      effect.setParentDirectives("fade=00BBFF=0.4")
      script.setUpdateDelta(1)
      self.tickTime = 1.0
      self.tickTimer = self.tickTime
    
    end
    
    function update(dt)
    
      mcontroller.controlModifiers({
          movementSuppressed = true
        })
    
      self.tickTimer = self.tickTimer - dt
      if self.tickTimer <= 0 then
        self.tickTimer = self.tickTime
        world.spawnProjectile("kinepticforceexplosion", mcontroller.position(), 0, {0, 0}, false, { timeToLive = 0 } )
      end
    
    end
    
    function uninit()
    
    end
    From docs.starbound.com:

    Anyone know what I'm doing wrong?
     
  4. The | Suit

    The | Suit Agent S. Forum Moderator

  5. The Observer

    The Observer Phantasmal Quasar

  6. The | Suit

    The | Suit Agent S. Forum Moderator

    I would guess you would need to fill in those values, not just call the functions. After all you are giving it a value, not requesting one.
    Vec2F tells where the sound originates from + direction
    AudioParamaters tells how loud the sound is and how far that sound travels.

    Though it should replace it default values if none are given.
    There is also a chance the function it self might not be fully working.
     
    Last edited: Oct 11, 2014
  7. The Observer

    The Observer Phantasmal Quasar

    Thanks.

    Tried mcontroller.playImmediateSound("sfx/objects/redalert.wav", Vec2F(x0, y0), AudioParameters())

    and got

    Error: Exception while invoking lua function 'init'. (LuaException) [string "/stats/effects/kinepticforceexplosion/kinepti..."]:5: attempt to call global 'Vec2F' (a nil value)

    Hmm, I don't think something's working. Oh well.
     
  8. The | Suit

    The | Suit Agent S. Forum Moderator

    mcontroller.playImmediateSound("sfx/objects/redalert.wav", Vec2F(0, 0), AudioParameters())

    I don't believe you need to declare x and y. After all - you are inputting floating numbers. Letters are not part of those.
    Anywho its odd @severedskullz hasn't popped in yet.

    I would give metadept a dm on twitter and ask about how to use it, and if its working.
     
  9. Riuny

    Riuny Big Damn Hero

    If you're using particle effects in your status effect, you might not need to struggle with LUA. Or, maybe, I think you can use entity.playImmediateSound or entity.playSound.
     
  10. The Observer

    The Observer Phantasmal Quasar

    Nevermind, I twitted Metadept like what was suggested, let's hope I get a reply.

    Thanks all.
     
  11. Well that's bloody strange. I did not get an alert when this topic was created, nor when @xxswatelitexx ping'd me. Vect2F is the C++ variant for just a table with 2 numbers for the X and Y coordinates... so: { 0, 0 }


    Im new to the whole movement controller right now, but it seems to work the same for the entity version.
    Code:
    mcontroller.playImmediateSound("sfx/objects/redalert.wav", {0, 0}) -- Will play at position (0,0) relative to the entity 
    If it works the same way as the entity varient, its relative to itself... if NOT then it will be absolute coordinates and you will have to use the entity's location in there instead.
     

Share This Page