Modifying GUI Values without Globals
Dalin Seivewright
0x0000221E Join Date: 2007-10-20 Member: 62685Members, Constellation
I have replaced the GUIWelderDisplay with some custom code using Class_ReplaceMethod. The code changes involve some variables that will change over time. The NS2 code base is riddled with Global variables (which incidentally, makes me want to throw monitors) and they seem necessary to update the GUI state.
For example, the Welder class uses the following to update its default WelderDisplay:
I cannot use the same as I don't think there is a way to add global variables to a particular class file... because... well.. they're Globals.
So my question is this: Aside from just using a custom GUI Class and overwriting the relevant parts in Welder, is there any other way I can go about updating the GUI class?
Note: I do define Setters for my custom code in the form of:
What am I doing horrible wrong?
For example, the Welder class uses the following to update its default WelderDisplay:
if self.ammoDisplayUI then local progress = PlayerUI_GetUnitStatusPercentage() self.ammoDisplayUI:SetGlobal("weldPercentage", progress) end
I cannot use the same as I don't think there is a way to add global variables to a particular class file... because... well.. they're Globals.
So my question is this: Aside from just using a custom GUI Class and overwriting the relevant parts in Welder, is there any other way I can go about updating the GUI class?
Note: I do define Setters for my custom code in the form of:
function GUIWelderDisplay:MySetterFunctionHowever, calling Class_Reload nets me a lovely Assert failure on Line 84 of Class.lua. I'm assuming that Class_Reload is only needed when making changes to existing functions, not simply adding them but please correct me if I'm wrong. Assuming I am correct, using:
self.ammoDisplayUI:MySetterFunctionfails as it cannot find this function, so I'm assuming self.ammoDisplayUI is not a GUIWelderDisplay instance directly.
What am I doing horrible wrong?
Comments
Thanks. I had a feeling a custom GUI class was going to be needed.