Rincevvind Posted May 2, 2014 Share Posted May 2, 2014 (edited) i have a custom component which adds two custom actions for some prefabSTRINGS.ACTIONS.SIGNREAD = "Sign read"STRINGS.ACTIONS.SIGNEDIT = "Sign edit"ACTIONS.SIGNREAD = Action(2,true)ACTIONS.SIGNREAD.fn = function(act) local tar = act.target if tar and tar.components.signdata then tar.components.signdata:OnLeftClick(tar) return true endendACTIONS.SIGNEDIT = Action(2,true,true)ACTIONS.SIGNEDIT.fn = function(act) local tar = act.target if tar and tar.components.signdata then tar.components.signdata:OnRightClick(tar) return true endendlocal SignData = Class(function(self, inst) self.inst = inst self.oncd = false self.data = {} self.done = falseend)function SignData:CollectSceneActions(doer, actions, right) if right and (not self.oncd) then table.insert(actions, ACTIONS.SIGNEDIT) end if not right and (not self.oncd) then table.insert(actions, ACTIONS.SIGNREAD) endendfunction SignData:OnLeftClick(target) print ("OnLeftClick")endfunction SignData:OnRightClick(target) print ("OnRightClick")endits work fine except one thing - its shows default "ACTION" string instead of my STRINGS.ACTIONS.SIGNREAD / STRINGS.ACTIONS.SIGNEDIT addingACTIONS.SIGNREAD.str = "Sign read"ACTIONS.SIGNREAD.id = "SIGNREAD"ACTIONS.SIGNEDIT.str = "Sign edit"ACTIONS.SIGNEDIT.id = "SIGNEDIT"doesnt helps too why? Edited May 2, 2014 by Rincevvind Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/ Share on other sites More sharing options...
Rincevvind Posted May 2, 2014 Author Share Posted May 2, 2014 in game : Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/#findComment-468238 Share on other sites More sharing options...
squeek Posted May 2, 2014 Share Posted May 2, 2014 (edited) It's because you're not setting the 'id' key of your entries in the ACTIONS table, which is used to get the corresponding entry in the STRINGS table. Adding a line like this to your actions should fix it:ACTIONS.SIGNREAD.id = "SIGNREAD" The modding API has a function for adding actions, though, so it might be better to use that. From the API examples mod: ------------------------------------- Actions and Handlers---- AddAction(action)-- Puts a new action into the global actions table and sets up the basic-- string for it.---- AddStategraphActionHandler("stategraphname", newActionHandler)-- Appends a handler for your action (or an existing action!) to an-- existing stategraph.-------------------------------------local Action = GLOBAL.Actionlocal ActionHandler = GLOBAL.ActionHandlerlocal MYACT = Action(3)MYACT.str = "Do My Action"MYACT.id = "MYACT"MYACT.fn = function(act) print(act.doer.. " is doing my action!")endAddAction(MYACT)AddStategraphActionHandler("wilson", ActionHandler(MYACT, "doshortaction")) Edited May 2, 2014 by squeek Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/#findComment-468242 Share on other sites More sharing options...
Rincevvind Posted May 2, 2014 Author Share Posted May 2, 2014 (edited) i try this API way, but look at picture, its have same fields with standart action Edited May 2, 2014 by Rincevvind Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/#findComment-468243 Share on other sites More sharing options...
squeek Posted May 2, 2014 Share Posted May 2, 2014 What does typingprint tostring(_G.STRINGS.ACTIONS.SIGNREAD)in the console give you? Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/#findComment-468244 Share on other sites More sharing options...
Rincevvind Posted May 2, 2014 Author Share Posted May 2, 2014 oh yes, STRINGS.ACTIONS.... was comented, my fault btw AddAction doing same env.AddAction = function(action) assert(action.id ~= nil, "Must specify an ID for your custom action! Example: myaction.id = \"MYACTION\"") initprint("AddAction", action.id) ACTIONS[action.id] = action STRINGS.ACTIONS[action.id] = action.str end but really good to know about it problem solved Well only one left - there two actions, but only one description is shows, any chance to show them both? Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/#findComment-468246 Share on other sites More sharing options...
squeek Posted May 2, 2014 Share Posted May 2, 2014 (edited) oh yes, STRINGS.ACTIONS.... was comented, my fault btw AddAction doing same env.AddAction = function(action) assert(action.id ~= nil, "Must specify an ID for your custom action! Example: myaction.id = \"MYACTION\"") initprint("AddAction", action.id) ACTIONS[action.id] = action STRINGS.ACTIONS[action.id] = action.str end but really good to know about itYep. I first thought you were adding to STRINGS.ACTIONS manually and then calling AddAction which was overwriting them, but then I realized you weren't even calling AddAction. Well only one left - there two actions, but only one description is shows, any chance to show them both?I think that might have to do with priority, but I'm not sure. Try setting one action's priority lower than the other and see if that works, and if it doesn't, then try switching them. Edited May 2, 2014 by squeek Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/#findComment-468248 Share on other sites More sharing options...
Rincevvind Posted May 2, 2014 Author Share Posted May 2, 2014 (edited) oh no, its works with any priority, just not on same place 1 description is under and 1 below, so its works "problem" solved haha, i guess i need to go sleep. sorry for disturbing without reason Edited May 2, 2014 by Rincevvind Link to comment https://forums.kleientertainment.com/forums/topic/35788-problem-with-stringsactions/#findComment-468250 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