Jump to content

Can't figure out how ISEmoteRadialMenu is pulling table from another function.


Deceptive Pastry

Recommended Posts

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 by Deceptive Pastry
Link to comment
Share on other sites

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();.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...