Jump to content

I don't understand why this doesn't work


Cyde042

Recommended Posts

PrefabFiles ={"bat",} function BatPrefabPostInit(inst)     inst:AddComponent("workable")    inst.components.workable:SetWorkAction(ACTIONS.NET)    inst.components.workable:SetWorkLeft(1)    --inst.components.workable:SetOnFinishCallback(OnWorked)    endAddPrefabPostInit("bat", BatPrefabPostInit)

  I included only the problem of the mod. For some reason, adding workable to a bat causes all the hud to disappear and some actions to not work (escape key for ex.) whenever I spawn one (or if one comes in my FOV I assume). Am I missing something obvious? cause I feel like I am.

Link to comment
Share on other sites

Check your crash log.txt after this occurs. 

 

 Well, It had to be GLOBAL.ACTIONS.NET, now it works. Thanks, I'll be checking the log from now on.

 

Edit: I hit another dead end.

PrefabFiles = { "bat", "batpet",}function BatPrefabPostInit(inst)     local function OnWorked(inst, worker)        if worker.components.inventory then                    if METRICS_ENABLED then		    FightStat_Caught(inst)	    end        inst.SoundEmitter:KillAllSounds()        worker.components.inventory:GiveItem("batpet", nil, GLOBAL.Vector3(TheSim:GetScreenPos(inst.Transform:GetWorldPosition())))        end    end	inst:AddComponent("workable")	inst.components.workable:SetWorkAction(GLOBAL.ACTIONS.NET)	inst.components.workable:SetWorkLeft(1)	inst.components.workable:SetOnFinishCallback(OnWorked)	endAddPrefabPostInit("bat", BatPrefabPostInit)

Crash log

...on/dont_starve/data/scripts/components/inventory.lua:531: attempt to index field 'components' (a nil value)LUA ERROR stack traceback:        D:/Steam/steamapps/common/dont_starve/data/scripts/components/inventory.lua(531,1) in function 'GiveItem'        D:/Steam/steamapps/common/dont_starve/data/../mods/Batilisk in a Box/modmain.lua(20,1) in function 'onfinish'        D:/Steam/steamapps/common/dont_starve/data/scripts/components/workable.lua(96,1) in function 'WorkedBy'        D:/Steam/steamapps/common/dont_starve/data/scripts/actions.lua(419,1) in function 'fn'        D:/Steam/steamapps/common/dont_starve/data/scripts/bufferedaction.lua(19,1) in function 'Do'        D:/Steam/steamapps/common/dont_starve/data/scripts/entityscript.lua(942,1) in function 'PerformBufferedAction'        D:/Steam/steamapps/common/dont_starve/data/scripts/stategraphs/SGwilson.lua(1215,1) in function 'fn'        D:/Steam/steamapps/common/dont_starve/data/scripts/stategraph.lua(476,1) in function 'UpdateState'        D:/Steam/steamapps/common/dont_starve/data/scripts/stategraph.lua(515,1) in function 'Update'        D:/Steam/steamapps/common/dont_starve/data/scripts/stategraph.lua(111,1) in function 'Update'        D:/Steam/steamapps/common/dont_starve/data/scripts/update.lua(127,1)scripts/frontend.lua(723,1) SCRIPT ERROR! Showing error screen	Force aborting...

 I followed the line in inventory.lua, seems that it doesn't accept the player's inventory as a valid location from what I understand.

Link to comment
Share on other sites

Does your patbet prefab have the inventoryitem component? Looks like something is going wrong when you're passing the patbet reference to the function. 

 

 It does have inventoryitem component, and for now, petbat prefab isn't the issue cause I tried switching it with guano, and still got the crash.

 

Using GLOBAL get pos didn't help. Same crash. I included the mod as it is now right now if you need a more detailed look.

Batilisk in a Box.zip

Link to comment
Share on other sites

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.

×
  • Create New...