Atena Posted March 13, 2015 Share Posted March 13, 2015 I make a new food item, the food could change character property(like temperature), but I don't want the monster(spider, hound...) or pigman eat it, because the monster seems not this components(temperaturem talk...), How could I do? My code:local function oneaten(inst, eater) -- Must determine eater is not a character -- How to do?? if eater not character then -- I need the code. return end -- Do something for character end Link to comment https://forums.kleientertainment.com/forums/topic/51991-helphow-could-i-determine-the-eater/ Share on other sites More sharing options...
DrSmugleaf Posted March 13, 2015 Share Posted March 13, 2015 In your character's prefablocal function oneat(inst, food) if food and food.components.edible and food.prefab == "yourfoodprefab" then inst.components.health:DoDelta(numberToChangeHealthBy) inst.components.hunger:DoDelta(numberToChangeHungerBy) end endAs to how to do something like temperature I have no idea. My only guess would be looking at something you know changes temperature by using it. In your character's prefab master_postinitinst.components.eater:SetOnEatFn(oneat) Link to comment https://forums.kleientertainment.com/forums/topic/51991-helphow-could-i-determine-the-eater/#findComment-621295 Share on other sites More sharing options...
DarkXero Posted March 13, 2015 Share Posted March 13, 2015 Alternatively,if not eater:HasTag("player") thenfor the check and,local temp = eater.components.temperature:GetCurrent() + 5local maxtemp = eater.components.temperature.maxtempif temp < maxtemp then eater.components.temperature:SetTemp(temp)else eater.components.temperature:SetTemp(maxtemp)endfor the temperature. Link to comment https://forums.kleientertainment.com/forums/topic/51991-helphow-could-i-determine-the-eater/#findComment-621299 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