Jump to content

[Another Idea] Spacebar does not pick-up traps. Resets them instead.


Ortorin

Recommended Posts

I was poking around the game files, but I was unable to come up with a solution.

 

I think it would be great to be able to reset the traps with left-click or space, and pick them up with right-click. This would make it much easier to clean-up after a fight. Really all you would have to do is hold space to both reset traps, and pickup the spoils of your fight.

 

I'll keep trying to figure this out, some help would be nice though. xD

Link to comment
Share on other sites

I -think- you might need to edit the value of GLOBAL.ACTIONS.RESETMINE.priority and possibly override both

 

inst.components.mine.CollectSceneActions

and

inst.components.inventory.CollectSceneActions

 

to reverse the right click logic

 

So this:

function Mine:CollectSceneActions(doer, actions, right)    if right and self.issprung then        table.insert(actions, ACTIONS.RESETMINE)    endend

to this?:

function Mine:CollectSceneActions(doer, actions, left)    if left and self.issprung then        table.insert(actions, ACTIONS.RESETMINE)    endend

???

 

I also found this:

function InventoryItem:CollectSceneActions(doer, actions)    if self.canbepickedup and doer.components.inventory then        table.insert(actions, ACTIONS.PICKUP)    endend

...

 

 

Here's the thing... If I switch the pickup to right click, then every item would follow suit. That line of code controls every pick-up-able item, not just the tooth traps.

Link to comment
Share on other sites

I changed the 

Mine:CollectSceneActions
 

to:

 

function Mine:CollectSceneActions(doer, actions)
    if self.issprung then
        table.insert(actions, ACTIONS.RESETMINE)
    end
end

 

Which makes the reset button the left-click... so I'm getting somewhere with this. xD

 

I know I'm going to run into the issue of how to declare that the tooth trap is picked-up with a different key than every other item in the game...

Link to comment
Share on other sites

I've been able to to make resetting the trap be preformed with the left click or spacebar, but I cannot tell the game that the tooth trap can only be picked-up with right click.

 

If someone has an idea on that, please share it.

Link to comment
Share on other sites

No dont change the class itself, only change what the toothtrap calls for it.   assign it in the prefabpostinit.

 

-edit-

 

I do the exact same thing in my rabbithole mod.  I'll paste the relevant code from my modmain.lua here

local function CheckRabbitHoleAction(self, doer, pos, actions, right)    if right and CheckRabbitHoleLocation(pos) then        table.insert(actions, ACTIONS.PLANTRABBITHOLE)    endendlocal function EmptyUseAction(self, doer, target, actions)endlocal function doTweak(inst)	inst:AddComponent("stackable")	inst.components.stackable.CollectUseActions = EmptyUseAction	inst:AddComponent("deployable")	inst.components.deployable.CollectPointActions = CheckRabbitHoleActionendAddPrefabPostInit("rabbit", doTweak)

If you look at the components copy of the CollectXXXActions functions you'll notice that they dont have 'self' as the first variable in the argument list.  Thats because when a function is called using a semi colon the self variable is implied and automatically available.  When you override the function with your own copy it doent get the same 'implied self' benifit so you need to add it.  After that my example code will have only rabbits stackable action be ignored and not have an effect on any other stackable.  In your case you dont want to edit the copy belonging to the 'mine' component you just want to override the mine components CollectXXXAction() for only tooth traps.

 

Oh the reason i use an empty function override for stackable is thats the 'combine stacks' behavior and i dont want to allow someone to add their stack of 3 rabbits to a still wild rabbit on the ground.  Its just weird

Link to comment
Share on other sites

No dont change the class itself, only change what the toothtrap calls for it.   assign it in the prefabpostinit.

 

-edit-

 

I do the exact same thing in my rabbithole mod.  I'll paste the relevant code from my modmain.lua here

local function CheckRabbitHoleAction(self, doer, pos, actions, right)    if right and CheckRabbitHoleLocation(pos) then        table.insert(actions, ACTIONS.PLANTRABBITHOLE)    endendlocal function EmptyUseAction(self, doer, target, actions)endlocal function doTweak(inst)	inst:AddComponent("stackable")	inst.components.stackable.CollectUseActions = EmptyUseAction	inst:AddComponent("deployable")	inst.components.deployable.CollectPointActions = CheckRabbitHoleActionendAddPrefabPostInit("rabbit", doTweak)

If you look at the components copy of the CollectXXXActions functions you'll notice that they dont have 'self' as the first variable in the argument list.  Thats because when a function is called using a semi colon the self variable is implied and automatically available.  When you override the function with your own copy it doent get the same 'implied self' benifit so you need to add it.  After that my example code will have only rabbits stackable action be ignored and not have an effect on any other stackable.  In your case you dont want to edit the copy belonging to the 'mine' component you just want to override the mine components CollectXXXAction() for only tooth traps.

 

Oh the reason i use an empty function override for stackable is thats the 'combine stacks' behavior and i dont want to allow someone to add their stack of 3 rabbits to a still wild rabbit on the ground.  Its just weird

 

I understand what you are trying to tell me to do, but I am unable to figure this out. Unfortunately, I have very little coding experience, and what I do know really only applies to the Morrowind Scripting Engine. /sigh

 

Thanks for your help, but this lesson is lost on me.

Link to comment
Share on other sites

Pickup behavoir seems to be controlled by the following (components/playercontroller.lua, I've detabbed it slightly for readability):

rad = self.directwalking and 3 or 6--pickuplocal pickup = FindEntity(self.inst, rad, function(guy) return (guy.components.inventoryitem and guy.components.inventoryitem.canbepickedup) or	(tool and tool.components.tool and guy.components.workable and tool.components.tool:CanDoAction(guy.components.workable.action)) or	(guy.components.pickable and guy.components.pickable:CanBePicked() and guy.components.pickable.caninteractwith) or	(guy.components.stewer and guy.components.stewer.done) or	(guy.components.crop and guy.components.crop:IsReadyForHarvest()) or	(guy.components.harvestable and guy.components.harvestable:CanBeHarvested()) or	(guy.components.trap and guy.components.trap.issprung) or	(guy.components.dryer and guy.components.dryer:IsDone()) or	(guy.components.activatable and guy.components.activatable.inactive)	 end)

Appending and not guy.components.mine after and guy.components.inventoryitem.canbepickedup can alter it so instances with mine component won't be targeted for auto-pickup (manual pick-up proceeds as usual).
 
While this is more like a quick'n'dirty hack than mod, default action seems so irritable that it can warrant this.
 
Auto-reset, in my opinion, will make tooth-trapping way too easy.

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