Difference between revisions of "Addons"

From Tales of Maj'Eyal
Jump to: navigation, search
m
Line 22: Line 22:
 
===== Details about Superloading =====
 
===== Details about Superloading =====
  
16:42 DarkGod overload repalces a whole *file*
+
16:42 '''DarkGod''' overload repalces a whole *file*
16:42 Reenen ok
+
16:42 '''Reenen''' ok
16:42 DarkGod superload is hum ..
+
16:42 '''DarkGod''' superload is hum ..
16:43 Reenen superload adds to a currently existing function
+
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''' when the engine wants to load a class; say mod.class.Foo
16:43 DarkGod it loads the module's one
+
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''' 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''' 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: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''' 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 *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)
+
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:
 
To load the existing function you should have:
Line 59: Line 59:
  
 
For those using OSX, there is no te4_log.txt. You might try running T-Engine from the Terminal (in Finder, right-click T-Engine, Show Package Contents, right-click /Contents/MacOS/t-engine and Open With -> Terminal), then follow the directions above. After exiting the game, search for 'md5' in the Terminal window and find the one for your addon.
 
For those using OSX, there is no te4_log.txt. You might try running T-Engine from the Terminal (in Finder, right-click T-Engine, Show Package Contents, right-click /Contents/MacOS/t-engine and Open With -> Terminal), then follow the directions above. After exiting the game, search for 'md5' in the Terminal window and find the one for your addon.
 +
 
Note however, that this method does not work for some, as the last character from the md5 may be cut off when using this method. Those running into this problem are able to extract the full md5 by running the game in gdb for mac (Google is your friend) and checking the console after exiting.
 
Note however, that this method does not work for some, as the last character from the md5 may be cut off when using this method. Those running into this problem are able to extract the full md5 by running the game in gdb for mac (Google is your friend) and checking the console after exiting.

Revision as of 09:17, 29 June 2013

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

  1. 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.
  2. 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.
  3. Data: Make new data like talents, NPCs, etc accessible to the game. This data will still need to be loaded (see hooks below).
  4. 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. Find a list of available hooks here.

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(<args>)
-- Do stuff "before" loading the original file
base(self, <args>)  -- 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.

For those using OSX, there is no te4_log.txt. You might try running T-Engine from the Terminal (in Finder, right-click T-Engine, Show Package Contents, right-click /Contents/MacOS/t-engine and Open With -> Terminal), then follow the directions above. After exiting the game, search for 'md5' in the Terminal window and find the one for your addon.

Note however, that this method does not work for some, as the last character from the md5 may be cut off when using this method. Those running into this problem are able to extract the full md5 by running the game in gdb for mac (Google is your friend) and checking the console after exiting.