DeadlyHooves Posted December 30, 2013 Share Posted December 30, 2013 (edited) So I need to know how to check if hunger has changed and if it has have an action happen, Im attempting to get it so It check current hunger and if its under a certain number (lets use 100 in this case) then an action happens. Well I triedif (inst.components.hunger.current < 100) thenaction(inst)elseendand Im getting the error: inst is not a declared variable. But I dont know how else Id call current hunger? I made a post on it but no help has come yet. Edited December 31, 2013 by DeadlyHooves Link to comment https://forums.kleientertainment.com/forums/topic/30645-how-to-call-hunger/ Share on other sites More sharing options...
DeadlyHooves Posted December 31, 2013 Author Share Posted December 31, 2013 bumping cause of important edit. Link to comment https://forums.kleientertainment.com/forums/topic/30645-how-to-call-hunger/#findComment-396533 Share on other sites More sharing options...
evillair Posted January 3, 2014 Share Posted January 3, 2014 You can try this... make a local function like this in your yourcharactername.lualocal function hungercheck(inst) local Hungercurr = inst.components.hunger.current if Hungercurr <= 100 then dosomething else dosomethingelse endendThen underneath it, call it in your local fn = function(inst) sectionlocal fn = function(inst) -- todo: Add an example special power here. inst:ListenForEvent("hungerdelta", hungercheck)endThis works if you want to change stats.There might be a better way but that's the only way I found to change stats when his hunger/insanity/health changes.There's hungerdelta, insanitydelta and healthdelta if you want to check other stuff. Hope that helps! Link to comment https://forums.kleientertainment.com/forums/topic/30645-how-to-call-hunger/#findComment-397881 Share on other sites More sharing options...
DeadlyHooves Posted January 5, 2014 Author Share Posted January 5, 2014 You can try this... make a local function like this in your yourcharactername.lualocal function hungercheck(inst) local Hungercurr = inst.components.hunger.current if Hungercurr <= 100 then dosomething else dosomethingelse endendThen underneath it, call it in your local fn = function(inst) sectionlocal fn = function(inst) -- todo: Add an example special power here. inst:ListenForEvent("hungerdelta", hungercheck)endThis works if you want to change stats.There might be a better way but that's the only way I found to change stats when his hunger/insanity/health changes.There's hungerdelta, insanitydelta and healthdelta if you want to check other stuff. Hope that helps!Wow! Thanks! That'll get me going again! Thank you so much! Link to comment https://forums.kleientertainment.com/forums/topic/30645-how-to-call-hunger/#findComment-399101 Share on other sites More sharing options...
evillair Posted January 5, 2014 Share Posted January 5, 2014 No problem!I had the same problem, took me awhile to figure it out. Link to comment https://forums.kleientertainment.com/forums/topic/30645-how-to-call-hunger/#findComment-399116 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