Tykvesh Posted October 3, 2016 Share Posted October 3, 2016 I want to buff Monster Lasagna for Webber (more satiety and little heal for eating it if player is a monster) How to do this? Link to comment Share on other sites More sharing options...
Serpens Posted October 3, 2016 Share Posted October 3, 2016 (edited) 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 October 4, 2016 by Serpens Link to comment Share on other sites More sharing options...
Tykvesh Posted October 4, 2016 Author Share Posted October 4, 2016 (edited) Thanks for trying to help, but... Nope, it crashes the game.. Edited October 4, 2016 by Tykvesh Link to comment Share on other sites More sharing options...
Serpens Posted October 4, 2016 Share Posted October 4, 2016 (edited) 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 October 4, 2016 by Serpens Link to comment Share on other sites More sharing options...
Tykvesh Posted October 4, 2016 Author Share Posted October 4, 2016 [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> Link to comment Share on other sites More sharing options...
Serpens Posted October 4, 2016 Share Posted October 4, 2016 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> ah thank you yes "inst" is the lasagna, of course it has no health replace "inst" with "eater" in the three "DoDelta" lines. Link to comment Share on other sites More sharing options...
Tykvesh Posted October 4, 2016 Author Share Posted October 4, 2016 Thanks a lot! Now it works perfectly! <3 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