Modding Help [SOLVED] Custom Status Effect LUA

Discussion in 'Starbound Modding' started by Omeruin, Dec 18, 2019.

  1. Omeruin

    Omeruin Void-Bound Voyager

    I'm trying to change it so that instead of having the status effect go away when in water, it will stop if you drink a certain food item OR have a certain status effect already going. (It is similar to fire/burning, but different.) How can one do this with LUA? I've read tutorials, looked at the Wiki, etc.. But it's really hard for me understand what I'm really supposed to be doing.
    Code:
    require "/scripts/util.lua"
    require "/scripts/vec2.lua"
    require "/scripts/interp.lua"
    require "/items/active/weapons/weapon.lua"
    
    function init()
      animator.setParticleEmitterOffsetRegion("flames", mcontroller.boundBox())
      animator.setParticleEmitterActive("flames", true)
      effect.setParentDirectives("fade=0CBAFF=0.25")
      animator.playSound("burn", -1)
     
      script.setUpdateDelta(5)
    
      self.tickDamagePercentage = 0.010
      self.tickTime = 1.0
      self.tickTimer = self.tickTime
    end
    
    function update(dt)
      if effect.duration() and world.liquidAt({mcontroller.xPosition(), mcontroller.yPosition() - 1}) then
        effect.expire()
      end
    
      self.tickTimer = self.tickTimer - dt
      if self.tickTimer <= 0 then
        self.tickTimer = self.tickTime
        status.applySelfDamageRequest({
            damageType = "IgnoresDef",
            damage = math.floor(status.resourceMax("health") * self.tickDamagePercentage) + 1,
            damageSourceKind = "holyfire",
            sourceEntityId = entity.id()
          })
      end
    end
    
    function uninit()
     
    end
    
    What I want to change is:
    function update(dt)
    if effect.duration() and world.liquidAt({mcontroller.xPosition(), mcontroller.yPosition() - 1}) then
    effect.expire()
    end

    Is there some way I can use effect.sourceEntity() or something?

    Any help would be AWESOME, PLEASE!
    Thanks!!
     
  2. Lunar Eye Gaming

    Lunar Eye Gaming Phantasmal Quasar

    This can be done with the following code in the scripts of the status effects that you want to remove your status effect, presumably "holyfire":
    Code:
    status.removeEphemeralEffect("statusEffect")
    You have to put this in the script of the status effects that will remove your status effect.
    Please note that if you want to do this for vanilla status effects, you will need to do dirty edits or choose an alternative solution that is much more complicated to do entirely on your own.
     
    Omeruin likes this.
  3. Omeruin

    Omeruin Void-Bound Voyager

    Woahhh, I never thought of actually editing the other status effect to be able to remove this one.
    The two are both custom status effects, so it's fine for me! Thank you so much!!
     

Share This Page