engine/ui/Dialog.lua won't superload, but List.lua will.

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

engine/ui/Dialog.lua won't superload, but List.lua will.

#1 Post by Marson »

I think I've got my head wrapped around superloading, but I'm banging my head against the wall trying to figure out why the init function in engine/ui/Dialog.lua won't superload. I copied the file over to engine/ui/List.lua and that will load fine. To keep it simple for testing this, I used:

Code: Select all

local _M = loadPrevious(...)

local D = require "engine.Dialog"
	
function _M:init(title, w, h, x, y, alpha, font, showup, skin)
	D:simplePopup("FUUUUU!!!", "FUUUUUUUU!!!!!")
end

return _M
With the same code in both Dialog.lua and List.Lua, this is the error thrown:

Code: Select all

Checking addon	tome-marson-ui	:: (as dir)	true	:: (as teaa)	nil	

Binding addon	Marson's UI Modifications	nil	tome-marson-ui-1.1.5
 * with superload
 * with overload
 * with hooks

FROM 	/mod/addons/marson-ui/superload/engine/ui/EquipDoll.lua	loading previous!
FROM 	/mod/addons/marson-ui/superload/engine/ui/List.lua	loading previous!
Using cached font	/data/font/DroidSans.ttf	14
Lua Error: /engine/ui/Dialog.lua:369: attempt to perform arithmetic on field 'h' (a nil value)
	At [C]:-1 __add
	At /engine/ui/Dialog.lua:369 setupUI
	At /engine/dialogs/GameMenu.lua:37 init
	At /engine/class.lua:97 new
	At /mod/class/Game.lua:1808 
	At /engine/KeyBind.lua:263 triggerVirtual
	At /mod/class/uiset/Minimalist.lua:1947 fct
	At /engine/Mouse.lua:52 
The problem isn't the error, which should be there, but the fact that none of the functions in Dialog.lua will superload, while ones in other files will. I put the same code with different text in EquipDoll as well. Both List:init and EquipDoll:init will display the text (before other parts get upset with "nil" variables).

I've also added

Code: Select all

function _M:setupUI(stuff)
	D:simplePopup("FUUUUU!!!U2", "FUUUUUUUU!!!!!U2")
end
to Dialog.lua, but no change. It still shows At /engine/ui/Dialog.lua:369 setupUI. If I superload GameMenu:init(), I'll get At /mod/addons/marson-ui/superload/engine/dialogs/GameMenu.lua:37 init, so other superloads work.

I've also removed almost all other addons, and the ones remaining have nothing in "engine". I'm guessing I'm missing something obvious, but I'm stumped. Any ideas?
TomeFiles.jpg
TomeFiles.jpg (69.78 KiB) Viewed 4187 times

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#2 Post by Marson »

*pulls out remaining hair*

I suppose I should ask if anyone has successfully overloaded or superloaded any functions in engine/ui/Dialog.lua in any addons they've made. I can't see any reason in the code why it would be different, but I'm trying to eliminate possibilities.

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#3 Post by Marson »

The reason I'm in that file to begin with is to enlarge some hard-coded dialog sizes without needing to copy every function that calls one. I'm boosting the font size, and I think I can scale the dialog width based on font size and have that cover most circumstances.

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#4 Post by Marson »

If anyone else runs into this, I resorted to putting explicit references in hooks/load.lua for the functions I wanted to modify.

Code: Select all

local base_D_init = engine.ui.Dialog.init
function engine.ui.Dialog:init(title, w, h, x, y, alpha, font, showup, skin)
	code, Blah!
	base_D_init(self, title, w, h, x, y, alpha, font, showup, skin)
end
It works, anyway.

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#5 Post by Zireael »

I've had to resort to similar shenanigans to debug my module.

The chatbox dialog consistently tries to use simple ui and I can't make it use either the module default or metal - the result is that it throws errors. Help?

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#6 Post by Marson »

Putting

package.loaded['engine.ui.Dialog'] = nil

in hooks/load.lua allowed me to overload the file, though it doesn't work for engine.UserChat for whatever reason. I still have to overwrite engine.UserChat:resize() in load.lua.

I'd probably have to look at your specific code to be much help, but just as a stab in the dark...
If you are making new dialog types, are you inheriting engine.ui.Base ?

local Base = require "engine.ui.Base"
module(..., package.seeall, class.inherit(Base))

Doctornull
Sher'Tul Godslayer
Posts: 2402
Joined: Tue Jun 18, 2013 10:46 pm
Location: Ambush!

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#7 Post by Doctornull »

Thanks to Marson's advice, I've got Nulltweaks being much more ... cooperative.

Here's what I did in hooks/load.lua (at the end):

Code: Select all

package.loaded['mod.class.interface.Combat'] = nil
package.loaded['data.talents.chronomancy.chronomancer'] = nil
package.loaded['data.talents.cursed.shadows'] = nil
package.loaded['data.talents.gifts.moss'] = nil
package.loaded['data.talents.misc.inscriptions'] = nil
package.loaded['data.talents.misc.objects'] = nil
package.loaded['data.talents.spells.aether'] = nil
package.loaded['data.talents.spells.arcane'] = nil
package.loaded['data.talents.techniques.2hweapon'] = nil
package.loaded['data.talents.techniques.combat-training'] = nil
package.loaded['data.talents.techniques.magical-combat'] = nil
package.loaded['data.talents.uber.str'] = nil
package.loaded['data.timed_effects'] = nil
Check out my addons: Nullpack (classes), Null Tweaks (items & talents), and New Gems fork.

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#8 Post by Zireael »

Judging by Zizzo's code, something similar is going on with Zone.lua. It makes tweaking entity generation difficult.

Zizzo
Sher'Tul Godslayer
Posts: 2521
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

Re: engine/ui/Dialog.lua won't superload, but List.lua will.

#9 Post by Zizzo »

Zireael wrote:Judging by Zizzo's code, something similar is going on with Zone.lua. It makes tweaking entity generation difficult.
...? Am I doing something particularly exotic in Zone.lua?

Anyway, catching up with the thread:
Marson wrote:If anyone else runs into this, I resorted to putting explicit references in hooks/load.lua for the functions I wanted to modify.

Code: Select all

local base_D_init = engine.ui.Dialog.init
function engine.ui.Dialog:init(title, w, h, x, y, alpha, font, showup, skin)
	code, Blah!
	base_D_init(self, title, w, h, x, y, alpha, font, showup, skin)
end
It works, anyway.
That may actually be the semi-official way of doing this sort of thing. Take a look at T4's mod.class.MapEffects, for instance; it gets require()'d in mod/load.lua, apparently for the express purpose of surgically replacing certain functions in engine.Map, basically the same way you're doing above. I'm doing something similar in T2.

...Wait, you're talking about addons, not modules, aren't you? (shrug) Well, the principle's the same, and as you say, it works.
"Blessed are the yeeks, for they shall inherit Arda..."

Post Reply