User Tools

Site Tools


dev:plugin:core

This plugin is required by all plugins part of the eXpansion pack. This plugin doesen't have a lot to do it basically has 3 main roles

Roles

Load Configuration

Multiple Language Support (i18n)

If you are hosting a server for specific language, you can enable the new default language in config file:

ManiaLivePlugins\eXpansion\Core\Config.defaultLanguage = language

Function for all localized messages is

__()

, that is defined in BasicPlugin class, which registers the function to general namespace. Core plugin handles loading and setting the default language. When invoked, the

__()

function then calls the i18n singleton and passes all parameters to sprintf which formats the text.

To use multiple language support, just do this:

__("your string to display goes here", $login); // string without parameters, with the login tho whom you will display the message
 
__("admin %s kicked the player %s", $login, $admin, $player); // string with parameters and with the login tho whom you will display the message

Even if this method is good, it might be slow, The Core will need to search for translations of the text. Ideally you should do that once. You can improve by simply doing this :

public static $msg_needBeAdmin;
public static $msg_adminkicked;
public function exp_onLoad() {
        self::$msg_needBeAdmin= exp_getMessage('#admin_error#You need to be an Admin to use that command');
        self::$msg_adminkicked = exp_getMessage("admin %s kicked the player %s");
        //More stuff
}

exp_getMessage will return an object containing all the translations of the text. That way you wan't need to search for them again. Then you use it just like before

__(self::$msg_needBeAdmin, $login); // string without parameters, with the login tho whom you will display the message
 
__(self::$msg_adminkicked, $login, $admin, $player); // string with parameters and with the login tho whom you will display the message

Color Codes

At the current stage the core plugin only loads the configuration of the Color parsing utility.

You may wan't to customize your installation and add you own color codes. You can do this directly in the configuration file by adding these lines :

ManiaLivePlugins\eXpansion\Core\Config.Colors_admin_error = customValue
ManiaLivePlugins\eXpansion\Core\Config.Colors_admina_action = customValue
ManiaLivePlugins\eXpansion\Core\Config.Colors_variable = customValue

YOu may find more information about how to use the color codes here : Chat Coloring

Check GameMode Compatibility

Every plugin checks their own game mode Compatibility, if they are not compatible at start they will unload.(More Info). But this isn't enough, if the game mode changes we might want to unload other plugins or load some new.

The Core plugin will check at the beginning of each map for a change in the game mode, if there is one it will force all loaded plugins to check if they are compatible and then check all the unloaded plugins if any is compatible. If any unloaded plugin is compatible it will load it.

Theoretically all load and unload processes will take in account dependencies. If plugin X isn't compatible with game mode and plugin Y needs it, the system will force unload plugin Y then plugin X. And it will the same way load plugin X first then plugin Y

dev/plugin/core.txt · Last modified: 2013/07/17 10:08 (external edit)