RedMattis Posted January 6, 2015 Share Posted January 6, 2015 I'm trying to add extracted blood as a foodtype and get a blood drinking-character to have exclusive access to it similar to WX-78 with his gears. The food items work and are created with the "BLOOD" tag, but I'm still struggling to figure out how to get the character to eat it. I've tried the following (and a few others which simply crashed). (in the master_postinit of the character)inst.components.eater.foodprefs = {FOODTYPE.BLOOD} Link to comment Share on other sites More sharing options...
Kzisor Posted January 6, 2015 Share Posted January 6, 2015 @RedMattis, post the code from one of the items and the code for your character. It's much easier for people to help when they have something to work with rather than blindly throwing ideas out at you. Link to comment Share on other sites More sharing options...
RedMattis Posted January 6, 2015 Author Share Posted January 6, 2015 @RedMattis, post the code from one of the items and the code for your character. It's much easier for people to help when they have something to work with rather than blindly throwing ideas out at you. local function master_postinit(inst) -- Ghost TEMP inst.experience = 0 -- default hunger level inst.strength = "normal" inst.components.hunger.current = 125 inst.components.hunger:SetMax(150) -- Emit light at night / Night vision -- WARNING doesn't work at day in caves! local light = inst.entity:AddLight() inst.Light:Enable(false) inst.Light:SetRadius(10) inst.Light:SetFalloff(0.75) inst.Light:SetIntensity(.6) inst.Light:SetColour(235/255,12/255,12/255) -- Stats varies day/night inst:ListenForEvent( "dusktime", function() updatestats(inst) end , GetWorld()) inst:ListenForEvent( "daytime", function() updatestats(inst) end , GetWorld()) inst:ListenForEvent( "nighttime", function() updatestats(inst) end , GetWorld()) updatestats(inst) -- Sanity Changes inst.components.sanity.night_drain_mult = 0.5 inst.components.sanity.neg_aura_mult = 1.1 inst.components.sanity:SetMax(TUNING.WILLOW_SANITY) --Update hunger status inst:ListenForEvent("hungerdelta", onhungerchange) --temp test inst:ListenForEvent("hungerdelta", onExperienceGain) --Carnivore, can only eat meat. Can Eat Monster Meat. inst.components.eater:SetCarnivore() inst.components.eater.strongstomach = true inst.components.eater.foodprefs = {FOODTYPE.MEAT, FOODTYPE.BLOOD} return inst endlocal function common(bank, build, anim, tag) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank(bank) inst.AnimState:SetBuild(build) inst.AnimState:PlayAnimation(anim) inst:AddTag("blood") if tag ~= nil then inst:AddTag(tag) end if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("edible") inst.components.edible.ismeat = true inst.components.edible.foodtype = FOODTYPE.BLOOD inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst:AddComponent("stackable") inst:AddComponent("perishable") inst.components.perishable:SetPerishTime(TUNING.PERISH_SLOW) inst.components.perishable:StartPerishing() inst.components.perishable.onperishreplacement = "spoiled_food" MakeHauntableLaunchAndPerish(inst) inst:ListenForEvent("spawnedfromhaunt", function(inst, data) Launch(inst, data.haunter, TUNING.LAUNCH_SPEED_SMALL) end) return instend-- small bloodbaglocal function smallblood() local inst = common("deerclops_eyeball", "smallblood", "idle") if not TheWorld.ismastersim then return inst end inst.components.edible.healthvalue = TUNING.HEALING_MEDSMALL inst.components.edible.hungervalue = TUNING.CALORIES_SMALL inst.components.edible.sanityvalue = TUNING.SANITY_TINY inst.components.inventoryitem.atlasname = "images/inventoryimages/smallblood.xml" inst.components.perishable:SetPerishTime(TUNING.PERISH_PRESERVED) inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM return instendreturn Prefab("common/inventory/smallblood", smallblood, assets)The lower codeblock is mostly copied from the meats LUA. Link to comment Share on other sites More sharing options...
Kzisor Posted January 6, 2015 Share Posted January 6, 2015 (edited) @RedMattis, based on the code by rezecib here http://forums.kleientertainment.com/topic/48308-how-do-i-make-my-character-able-to-eat-grass/?p=596545 you need a new tag added/ inst:AddTag("edible_"..GLOBAL.FOODTYPE.BLOOD) Edited January 6, 2015 by Kzisor Link to comment Share on other sites More sharing options...
RedMattis Posted January 7, 2015 Author Share Posted January 7, 2015 @RedMattis, based on the code by rezecib here http://forums.kleientertainment.com/topic/48308-how-do-i-make-my-character-able-to-eat-grass/?p=596545 you need a new tag added/ inst:AddTag("edible_"..GLOBAL.FOODTYPE.BLOOD) I got it working. Thanks. Link to comment 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