Client autoloader 2.x.x

Structure:

The entry point to a client mod is a file you name “cmod.cs” if you distribute mods with this file it will be found and auto executed by LiFx framework if it is in ~/mods, ~/yolauncher/mods or ~/yolauncher/modpack folders.

Hook overview

$LiFx::hooks::onDatablockLoad Entry hook for loading new datablocks on the client. It is executed after the original code from BitBox is executed so that you can inherit datablocks from BitBox.
$LiFx::hooks::onMaterialsLoad
Entry hook for loading new materials, it is executed right after original material load code from BitBox so that you can reference and use material references to the base game as well as ensuring the load time is correct.
$LiFx::hooks::onInitialized
Hook to call mod code at the very end of init() from the Base game.
$LiFx::hooks::onInitClientDone
Hook to call mod code just after onInitClientDone is called but before joining a server.
$LiFx::hooks::beforeInitClientDone
Hook to call mod code just before onInitClientDone is called.

 

Example mod

Example cmod.cs:

/**
* <author></author>
* <url>lifxmod.com</url>
* <credits></credits>
* <description></description>
* <license>GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007</license>
*/
// ---------------- hook overview
// $LiFx::hooks::onDatablockLoad =  JettisonArray("onDatablockLoad"); // Entry hook for loading new datablocks on the client. It is executed after the original code from BitBox is executed so that you can inherit datablocks from BitBox.
// $LiFx::hooks::onMaterialsLoad =  JettisonArray("onMaterialsLoad"); // Entry hook for loading new materials, it is executed right after original material load code from BitBox so that you can reference and use material references to the base game as well as ensuring the load time is correct.
// $LiFx::hooks::onInitialized =  JettisonArray("onInitialized"); // Hook to call mod code just after onInitClientDone is called but before joining a server.
// $LiFx::hooks::onInitClientDone =  JettisonArray("onInitClientDone"); // Hook to call mod code just after onInitClientDone is called but before joining a server.
// $LiFx::hooks::beforeInitClientDone =  JettisonArray("beforeInitClientDone"); // Hook to call mod code just before onInitClientDone is called.
// $LiFx::hooks::mods = JettisonArray("mods"); // Hook to register the mod to be loaded by LiFxframework, pass inn function to initialize and register the above hooks.

if (!isObject(ExampleCMod))
{
    new ScriptObject(ExampleCMod)
    {
    };
}
package ExampleCMod
{
  function ExampleCMod::setup() {
    LiFx::registerCallback($LiFx::hooks::onDatablockLoad, RegisterDatablock, ExampleCMod);
    LiFx::registerCallback($LiFx::hooks::onMaterialsLoad, RegisterMaterials, ExampleCMod);
    LiFx::registerCallback($LiFx::hooks::onInitialized, onInitialized, ExampleCMod);
    LiFx::registerCallback($LiFx::hooks::onInitClientDone, onInitClientDone, ExampleCMod);
    LiFx::registerCallback($LiFx::hooks::beforeInitClientDone, beforeInitClientDone, ExampleCMod);
  }

  function ExampleMod::RegisterDatablock() {
    LiFx::loadRecursivelyInFolder("yolauncher/modpack", "datablock.cs");
  }
  function ExampleMod::RegisterMaterials() {
    LiFx::loadRecursivelyInFolder("yolauncher/modpack", "materials.cs");
  }
  function ExampleMod::onInitialized() {
    // Init client mod variables binds etc
  }
  function ExampleMod::onInitClientDone() {
    // run code that has to be ran after bitbox base game
  }
  function ExampleMod::beforeInitClientDone() {
   // change skill trees etc
  }
};
activatePackage(ExampleCMod);
LiFx::registerCallback($LiFx::hooks::mods, setup, ExampleCMod);

 

+1