As of beta 35 the t-engine has support for addons. Addons are way for third parties to modify existing modules.
Capabilities
Addons are capable of three things to modify their parent module
- Overloading: Overloading is a way to add new or overwrite files to the parent module. This the way graphics such as talent icons are added. Overloading can also add .lua but will replace those with the same name. So typically adding new trees, or overwriting trees. Or adding music and graphics.
- Superloading: Superloading allows you to add completely replace, or add code to the beginning or end of an arbitrary class function. Currently only ActorTalents and ActorTemporaryEffects supports superloading.
- Data: Make new data like talents, NPCs, etc accessible to the game. This data will still need to be loaded (see hooks below).
- Hooks: Certain functions are capable of supporting hooks. When that function is called they will also call whatever is in the hook. Example module shows how the "Actor:takeHit" function is hooked to make the tourist take no damage. You can also use hooks to load add-on data in to the module, eg. new talents.
An example addon can be found here: http://te4.org/dl/tmp/tome-example.teaa
A .teaa file is simply a renamed zip that contains the whole addon, this way the players do not even have to unzip it!
The example addon illustrate how to add a new class, new talents, new timed effects and how to hook onto a few useful locations in the code.
Grammar and Syntax
- The addon folder must be in the format <ModuleName>-<AddonName>.
- The short_name in init.lua must be the same as the module folder's name (excluding the module name).
Details about Superloading
16:42 DarkGod overload repalces a whole *file*
16:42 Reenen ok
16:42 DarkGod superload is hum ..
16:43 Reenen superload adds to a currently existing function
16:43 DarkGod when the engine wants to load a class; say mod.class.Foo
16:43 DarkGod it loads the module's one
16:43 DarkGod then it checks each addons if there is a superload for it
16:43 DarkGod if there is it loads the superload, passing it the existing one
16:43 DarkGod there the code can do waht it wants with it
16:44 DarkGod basically you replace a method with your own
16:44 DarkGod and *if* you wish your own method to call the previous one you do it
16:44 DarkGod (and it is a good idea to do so, so taht addons can "chain" superloads)
To load the existing function you should have:
local _M = loadPrevious(...)
local base = _M.levelup (or whatever function you are superloading)
function _M:levelup()
-- Do stuff "before" loading the original file
base(self) -- Loads the original file
-- Do stuff "after" loading the original file
return
end
return _M
Addon MD5
The MD5 is needed for uploading addons to the website.
Make sure the final addon is in .teaa form and activated, and that cheat mode is off.
Start a new character, then exit the game.
Open the te4_log.txt and search for md5.
Recent comments
4 days 12 hours ago
4 days 14 hours ago
5 days 13 hours ago
6 days 1 hour ago
6 days 7 hours ago
1 week 16 hours ago
1 week 17 hours ago
1 week 20 hours ago
1 week 1 day ago
1 week 1 day ago