Snowhusky5 Posted February 5, 2016 Share Posted February 5, 2016 (edited) Hi. I'm trying to make a mod that changes the behavior of tooth traps. So far, I've been able to do what I wanted, all that is left (pun intended) is to allow tooth traps to be reset with left mouse and spacebar instead of right mouse. How exactly do I change that? Will I have to add an action replacing RESETMINE, or a component action replacing it? How exactly would I go about doing that? Edited February 7, 2016 by Snowhusky5 Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/ Share on other sites More sharing options...
zUsername Posted February 6, 2016 Share Posted February 6, 2016 (edited) local function abc(inst, doer, actions, right) if inst.prefab == "trap_teeth" and inst:HasTag("minesprung") then table.insert(actions, ACTIONS.RESETMINE) end end AddComponentAction("SCENE", "mine", abc) Edited February 6, 2016 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/#findComment-718389 Share on other sites More sharing options...
Mobbstar Posted February 6, 2016 Share Posted February 6, 2016 As zUsername suggested, you should look into changing the existing check-function that decides whether the action is adequate or not. Alternatively, you can probably make a new one for left-click. Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/#findComment-718398 Share on other sites More sharing options...
Snowhusky5 Posted February 6, 2016 Author Share Posted February 6, 2016 9 hours ago, zUsername said: local function abc(inst, doer, actions, right) if inst.prefab == "trap_teeth" and inst:HasTag("minesprung") then table.insert(actions, ACTIONS.RESETMINE) end end AddComponentAction("SCENE", "mine", abc) This worked in making the action become left click instead of right click, but for some reason spacebar does not do anything. I've tried fixing it, but I can't figure it out. I've tried reassigning the action's priority (to 1), canforce (true), and rangecheckfn (to PICK's rangecheckfn), but it hasn't worked. Is there some other part of spacebar actions that I should be aware of? Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/#findComment-718557 Share on other sites More sharing options...
zUsername Posted February 6, 2016 Share Posted February 6, 2016 (edited) 1 hour ago, Snowhusky5 said: This worked in making the action become left click instead of right click, but for some reason spacebar does not do anything. I've tried fixing it, but I can't figure it out. I've tried reassigning the action's priority (to 1), canforce (true), and rangecheckfn (to PICK's rangecheckfn), but it hasn't worked. Is there some other part of spacebar actions that I should be aware of? Try this. local oldactionpickup = GLOBAL.ACTIONS.PICKUP.fn GLOBAL.ACTIONS.PICKUP.fn = function(act) if act.target ~= nil and act.target.components.mine ~= nil and act.target:HasTag("minesprung") then act.target.components.mine:Reset() return true end return oldactionpickup(act) end Edited February 6, 2016 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/#findComment-718588 Share on other sites More sharing options...
Muche Posted February 6, 2016 Share Posted February 6, 2016 2 hours ago, Snowhusky5 said: This worked in making the action become left click instead of right click, but for some reason spacebar does not do anything. I've tried fixing it, but I can't figure it out. I've tried reassigning the action's priority (to 1), canforce (true), and rangecheckfn (to PICK's rangecheckfn), but it hasn't worked. Is there some other part of spacebar actions that I should be aware of? As far as I know, the spacebar action is controlled by PlayerController:GetActionButtonAction in components/playercontroller.lua. Setting its field actionbuttonoverride seems like a good way to alter its behavior. Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/#findComment-718610 Share on other sites More sharing options...
Snowhusky5 Posted February 6, 2016 Author Share Posted February 6, 2016 (edited) Ok, thanks for your help @zUsername and @Muche. Because I have no idea how to go about setting actionbuttonoverride, I just hijacked the PICK action, which works 99% like how I want it to (it says 'pick tooth trap' instead of 'reset tooth trap' when moused over). Will add the mod link here once I'm done making an image and uploading it to steam. EDIT: http://steamcommunity.com/sharedfiles/filedetails/?id=617944113 Edited February 7, 2016 by Snowhusky5 Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/#findComment-718723 Share on other sites More sharing options...
zUsername Posted February 7, 2016 Share Posted February 7, 2016 (edited) local function abc(inst, doer, actions, right) if inst.prefab == "trap_teeth" and inst:HasTag("minesprung") then if right then if not inst:HasTag("rightclick") then inst:AddTag("rightclick") end table.insert(actions, ACTIONS.PICKUP) -- right mouse will pick up teeth trap else if inst:HasTag("rightclick") then inst:RemoveTag("rightclick") end table.insert(actions, ACTIONS.RESETMINE) -- left mouse will reset teeth trap end end end AddComponentAction("SCENE", "mine", abc) local oldactionpickup = GLOBAL.ACTIONS.PICKUP.fn GLOBAL.ACTIONS.PICKUP.fn = function(act) if act.target ~= nil and act.target.prefab == "trap_teeth" and act.target.components.mine ~= nil and act.target:HasTag("minesprung") and not act.target:HasTag("rightclick") then act.target.components.mine:Reset() return true end return oldactionpickup(act) end Add this code in your modmain . Edited February 7, 2016 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/63831-how-to-change-action-from-right-to-left-click-solved-more-or-less/#findComment-718869 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