Jump to content

Recommended Posts

Hello again, one year later.

My goal is to tie a character's glow in with their hunger. I've been fumbling around with a string that looked somewhat like this-

inst.Light:Enable(true)
inst.Light:SetRadius(Hunger:GetPercent / 37.5)

I couldnt quite get that to work so I scrapped it, and this is what I currently have after a bit of tearing from other mods-
 

Quote

 

function Light:SetRadius (inst)
    inst.slimeRate = self.inst.components.hunger:GetHunger()
    
    return (inst.slimeRate > 119 and 4) or
        (inst.slimeRate > 89 and 3) or
        (inst.slimeRate > 59 and 2) or
        (inst.slimeRate > 29 and 1) or
        0
    
end

 

No idea how much of this is right or wrong, code is pain :T

I'd prefer to set it up as a constantly waning light source, like I tried with the initial lil snip

 

Edited by Kaira
Link to comment
https://forums.kleientertainment.com/forums/topic/72528-solved-glowing-character/
Share on other sites

didn't played almost an year, but one of solutions is to listen onhungerchange event and change light radius here.

in your code i don't get any point of returning value.

it should look like:
 

function MyHungerListener(data) -- don't remember what parameters here

local hunger = -1

if data and data.recordname and typeof(data.recordname)=='integer' -- need proper 'recordname'

hunger = data.recordname

end

if hunger > 0

self.inst.Light(...here goes your radius formula with 'hunger'...)

self.inst.Light.enable(true)

end

end

this is NOT proper code, just idea how it probably should look

Edited by R1ncewind

~a few days later~

Quote

local function SlimeLight(inst, data) --can this be named whatever? dif between function and localfunction?
    local percent = inst.components.hunger:GetPercent() --does this make 'percent' the value? 0-1
    
    if percent > 0 then --is this..
        self.inst.Light:Enable(true)
        self.inst.Light:SetRadius(percent * 4) --..and this acceptable uses of 'percent'?
    else
        self.inst.Light:Enable(false)
    end
end

I messed around with some of your advice and this. On the bright side, my game doesn't crash right from startup. the functions aren't even applying to my character though.

finished~ topic's ova ( ° ͜ʖ °)

Quote

inst:ListenForEvent("hungerdelta", function(inst) local percent = inst.components.hunger:GetPercent() if percent > 0 then inst.Light:Enable(true) inst.Light:SetRadius(percent * 4) else inst.Light:Enable(false) end end)

Also, i'm insane now. Please bring cooked greencaps or I will burn the forums down. (   ° ͜ʖ °  )

Edited by Kaira

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...