Inconsistent Superload/overload addon behavior
Posted: Wed Feb 06, 2013 12:13 am
If 2 add-ons try to superload the same function, only the first load (lowest priority) succeeds and later loads are ineffective. For typical composite add-ons, this can result in only parts of each add-on being loaded, leading to unpredictable behavior.
As an example, I have attached 2 different add-ons (Sample1, weight 150, and Sample2, weight 100) that superload and overload the same 2 functions.
Sample1 overloads the Yeek Birth intro text, adding "YEEK! You're playing a YEEK! (1)"
and superloads the function mod.class.Actor.lua:canBe(what) adding "%s is tickled! (1)" in response to what == "tickle"
Sample2 overloads the Yeek Birth intro text, adding "Are you sure you want to play a YEEK? They're wimpy and weird (2)"
and superloads the function mod.class.Actor.lua:canBe(what) adding "%s is NOT ticklish! (2)" in response to what == "tickle"
With both files loaded, the game uses the birth code from Sample1 and the Actor.lua code from Sample2.
As an example, I have attached 2 different add-ons (Sample1, weight 150, and Sample2, weight 100) that superload and overload the same 2 functions.
Sample1 overloads the Yeek Birth intro text, adding "YEEK! You're playing a YEEK! (1)"
and superloads the function mod.class.Actor.lua:canBe(what) adding "%s is tickled! (1)" in response to what == "tickle"
Sample2 overloads the Yeek Birth intro text, adding "Are you sure you want to play a YEEK? They're wimpy and weird (2)"
and superloads the function mod.class.Actor.lua:canBe(what) adding "%s is NOT ticklish! (2)" in response to what == "tickle"
With both files loaded, the game uses the birth code from Sample1 and the Actor.lua code from Sample2.