Deceptive Pastry Posted November 2, 2022 Share Posted November 2, 2022 (edited) I'm trying to set up some extra FirearmRadialMenu functions just like the emote menu does. ISEmoteRadialMenu sets up its menu as shown below. If I set it up exactly like this for the firearm radial .lua but replace everything with ISFirearmRadialMenu, it doesn't work. It DOES work (In that it fills out the menu and the buttons work properly) if I put all the ISFirearmRadialMenu.x lines inside ISFirearmRadialMenu:fillmenu, but that also executes some commands stored in the variables upon opening the menu which I don't want. But if I put ISFirearmRadialMenu.x inside a separate function as in the emote code, :init, then :fillmenu pairs can't find the tables. I thought not using "local x" would make it accessible to the whole file (or just make them global) rather than just the function, but seemingly not, or is there something else I'm missing? I don't see anything else in the ISEmoteRadialMenu code indicating a reason why it should be working differently. I don't understand how ISEmoteRadialMenu:fillmenu is accessing the table set up in :init. function ISEmoteRadialMenu:init() ISEmoteRadialMenu.defaultMenu = {}; ISEmoteRadialMenu.defaultMenu["friendly"] = {}; ISEmoteRadialMenu.defaultMenu["friendly"].name = getText("IGUI_Emote_Friendly"); ISEmoteRadialMenu.defaultMenu["friendly"].subMenu = {}; ISEmoteRadialMenu.variants = {}; ISEmoteRadialMenu.variants["wavehi"] = {"wavehi", "wavehi02", "wavebye"}; ISEmoteRadialMenu.icons = {}; ISEmoteRadialMenu.icons["friendly"] = getTexture("media/ui/emotes/thumbsup.png"); ISEmoteRadialMenu.menu = ISEmoteRadialMenu.defaultMenu; end function ISEmoteRadialMenu:fillMenu(submenu) local menu = getPlayerRadialMenu(self.playerNum) menu:clear() local icon = nil; if not submenu then -- base menu with all categories for i,v in pairs(ISEmoteRadialMenu.menu) do icon = nil; if ISEmoteRadialMenu.icons[i] then icon = ISEmoteRadialMenu.icons[i]; end if v.subMenu then -- stuff with submenu menu:addSlice(v.name, icon, self.fillMenu, self, i) else -- stuff for rapid access menu:addSlice(v.name, icon, self.emote, self, i) end end else for i,v in pairs(ISEmoteRadialMenu.menu[submenu].subMenu) do icon = nil; if ISEmoteRadialMenu.icons[i] then icon = ISEmoteRadialMenu.icons[i]; end menu:addSlice(v, icon, self.emote, self, i) end menu:addSlice(getText("IGUI_Emote_Back"), ISEmoteRadialMenu.icons["back"], self.fillMenu, self) end self:display() end Edited November 2, 2022 by Deceptive Pastry Link to comment Share on other sites More sharing options...
Deceptive Pastry Posted November 2, 2022 Author Share Posted November 2, 2022 I've found that if I add self.init() to the beginning of ISFirearmRadialMenu:fillMenu and run pairs, it fills out the table and everything works properly. So now I'm even more confused, how is ISEmoteRadialMenu:fillmenu accessing the tables within :init without accessing :init? Link to comment Share on other sites More sharing options...
Deceptive Pastry Posted November 3, 2022 Author Share Posted November 3, 2022 I did a lot of file searching. Turns out this function: function ISEmoteRadialMenu:new(character) local o = ISBaseObject.new(self) o.character = character o.playerNum = character:getPlayerNum() ISUIEmoteConfig:readFile(); return o end Links to another file, ISUIEmoteConfig, which contains the ISEmoteRadialMenu:init();. trombonaught 1 Link to comment 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