Jump to content

Whats triggering the trap?


Recommended Posts

So I have a custom character with a custom chester and its suppose to not trigger traps when walked over.

 

Well apparently someone reported that he does trigger the trap and cause the game to crash. Problem is I thought the tag inst:AddTag("notraptrigger") fixed that.

 

So whats going on?

The part of the code causing the problem

local old_RUMMAGE = GLOBAL.ACTIONS.RUMMAGE.fn GLOBAL.ACTIONS.RUMMAGE.fn = function(act)    if act.target.prefab == "personal_dogoo" then         print("GLOBAL.ACTIONS.RUMMAGE--"..tostring(act.doer.components.inventory))        result = act.doer.components.inventory:FindItem(function(item)            if item.prefab == "personal_dogoo_eyebone" then                print("GLOBAL.ACTIONS.RUMMAGE--"..tostring(item).."--ok--")                return true            end        end)        if result then             return old_RUMMAGE(act)        else            print("GLOBAL.ACTIONS.RUMMAGE--"..tostring(item).."--fail--")             act.doer:DoTaskInTime(1, function ()                act.doer.components.talker:Say("No Can Do!")            end)            return false        end    else        return old_RUMMAGE(act)    endend

The

[string "../mods/workshop-472803272/modmain.lua"]:364: attempt to index field 'target' (a nil value)

Is the crash error and the line

  if act.target.prefab == "personal_dogoo" then 

is the culprit.

 

The supposed traps that are conflicintg is rezecib's Landmines mod and TheSun's Spike Trap mod. Could be other traps in the game itself also.

Edited by rons0n
Link to comment
Share on other sites

@rons0n
Did you actually test it? I just ran a couple tests with the base game traps (toothtrap and beemine), rezecib's landmines and sun's spike traps. The little blue guy didn't trigger any of those.

Your crash isn't related to traps at all, but rather by someone/something trying to access a Dogoo's inventory. When it comes to ACTIONS it's always a good idea to check if the target or the doer aren't nil before doing something with them.
 
.. So! To fix your crash, just a simple

if act.target and act.target.prefab == "personal_dogoo" then 

will do.

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...