Haru Posted December 27, 2014 Share Posted December 27, 2014 help me, I want to script to my character eating foodtype VEGGIE. But I don't want to eat "petals", please! tell me how to do?EX.if food and food.components.edible and food.components.edible.foodtype=="VEGGIE" then Link to comment https://forums.kleientertainment.com/forums/topic/47696-need-help-for-script-not-eat-petals/ Share on other sites More sharing options...
przemolsz Posted December 27, 2014 Share Posted December 27, 2014 and not food.prefab == "petals"This should work. Link to comment https://forums.kleientertainment.com/forums/topic/47696-need-help-for-script-not-eat-petals/#findComment-593490 Share on other sites More sharing options...
Haru Posted December 27, 2014 Author Share Posted December 27, 2014 and not food.prefab == "petals"This should work. thank you , but is not all work.EXif food and food.components.edible and food.components.edible.foodtype=="VEGGIE" and not food.prefab == "petals" then --give an upgrade! inst.level = inst.level + 1eat petals is not level up.but i eat "carrot" is not level up too.i need eat all veggie type level up except petals.help please. Link to comment https://forums.kleientertainment.com/forums/topic/47696-need-help-for-script-not-eat-petals/#findComment-593498 Share on other sites More sharing options...
Ryuushu Posted December 28, 2014 Share Posted December 28, 2014 (edited) @Haru Check your listener. remember that you receive data (an array) instead the inst. To access the actual food you use data.food. This is working for me:AddPlayerPostInit( function (inst) inst:ListenForEvent("oneat", function (inst, data) print("I'm eating!") print("Eating something?", data.food ~= nil) print("I'm eating a: ", data.food and data.food.name) print("Edible?", data.food and data.food.components.edible ~= nil) print("Eating veggie?", data.food and data.food.components.edible and data.food.components.edible.foodtype == "VEGGIE" or false) print("Not petals?", data.food and data.food.prefab ~= "petals" or false) if data.food and data.food.components.edible and data.food.components.edible.foodtype == "VEGGIE" and data.food.prefab ~= "petals" then print("Level up!") end end)end)It prints "Level up!" when I eat a carrot, and doesn't prints it when I eat some petals. Edit: My bad x.x didn't realize you were changing the oneatfn.Still, it's mostly the same.inst.components.eater.oneatfn = function (inst, food) print("I'm eating!") print("Eating something?", food ~= nil) print("I'm eating a: ", food and food.name) print("Edible?", food and food.components.edible ~= nil) print("Eating veggie?", food and food.components.edible and food.components.edible.foodtype == "VEGGIE" or false) print("Not petals?", food and food.prefab ~= "petals" or false) if food and food.components.edible and food.components.edible.foodtype == "VEGGIE" and food.prefab ~= "petals" then print("Level up!") end end Edited December 29, 2014 by Ryuushu Link to comment https://forums.kleientertainment.com/forums/topic/47696-need-help-for-script-not-eat-petals/#findComment-593634 Share on other sites More sharing options...
Jazariz Posted December 31, 2014 Share Posted December 31, 2014 i know this is your thread i dont know how to contact ppl on this forum i wanted to ask if you can possably help me with making a character mod. i really like your work and it kinda made me wanna make one. if you can help it would be well appreciated Link to comment https://forums.kleientertainment.com/forums/topic/47696-need-help-for-script-not-eat-petals/#findComment-594875 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