Modding Help Detecting Player Difficulty With LUA?

Discussion in 'Starbound Modding' started by EclipticWulf, Aug 15, 2017.

  1. EclipticWulf

    EclipticWulf Scruffy Nerf-Herder

    I am making a mod that adds an effect that lowers the food bar of the player whenever they get it. It's working just fine, but the issue comes in when a player is in casual mode - as it does not even have a hunger bar. Is there any possible way to detect if the player is not in casual mode, then lowering the food bar if they aren't?

    (The error received is "[Error] Exception while invoking lua function 'update'. (LuaException) Error code 2, [string "/stats/effects/famine/famine.lua"]:9: (StatusException) No such resource 'food' in StatSet")

    Here's the status effects LUA without any way of detecting the mode, I tried "if player.playermode ~= "casual" then" (as well as self.difficulty and player.playerdifficulty all while trying to grasp at straws) but that doesn't work - I feel I am just not calling the right key ("player.playermode")
    Code:
    function init()
        script.setUpdateDelta(5)
    
        self.starvingRate = 0.1 / config.getParameter("starveTime", 15)
    end
    
    function update()
            status.modifyResourcePercentage("food", self.starvingRate - 0.01)
    end
    
    function uninit()
    end
    
    
     
    Last edited: Aug 15, 2017

Share This Page