PlayerGfx.lua

From Moondust Wiki
Revision as of 10:14, 26 November 2017 by Yingchun Soul (talk | contribs)
Jump to navigation Jump to search

Attention: This page contains dead links!

Download latest version
Download example level

Note: This library only for use if you don't have SMBX2!

playerGfx is a library for swapping or overlaying sets of player graphics at runtime.

Installation

Drop the playerGfx.lua file in the LuaScriptsLib folder.

How to use

Overlay/replacement images should be formatted like regular SMBX player graphics, except they must be PNG files with transparent backgrounds and they should ideally use the naming convention "[prefix]_[number]" as opposed to SMBX's default "[prefix]-number". They should be placed in the episode or level folder.

Once you have your images in place, load in the API and use 'playerGfx.arrayFromPrefix()' to generate a table of your images' filenames. Use that table in PlayerGfxSet.createEx() to generate a PlayerGraphicsSet instance, and call playerGfx.assignSet() to assign a PlayerGraphicsSet to a given character.

Player graphic sets are only used when playerGfx.isOn == true; use playerGfx.enable(), playerGfx.disable() and playerGfx.toggle() to activate and deactivate the system.

Code Documentation

playerGfx
Type Function/Field Return values/Value type Description
function playerGfx.enable () nil Enables the graphic replacement system.
function playerGfx.disable () nil Disables the graphic replacement system.
function playerGfx.toggle () nil Toggles the graphic replacement system.
function myFilenameTable = playerGfx.arrayFromPrefix (String prefix) Table of String Generates a table of filenames corresponding to powerup states from a given prefix using the format "[prefix]_[number].png".
function myPlayerGfx = PlayerGfxSet.create (Table of String filenameArray, number offsetX, number offsetY, boolean overwrite) PlayerGfxSet Creates a new graphics set from the given filename array. When assigned to a player character, the images will be offset from the player's position by offsetX and offsetY, and if overwrite is true the player's normal graphics will be hidden. Deprecated: use createEx instead!
function myPlayerGfx = PlayerGfxSet.createEx (Table of String filenameArray, Table of named arguments properties) PlayerGfxSet Creates a new graphics set from the given filename array and table of named arguments. The arguments of PlayerGfxSet.create() have equivalents of the same name ("offsetX", "offsetY" and "overwrite"), and additional arguments will be listed here in the future.
function playerGfx.assignSet (Character constant playerChar, PlayerGfxSet gfxSet) nil Changes the given player character's graphics to use the given PlayerGfxSet; if gfxSet is nil, the character is reset to their default graphics.