josra102 Posted December 8, 2024 Share Posted December 8, 2024 I need help with an action that works from the cursor location, in general, like Maxwell's spell, there is only one. This action should appear when the amulet is put on. And another question: how to make an area of action that appears from the cursor? Here's the code I usually use for actions: AddComponentAction("POINT", "ruby_of_illusions", function(inst, doer, pos, actions, right) table.insert(actions, ACTIONS.RUBY_ILLUSIONS) end) AddAction("RUBY_ILLUSIONS", "Nigntmare", function(act) if act.invobject then act.invobject.components.ruby_illusions:nigntmare(act.inst, act.doer, act.pos, act.actions, act.right) return true end return false end) AddStategraphActionHandler("wilson", ActionHandler(ACTIONS.RUBY_ILLUSIONS, "give")) AddStategraphActionHandler("wilson_client", ActionHandler(ACTIONS.RUBY_ILLUSIONS, "give")) Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/ Share on other sites More sharing options...
Mr.CrazyPotato Posted December 9, 2024 Share Posted December 9, 2024 (edited) you declare RUBY_ILLUSIONS in AddAction. but you're trying to use it in AddComponentAction. the problem is that you're using the action that you declare after using it. so just change order of AddComponentAction and AddAction. AddAction have to be first and AddComponentAction second. Edited December 9, 2024 by Mr.CrazyPotato Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1771971 Share on other sites More sharing options...
josra102 Posted December 10, 2024 Author Share Posted December 10, 2024 I swapped AddAction and AddComponentAction and it didn't help. The action didn't appear. Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1772655 Share on other sites More sharing options...
Mr.CrazyPotato Posted December 10, 2024 Share Posted December 10, 2024 6 hours ago, josra102 said: The action didn't appear. Well, I looked at the code more. I haven;t found any problems unless you misspelled "Nightmare" to "Nigntmare" in AddAction(). Main problem has to be the AddComponentAction(). for function arguments you wrote (inst, doer, pos, actions, right) which is WRONG. You should use for POINT actions target, this is the way. So you're code might as well look like this: AddAction("RUBY_ILLUSIONS", "Nightmare", function(act) -- Fixed misspell if act.invobject and act.invobject.components.ruby_illusions then -- Just checks that won't hurt, usually it's always added act.invobject.components.ruby_illusions:nightmare(act.inst, act.doer, act.pos, act.actions, act.right, act.target) -- Another fixed misspell and act.target, you need it for POINT action. return true end return false end) AddStategraphActionHandler("wilson", ActionHandler(ACTIONS.RUBY_ILLUSIONS, "give")) AddStategraphActionHandler("wilson_client", ActionHandler(ACTIONS.RUBY_ILLUSIONS, "give")) AddComponentAction("POINT", "ruby_of_illusions", function(inst, doer, pos, actions, right, target) -- Same thing table.insert(actions, ACTIONS.RUBY_ILLUSIONS) end) Make sure you're working with inventory objects but not scene prefabs, for them you'll need to use target instead of invobject. Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1772837 Share on other sites More sharing options...
josra102 Posted December 10, 2024 Author Share Posted December 10, 2024 This also didn't work, the action just doesn't appear to click. I seemed to have done as it was said but nothing. I even gave the ruby component to the character but nothing AddAction("RUBY_OF_ILLUSIONS", "Nightmare", function(act) if act.invobject and act.invobject.components.ruby_of_illusions then act.invobject.components.ruby_of_illusions:nigntmare(act.inst, act.doer, act.pos, act.actions, act.right, act.target) return true end return false end) AddStategraphActionHandler("wilson", ActionHandler(ACTIONS.RUBY_OF_ILLUSIONS, "give")) AddStategraphActionHandler("wilson_client", ActionHandler(ACTIONS.RUBY_OF_ILLUSIONS, "give")) AddComponentAction("POINT", "ruby_of_illusions", function(inst, doer, pos, actions, right, target) table.insert(actions, ACTIONS.RUBY_OF_ILLUSIONS) end) Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1773138 Share on other sites More sharing options...
Mr.CrazyPotato Posted December 10, 2024 Share Posted December 10, 2024 Well, for further investigations I think component file is needed. Make sure it's in your scripts/components/ and I think problem might be in it as well. Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1773148 Share on other sites More sharing options...
josra102 Posted December 11, 2024 Author Share Posted December 11, 2024 Here is the component : local ruby_of_illusions = Class(function(self, inst) self.inst = inst end) function ruby_of_illusions:nigntmare(inst, doer, pos, target, doer) print("test") end return ruby_of_illusions Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1773810 Share on other sites More sharing options...
Mr.CrazyPotato Posted December 18, 2024 Share Posted December 18, 2024 Sorry for answearing that late, I had some things to do with school. I was wondering: what are you trying to do with this code? It's point action, sure, but I just have no idea what you're trying to achieve. You want action on the ground on right mouse button for your character which will have this component? Or is that something else? Just I've been thinking that maybe the more exact point of code will help me understand what should I do to help you. Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1780429 Share on other sites More sharing options...
josra102 Posted December 26, 2024 Author Share Posted December 26, 2024 Hi. I've been working on something else for now and only this ruby is left. So I tried to do it through "spellcaster" but it doesn't want to work, apparently because it's an item on the body and not in the hand. And I tried like a willow spell but there they go through "spellbook" and I understood how to do it and I don't need it. In general, I have no ideas. And trying to make a new action didn't work, it just doesn't appear Link to comment https://forums.kleientertainment.com/forums/topic/162098-need-help-with-cursor-action/#findComment-1782399 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