AkaiNight Posted November 19, 2021 Share Posted November 19, 2021 I am trying to make a companion who is a crafting station and im trying to make her upgradeable with an item and i think the easiest way to do it is adding eater component but the problem is she is not eating anythign not just the custom item i made( i tried it with my character its eatable food) but not even normal foods. I don't know what im missing(i checked critters and woby files for it). I think problem is about interactions beacue even im near her the items should be able to craftable with certain tech is not craftable too (but i can craft them with c_freecrafting() code so i think item is fine and problem is about companion). So any help would be great. I am leaving companion's code let me know if there is anything else u need and it would be helpful if u know any tutorial or similar code like it. local assets = { Asset("ANIM", "anim/liira.zip"), --Asset("SOUND", "sound/liira.fsb"), } local prefabs = { "fairybait", "globalmapiconunderfog", } local brain = require("brains/liirabrain") local function OnStartFollowing(inst) inst:AddTag("companion") end local function FairyLevel(inst) local max_fairyexp = 10 local min_fairyexp = 0 local max_fairylevel = 4 local min_fairylevel = 0 local fairyexp = math.min (inst.fairyexp, max_fairyexp, min_fairyexp) if inst.fairylevel == 1 then inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.FAIRY_TECH_ONE end if inst.fairylevel == 2 then inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.FAIRY_TECH_TWO end if inst.fairylevel == 3 then inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.FAIRY_TECH_THREE end if inst.fairylevel == 4 then inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.FAIRY_TECH_FOUR end if inst.fairyexp == 10 then inst.fairylevel = inst.fairylevel + 1 inst.fairyexp = 0 end end local function OnEat(inst, food) if food and food.components.edible and food.prefab == "fairy_cream" then inst.fairyexp = inst.fairyexp + 1 FairyLevel(inst) end end local function onpreload(inst, data) if data.fairyexp and data.fairylevel then inst.fairyexp = data.fairyexp inst.fairylevel = data.fairylevel fairylevel(inst) end end local function onsave(inst,data) data.fairyexp = inst.fairyexp data.fairylevel = inst.fairylevel end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddDynamicShadow() inst.entity:AddNetwork() inst.entity:AddLightWatcher() inst.DynamicShadow:SetSize(2, .75) --same as glommer change if its needed inst.Transform:SetFourFaced() --inst.Transform:SetScale(0.7, 0.7, 1) MakeGhostPhysics(inst, 1, 5) -- i don't know what the heck is this but same with glommer inst.AnimState:SetBank("liira") inst.AnimState:SetBuild("liira") inst.AnimState:PlayAnimation("idle_loop") inst:AddTag("liira") inst:AddTag("flying") inst:AddTag("ignorewalkableplatformdrowning") inst:AddTag("cattoyairborne") --probably this is for cats to play with it inst:AddTag("notraptrigger") inst:AddTag("noauradamage") inst:AddTag("prototyper") inst:AddTag("NOBLOCK") inst.fairylevel = 1 inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("follower") inst:ListenForEvent("startfollowing", OnStartFollowing) inst:AddComponent("eater") inst.components.eater:SetDiet({FOODTYPE.MEAT}, {FOODTYPE.MEAT}) inst:AddComponent("knownlocations") inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 8 inst.components.locomotor.pathcaps = {allowocean = true} inst:SetStateGraph("SGliira") inst:SetBrain(brain) inst:ListenForEvent("levelfairy", FairyLevel) inst.components.eater:SetOnEatFn(OnEat) inst.OnLoad = onpreload inst.OnNewSpawn = onpreload inst.OnSave = onsave inst.OnPreLoad = onpreload return inst end return Prefab("liira", fn, assets, prefabs) liira.lua Link to comment https://forums.kleientertainment.com/forums/topic/135411-making-a-pet-like-companion-eater/ Share on other sites More sharing options...
penguin0616 Posted November 22, 2021 Share Posted November 22, 2021 It seems you have her diet set to meat. Were you trying to feed her meat? Link to comment https://forums.kleientertainment.com/forums/topic/135411-making-a-pet-like-companion-eater/#findComment-1516045 Share on other sites More sharing options...
AkaiNight Posted November 22, 2021 Author Share Posted November 22, 2021 2 hours ago, penguin0616 said: It seems you have her diet set to meat. Were you trying to feed her meat? yes i did not working Link to comment https://forums.kleientertainment.com/forums/topic/135411-making-a-pet-like-companion-eater/#findComment-1516068 Share on other sites More sharing options...
penguin0616 Posted November 22, 2021 Share Posted November 22, 2021 @AkaiNight Try using a FOODGROUP instead of a FOODTYPE. That seems to be what is usually done. Link to comment https://forums.kleientertainment.com/forums/topic/135411-making-a-pet-like-companion-eater/#findComment-1516087 Share on other sites More sharing options...
AkaiNight Posted November 23, 2021 Author Share Posted November 23, 2021 nope still not work :/ Link to comment https://forums.kleientertainment.com/forums/topic/135411-making-a-pet-like-companion-eater/#findComment-1516100 Share on other sites More sharing options...
penguin0616 Posted November 23, 2021 Share Posted November 23, 2021 2 hours ago, AkaiNight said: nope still not work :/ I would suggest starting with a basic eater that can eat standard character food and work your way to what you want. If even the basic eater fails, I am inclined to believe you have other key issues at hand. Link to comment https://forums.kleientertainment.com/forums/topic/135411-making-a-pet-like-companion-eater/#findComment-1516124 Share on other sites More sharing options...
AkaiNight Posted November 23, 2021 Author Share Posted November 23, 2021 (edited) 3 hours ago, penguin0616 said: I would suggest starting with a basic eater that can eat standard character food and work your way to what you want. If even the basic eater fails, I am inclined to believe you have other key issues at hand. The problem is i don't know how to make a basic eater its not a character and I think its not about eating because as i mentioned it should be a crafter on its own but this feature doesn't work. Its first time im making a companion and i don't know coding (just tying to understand while making and im trying to find similar modes i want and i try to edit them) Edited November 23, 2021 by AkaiNight Link to comment https://forums.kleientertainment.com/forums/topic/135411-making-a-pet-like-companion-eater/#findComment-1516161 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