mrboosch Posted April 26, 2017 Share Posted April 26, 2017 (edited) Hey all, I am attempting to overwrite the default ACTIONS.PICKUP action in my mod safely. When I try to do this, the action fires twice every time it fires (so all things can still pick things up, but at the same time they get "I cant do that" and the print in my fn below fires twice). My Code (in modmain.lua, tak is my mod's character): local function _overrideActionPickupFn(inst) if ACTIONS and ACTIONS.PICKUP and ACTIONS.PICKUP.fn ~= newPICKUPfn then local _actionPickupFn = ACTIONS.PICKUP.fn local function newPICKUPfn(act) _actionPickupFn(act) print("[TAKDEBUG] NewActionWorking!") end ACTIONS.PICKUP.fn = newPICKUPfn end end AddPrefabPostInit("tak", _overrideActionPickupFn) Any thoughts here? I am sure it's something silly, but I cant figure it out! Edited April 30, 2017 by mrboosch Link to comment Share on other sites More sharing options...
Serpens Posted April 26, 2017 Share Posted April 26, 2017 (edited) I'm not that experienced with modding actions yet, but if I did not overlooked bugs, it also should work like this (code is in my questmod api in modmain (so without addprefabpostinit)): local _LOOKATfn = GLOBAL.ACTIONS.LOOKAT.fn GLOBAL.ACTIONS.LOOKAT.fn = function(act) local targ = act.target or act.invobject if targ~= nil then targ:PushEvent("questmod:examined",{player=act.doer}) if targ:HasTag("questgiver") and targ.components and targ.components.talker and targ:GetDistanceSqToInst(act.doer) <= math.pow(10,2) then -- if directly next to a questgiver, not the player should say sth, but the questgiver return -- no examination talking else return _LOOKATfn(act) end end return _LOOKATfn(act) end Edited April 26, 2017 by Serpens Link to comment Share on other sites More sharing options...
mrboosch Posted April 26, 2017 Author Share Posted April 26, 2017 (edited) @Serpens Thank you very much for your reply! Going the route you proposed* does give me the 'only call it once' behavior I was looking for! Now evidently I just need to find out what the heck is wrong with my execution logic - haha! Many thanks for your insight. Regards, Mr Boosch * for others: by this I meant removing the prefabpostinit call and executing all logic as part of modmain Edited April 26, 2017 by mrboosch Link to comment Share on other sites More sharing options...
mrboosch Posted April 29, 2017 Author Share Posted April 29, 2017 Bump @admins would appreciate this flagged as solved. Link to comment Share on other sites More sharing options...
Lumina Posted April 30, 2017 Share Posted April 30, 2017 Just edit your first post and put solved in title ? Link to comment Share on other sites More sharing options...
Serpens Posted April 30, 2017 Share Posted April 30, 2017 the edit button should be right from the "Quote" button at the bottom of your post. All [Solved] flags you find in the forum are added by the thread starter. There is no admin who does this ^^ Link to comment Share on other sites More sharing options...
mrboosch Posted April 30, 2017 Author Share Posted April 30, 2017 OK so, @Serpens @Lumina thank you both for assisting a newer modder Interesting side point - Firefox browser does not appear to recognize that a user can edit old posts - the edit button only appears next to a post immediately after it has been posted, then upon logging out and back in, will no longer show. Go figure?! Shows up fine in Chrome, so I've edited the topic. Many thanks! Link to comment Share on other sites More sharing options...
Serpens Posted April 30, 2017 Share Posted April 30, 2017 11 minutes ago, mrboosch said: OK so, @Serpens @Lumina thank you both for assisting a newer modder Interesting side point - Firefox browser does not appear to recognize that a user can edit old posts - the edit button only appears next to a post immediately after it has been posted, then upon logging out and back in, will no longer show. Go figure?! Shows up fine in Chrome, so I've edited the topic. Many thanks! interesting... you could try to report this in bug section, but not sure if it is the right place... I also use firefox, but I never log out I think I'm logged in since months 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