Eremus007 Posted February 2, 2016 Share Posted February 2, 2016 Hello again, I am still breaking my head over how I make my custom prefab inflict nightvision for a specific amount of time when eaten. I was trying to copy the catpotion from the witcher mod, but I can't make it work. This is what I had in mind but doesn't work: local assets = { Asset("ANIM", "anim/dwarventonic.zip"), Asset("ATLAS", "images/inventoryimages/dwarventonic.xml") } local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() MakeInventoryPhysics(inst) inst.AnimState:SetBank("recycledpickaxe") inst.AnimState:SetBuild("dwarventonic") inst.AnimState:PlayAnimation("idle") inst.entity:AddNetwork() inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/dwarventonic.xml" inst:AddComponent("edible") inst.components.edible.oneaten = function(inst, eater) if eater.prefab == "skyminer" then eater.components.hunger:DoDelta(3) eater.components.sanity:DoDelta(-10) end if eater.components.inventory ~= nil then local item = SpawnPrefab("woodenmug") eater.components.inventory:GiveItem(item) inst:Remove() end end MakeHauntableLaunchAndIgnite(inst) return inst end return Prefab("common/inventory/dwarventonic", fn, assets) Can someone please point me in the right direction? Many thanks in advantage. -Eremus Link to comment https://forums.kleientertainment.com/forums/topic/63678-please-help-breaking-my-head-on-how-to-code-this/ Share on other sites More sharing options...
zUsername Posted February 2, 2016 Share Posted February 2, 2016 (edited) Try the code posted by @DarkXero he using inst:DoTaskInTime. Edited February 2, 2016 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/63678-please-help-breaking-my-head-on-how-to-code-this/#findComment-716671 Share on other sites More sharing options...
Eremus007 Posted February 2, 2016 Author Share Posted February 2, 2016 49 minutes ago, zUsername said: Try the code posted by @DarkXero he using inst:DoTaskInTime. I will have a long look at it thanks! Link to comment https://forums.kleientertainment.com/forums/topic/63678-please-help-breaking-my-head-on-how-to-code-this/#findComment-716683 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