Lynnden Posted June 9, 2015 Author Share Posted June 9, 2015 @Blueberrys, @Lynnden Event listener. so where do i put this? in the fn function or wrap that around sanityCheck?right never mind that i figured that out. I wrapped it around the call for sanity check in fn, compiled it and it ran. the mod was enabled, i booted up a level, and upon using "c_setsanity(.20)" promptly gave me this messageReset() returningQueryServerComplete no callback..._starve/data/../mods/Ellen/scripts/prefabs/ellen.lua:40: attempt to index local 'data' (a nil value)..._starve/data/../mods/Ellen/scripts/prefabs/ellen.lua:40: attempt to index local 'data' (a nil value)LUA ERROR stack traceback: C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/Ellen/scripts/prefabs/ellen.lua(40,1) in function 'sanityCheck' C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/Ellen/scripts/prefabs/ellen.lua(62,1) in function 'fn' C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/entityscript.lua(690,1) in function 'PushEvent' C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/components/sanity.lua(142,1) in function 'DoDelta' C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/components/sanity.lua(261,1) in function 'Recalc' C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/components/sanity.lua(187,1) in function 'OnUpdate' C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/update.lua(104,1)scripts/frontend.lua(723,1) SCRIPT ERROR! Showing error screen Force aborting...so now i'm in the same issue when i scratch my head when it yells at me for using "inst." in the wrong place. Link to comment Share on other sites More sharing options...
Blueberrys Posted June 9, 2015 Share Posted June 9, 2015 @Lynnden-- SanityCheck function somewhere-- In fn function inst:ListenForEvent("sanitydelta", SanityCheck) Link to comment Share on other sites More sharing options...
Lynnden Posted June 9, 2015 Author Share Posted June 9, 2015 @Blueberrys,alright so everything works, it executes. i can run the game without crashing, now the problem is nothing dies, i've spawned a hound did c_setsanity(.2) it prints here's johnny" but doesn't kill anything. here's the code.function sanityCheck(inst, data) if data.newpercent <= .2 then print(inst) local i = 1 print("spooks skeletons") local CurrentSanity = inst.components.sanity:GetPercent() if CurrentSanity <= .20 then print("well you're insane") inst.components.sanity:DoDelta(30) local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, 25) for k, v in pairs(ents) do print("here's johnny") inst.components.health:Kill() end end endend Link to comment Share on other sites More sharing options...
Blueberrys Posted June 9, 2015 Share Posted June 9, 2015 @Lynndenfor k, v in pairs(ents) do -- inst.components.health:Kill() -- Attempting to kill "inst"? if v.components.health then v.components.health:Kill() -- Kill the entity in the loop endend Link to comment Share on other sites More sharing options...
Lynnden Posted June 9, 2015 Author Share Posted June 9, 2015 @Blueberrys, well, it works, it kills everything. Including me. not what i had in mind. Link to comment Share on other sites More sharing options...
Mobbstar Posted June 9, 2015 Share Posted June 9, 2015 @Blueberrys, well, it works, it kills everything. Including me. not what i had in mind. add a test: if v.components.health and v ~= inst then "~=" means "is not" Link to comment Share on other sites More sharing options...
Lynnden Posted June 9, 2015 Author Share Posted June 9, 2015 thank you both so much. everything works out perfectly. Expect a (fairly compotent) mod coming soon. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.