rons0n Posted July 4, 2015 Share Posted July 4, 2015 (edited) 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 problemlocal 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) endendThe[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 July 4, 2015 by rons0n Link to comment Share on other sites More sharing options...
Ryuushu Posted July 4, 2015 Share Posted July 4, 2015 @rons0nDid 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 simpleif act.target and act.target.prefab == "personal_dogoo" then will do. Link to comment Share on other sites More sharing options...
rons0n Posted July 4, 2015 Author Share Posted July 4, 2015 @Ryuushu, It's good to see you around on the forums again! Anyway, thanks for your assistance! I'll keep your advice in mind! 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