Jump to content

Recommended Posts

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 tried

if (inst.components.hunger.current < 100) thenaction(inst)elseend

and 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 by DeadlyHooves
Link to comment
https://forums.kleientertainment.com/forums/topic/30645-how-to-call-hunger/
Share on other sites

You can try this...

 

make a local function like this in your yourcharactername.lua

local function hungercheck(inst) local Hungercurr = inst.components.hunger.current        if Hungercurr <= 100 then             dosomething        else             dosomethingelse        endend

Then underneath it, call it in your local fn = function(inst) section

local fn = function(inst)       -- todo: Add an example special power here.        inst:ListenForEvent("hungerdelta", hungercheck)end

This 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!

You can try this...

 

make a local function like this in your yourcharactername.lua

local function hungercheck(inst) local Hungercurr = inst.components.hunger.current        if Hungercurr <= 100 then             dosomething        else             dosomethingelse        endend

Then underneath it, call it in your local fn = function(inst) section

local fn = function(inst)       -- todo: Add an example special power here.        inst:ListenForEvent("hungerdelta", hungercheck)end

This 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!

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...