Kaira Posted December 15, 2016 Share Posted December 15, 2016 (edited) 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 December 20, 2016 by Kaira Link to comment https://forums.kleientertainment.com/forums/topic/72528-solved-glowing-character/ Share on other sites More sharing options...
R1ncewind Posted December 17, 2016 Share Posted December 17, 2016 (edited) 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 December 17, 2016 by R1ncewind Link to comment https://forums.kleientertainment.com/forums/topic/72528-solved-glowing-character/#findComment-849771 Share on other sites More sharing options...
Kaira Posted December 19, 2016 Author Share Posted December 19, 2016 ~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. Link to comment https://forums.kleientertainment.com/forums/topic/72528-solved-glowing-character/#findComment-850579 Share on other sites More sharing options...
R1ncewind Posted December 19, 2016 Share Posted December 19, 2016 you have to add listener for event and this function, look similar code (with health change events) maybe i unpack my sources in some time and give you exact code Link to comment https://forums.kleientertainment.com/forums/topic/72528-solved-glowing-character/#findComment-850592 Share on other sites More sharing options...
Kaira Posted December 20, 2016 Author Share Posted December 20, 2016 (edited) 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 December 20, 2016 by Kaira Link to comment https://forums.kleientertainment.com/forums/topic/72528-solved-glowing-character/#findComment-850892 Share on other sites More sharing options...
R1ncewind Posted January 9, 2017 Share Posted January 9, 2017 you are actually don't use event's data, but it's not a problem. Getpercent() is working fast anyway. Link to comment https://forums.kleientertainment.com/forums/topic/72528-solved-glowing-character/#findComment-856808 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now