Jump to content

Yummy Monster Lasagna for Webber


Recommended Posts

I think this code in modmain should do it:
 

AddPrefabPostInit("monsterlasagna",function(inst)
    if not GLOBAL.TheNet:GetIsServer() then 
        return
    end
    inst.components.edible:SetOnEatenFn(function(inst,eater)
        if eater and eater:HasTag("player") and eater:HasTag("monster") then
            inst.components.health:DoDelta(10)
            inst.components.sanity:DoDelta(10)
            inst.components.hunger:DoDelta(10)
        end
    end)
end)

 

Edited by Serpens
Link to comment
Share on other sites

8 hours ago, Tykvesh said:

Thanks for trying to help, but...

Nope, it crashes the game..

..then tell me what the error is or upload the logfile...
And most of the time it are just typos you can fix yourself ;)
E.g I just saw, that I wrote "component" instead of "components". I fixed it now.
Try again and if it still crashes, post the error.

Edited by Serpens
Link to comment
Share on other sites

[00:01:42]: [string "../mods/workshop-xxxxxxxxx/modmain.lua"]:61: attempt to index field 'health' (a nil value)
LUA ERROR stack traceback:
    ../mods/workshop-xxxxxxxxx/modmain.lua:61 in (field) oneaten (Lua) <59-65>
    scripts/components/edible.lua:126 in (method) OnEaten (Lua) <124-135>
    scripts/components/eater.lua:180 in () ? (Lua) <121-195>
    =(tail call):-1 in ()  (tail) <-1--1>
    scripts/bufferedaction.lua:24 in (method) Do (Lua) <20-34>
    scripts/entityscript.lua:1243 in (method) PerformBufferedAction (Lua) <1235-1253>
    scripts/stategraphs/SGwilson.lua:2279 in (field) fn (Lua) <2275-2281>
    scripts/stategraph.lua:568 in (method) UpdateState (Lua) <536-580>
    scripts/stategraph.lua:607 in (method) Update (Lua) <599-627>
    scripts/stategraph.lua:125 in (method) Update (Lua) <109-148>
    scripts/update.lua:209 in () ? (Lua) <150-223>

monsterlasagna_test.png

Link to comment
Share on other sites

22 minutes ago, Tykvesh said:

[00:01:42]: [string "../mods/workshop-xxxxxxxxx/modmain.lua"]:61: attempt to index field 'health' (a nil value)
LUA ERROR stack traceback:
    ../mods/workshop-xxxxxxxxx/modmain.lua:61 in (field) oneaten (Lua) <59-65>
    scripts/components/edible.lua:126 in (method) OnEaten (Lua) <124-135>
    scripts/components/eater.lua:180 in () ? (Lua) <121-195>
    =(tail call):-1 in ()  (tail) <-1--1>
    scripts/bufferedaction.lua:24 in (method) Do (Lua) <20-34>
    scripts/entityscript.lua:1243 in (method) PerformBufferedAction (Lua) <1235-1253>
    scripts/stategraphs/SGwilson.lua:2279 in (field) fn (Lua) <2275-2281>
    scripts/stategraph.lua:568 in (method) UpdateState (Lua) <536-580>
    scripts/stategraph.lua:607 in (method) Update (Lua) <599-627>
    scripts/stategraph.lua:125 in (method) Update (Lua) <109-148>
    scripts/update.lua:209 in () ? (Lua) <150-223>

monsterlasagna_test.png

ah thank you :)
yes "inst" is the lasagna, of course it has no health :D 
replace "inst" with "eater" in the three "DoDelta" lines.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...