ChubbyBacon Posted April 3, 2025 Share Posted April 3, 2025 I began making a component action, and in modmain, i can print the action, which logs a table number. However, the action does not actually get added to GLOBAL.ACTIONS, and trying to print this results in nil. I suspect the line with AddAction does not work, but I cannot understand why it doesn't. The action's string does not show up hovering over the ground in game. Link to comment https://forums.kleientertainment.com/forums/topic/165207-problem-with-component-actions/ Share on other sites More sharing options...
Merkyrrie Posted April 6, 2025 Share Posted April 6, 2025 Could you post the snippet of code in question to get a better understanding of the problem? Otherwise, it could simply be that one of the conditionals in the if statement prior to adding the action to the table in AddComponentAction isn't ever true, or similarly to the if statement in AddAction. Link to comment https://forums.kleientertainment.com/forums/topic/165207-problem-with-component-actions/#findComment-1811060 Share on other sites More sharing options...
ChubbyBacon Posted April 7, 2025 Author Share Posted April 7, 2025 Spoiler local ActionHandler = GLOBAL.ActionHandler local ACTIONS = GLOBAL.ACTIONS local Action = GLOBAL.Action local MYACTION = Action({priority = 4 , distance = 99}) MYACTION.str="action" MYACTION.id = "MYACTION" MYACTION.fn=function(act) print("hi") return true end AddAction(MYACTION) print(MYACTION) --returns table number print(ACTIONS.MYACTION) --returns nil AddComponentAction("POINT", "MYACTION_component", function(inst, doer, pos, actions, right) if right then table.insert(actions, ACTIONS.MYACTION) end end) Sorry for the late response. This is some of the code in modmain. Link to comment https://forums.kleientertainment.com/forums/topic/165207-problem-with-component-actions/#findComment-1811238 Share on other sites More sharing options...
Merkyrrie Posted April 8, 2025 Share Posted April 8, 2025 1 hour ago, ChubbyBacon said: Reveal hidden contents local ActionHandler = GLOBAL.ActionHandler local ACTIONS = GLOBAL.ACTIONS local Action = GLOBAL.Action local MYACTION = Action({priority = 4 , distance = 99}) MYACTION.str="action" MYACTION.id = "MYACTION" MYACTION.fn=function(act) print("hi") return true end AddAction(MYACTION) print(MYACTION) --returns table number print(ACTIONS.MYACTION) --returns nil AddComponentAction("POINT", "MYACTION_component", function(inst, doer, pos, actions, right) if right then table.insert(actions, ACTIONS.MYACTION) end end) Sorry for the late response. This is some of the code in modmain. Your problem probably actually has to do with it being a 'POINT' action specifically. I'm not extremely well versed in how point actions work so I could stand corrected, but POINT actions tend to need something equipped or on the cursor with the component in order to function properly. For instance, if I take your exact code here and then add the component to an equippable, like say the spear, the action does work as expected. Its kind of noticeable that this is the case because the best example I can think of that would be a point action not tied to an item is Wortox's soulhop, which has its own workaround using the "pointspecialactionsfn" from the playeractionpicker component. Depending on how you want your action to work, you can maybe look into using that. Link to comment https://forums.kleientertainment.com/forums/topic/165207-problem-with-component-actions/#findComment-1811244 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