Jump to content

Attaching character specific action to existing item


Recommended Posts

Basically I want an action similar in function to how the razor works when mousing over something shaveable. I need to do this on an item that exists in the game itself, not an item of my own creation. This action should only trigger on the one character.

What I have:

  1. Action
  2. AddComponentAction

  3. AddStategraphActionHandler

These work mostly and I can see the action in-game if I take the character specific checks off. Testing with the razor I can mouse over something like a tree in this case and my action appears. However, I can't get it to work when mousing over my own character since the "Examine" action always seems to take priority.

I want this action to take priority over things like Examine and Give so I can use it on myself and friendly players. This action will eventually be attached to a sewing kit once I get it working correctly.

Link to comment
Share on other sites

Examine action has default priority -3. Most other actions have higher priorities, so this isn't the reason (also it would have affected the tree as well). More likely the component action checks don't evaluate the player as a valid target.

When I was experimenting with priorities of scene component actions I added this debug prints into components/playeractionpicker.lua (it outputs all found actions; note: it spams the log *very* much):

--- components/playeractionpicker.lua
+++ components/playeractionpicker.debug.lua
@@ -291,6 +291,14 @@ function PlayerActionPicker:DoGetMouseActions(position, target)
 
     local leftActions = self:GetLeftClickActions(position, target)
     local rightActions = self:GetRightClickActions(position, target)
+if type(leftActions) == "table" and #leftActions > 0 then
+  print(string.format("[PlayerActionPicker:DoGetMouseActions] position=%s, target=%s, self=%s, self.inst=%s, leftActions=%s", tostring(position), tostring(target), tostring(self), tostring(self.inst), tostring(leftActions)))
+  dumptable(leftActions)
+end
+if type(rightActions) == "table" and #rightActions > 0 then
+  print(string.format("[PlayerActionPicker:DoGetMouseActions] position=%s, target=%s, self=%s, self.inst=%s, rightActions=%s", tostring(position), tostring(target), tostring(self), tostring(self.inst), tostring(rightActions)))
+  dumptable(rightActions)
+end
     local lmb = leftActions and leftActions[1]
     local rmb = rightActions and rightActions[1]
 

 

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