summerscorcher Posted February 1, 2021 Share Posted February 1, 2021 Hello all, I'm trying to add a custom action to my mod. I've ran into a bunch of errors, but I've finally managed to have the game boot up and not crash. The problem is however, it doesn't actually bring up the prompt to perform said action; only the default ones such as Examine, Attack and Walk To. local MYACTION = GLOBAL.Action({}, 3) MYACTION.id = "MYACTION" MYACTION.str = "Perform Action" MYACTION.fn = function(act) print("Action performed!") end AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(MYACTION, "dolongaction")) AddAction(MYACTION) This is my current code. I've seen other posts bring up stuff like AddComponentAction, but I don't think that exists in DS (undeclared error). Besides, it's not mentioned anywhere in modutils or actions.lua. Does anyone know why the action isn't coming up in game? I'm really not sure what else to try. Thank you in advance. Link to comment https://forums.kleientertainment.com/forums/topic/126620-custom-action-not-appearing/ Share on other sites More sharing options...
summerscorcher Posted February 6, 2021 Author Share Posted February 6, 2021 (edited) Update: Fixed it a day or so after posting. I added a component to my custom item which the action was on- turns out there's a method to check whether or not you're hovering over an entity, and then you can insert the action there. Here's an example: local customcomponent = Class(function(self, inst) self.inst = inst end) function customcomponent:CollectEquippedActions(doer, target, actions, right) table.insert(actions, ACTIONS.MYACTION) end end return customcomponent If anyone's interested, I believe this came from playeractionpicker.lua; there's a couple more like it that handle if you're hovering over an item, for instance. Edited February 6, 2021 by Lillyth Link to comment https://forums.kleientertainment.com/forums/topic/126620-custom-action-not-appearing/#findComment-1426172 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