Skip to content

Creating a mod

Hellrage edited this page Mar 6, 2021 · 1 revision

Bezel expects mods to have certain methods and properties in order to load them. This is dictated by the way flash loads files and by the API.

For an example refer to Gemsmith.as

[REF] are links to lines that implement a mentioned feature.

Requirements

Your mod must:

  • Be compiled into an .swf file via Flex/AIR SDK (I'm using Flex 4.6.0, AIR 32.0).
  • Have its Document class (the class that's loaded when the SWF is loaded) extend MovieClip. [REF]
  • Have a public parameterless constructor. That's needed for flash.display.Loader to load the SWF. [REF]
  • Have the following string consts: VERSION, GAME_VERSION, BEZEL_VERSION, MOD_NAME. [REF]
  • Have a public function bind(modLoader: Object, gameObjects: Object) method that returns your mod. In it you do your initialization logic and prepare to run. Bezel calls this after the game is initialized and ready to go. [REF]
  • Have a public function unload(): void method that unsubscribes your event listeners and disposes of resources. This method is called by Bezel when reloading mods to make sure that we're not leaving a bunch of duplicate subscribers running code on events. [REF]

Your mod may:

  • Have a public const COREMOD_VERSION: String and a public function loadCoreMod(lattice: Object): void method if you need to apply coremods (Modifications to the base game's code. Covered in a separate wiki page.)

Working with Bezel

Below are some features that Bezel provides for you and recommendations on organizing your mod.

Requesting a logger from Bezel.

This is the preferred method of logging, because this way we keep all logs in one place and Bezel takes care of formatting and timestamping. You'll want to do that in your bind method like so: bezel.getLogger("ModName"). Bezel tracks the created loggers, so if you request the same one from several places in your code, you'll get the same object. [REF]

Requesting a mod instance from Bezel.

This is useful if you want to have some cross-mod interaction or dependencies. It is done like so: bezel.getModByName("ModName"). Returns null if no such mod is loaded. [REF]

Using Local Store folder to store your data.

This is just a strong recommendation so that we have a standard place to store data along with the game. Please create a folder for your mod so it's neatly organized separately from everything else. [REF]

Subscribing to events.

Bezel provides some events out-of-the-box that trigger based on actions in the game. I suggest defining a private function addEventListeners(): void that handles all your subscriptions and a corresponding private function removeEventListeners(): void to unsubscribe. [REF]

Refer to BezelModLoader for specific events' eventArgs. Referenced is an example of subscribing to keystrokes. [REF]

You can also add your own events/hooks by coremodding. (Covered in a separate wiki page.)