Need some help understanding superloading
Posted: Tue Feb 12, 2013 11:06 pm
I'm trying to figure out superloading so that I can write mods the right way. Running into problems.
Here's (what I believe to be) my troublesome code, in /mod/class:
Which I anticipated to just give me a log message every time I entered a level, but which instead throws:
Tried to trace this through, but it doesn't make any sense to me. The above code (player.lua superload) was just added to the superload example ( http://te4.org/dl/tmp/tome-example.teaa ) from the wiki, which was modified for version 1,0,0 but otherwise untouched, and which stops throwing errors the instant I remove my overload/mod/player.lua.
Happy to provide any more details, have just provided what I believe to be necessary. Looking especially for abstract information about how superloading works, less so for how to get it to work in this particular instance (which as you can see from the code is just a learning exercise for me).
Thanks in advance for anybody who feels like helping me out!
Here's (what I believe to be) my troublesome code, in /mod/class:
Code: Select all
local _M = loadPrevious(...)
local base_onEnterLevel = _M:onEnterLevel
function _M:onEnterLevel(zone, level)
game.logSeen(self, "This is a test of superloading.")
return base_act(self, zone, level)
end
return _M
Code: Select all
FROM /mod/addons/example/superload/mod/class/Actor.lua loading previous!
Lua Error: /loader/init.lua:148: bad argument #1 to 'setfenv' (number expected, got nil)
At [C]:-1
At [C]:-1 setfenv
At /loader/init.lua:148
At [C]:-1 require
At /mod/class/Game.lua:45
At [C]:-1 require
At /mod/load.lua:326
At [C]:-1 require
At /engine/Module.lua:159 load
At /engine/Module.lua:699 instanciate
At /engine/utils.lua:1906 showMainMenu
At /engine/init.lua:136
At [C]:-1 dofile
At /loader/init.lua:190
Happy to provide any more details, have just provided what I believe to be necessary. Looking especially for abstract information about how superloading works, less so for how to get it to work in this particular instance (which as you can see from the code is just a learning exercise for me).
Thanks in advance for anybody who feels like helping me out!