Consider a donation to support the creation of free game assets!

Lua scripting reference for Asset Forge

Article January 6th, 2024 1 min read

    Using Asset Forge you can run scripts written in Lua using the methods listed below.

    General

    forge.print(string text)
    Displays a message on screen

    forge.clear()
    Clears all blocks in current project without warning

    forge.getNoise(int x, int y)
    Returns a Perlin noise sample

    forge.exportSprite(int size, string path)
    Exports a 2D sprite using the current configuration set in the side panel

    forge.load(string path)
    Loads a .model file

    forge.save(string path)
    Saves a .model file

    Selection

    forge.selectAll(string block)
    Select all blocks in model, optional filter block type

    forge.selectNone()
    Clear current selection

    forge.selectRandom(string block)
    Select a random block of type (parameter is optional)

    forge.invertSelection()
    Inverts selection

    forge.getSelectionX() forge.getSelectionY() forge.getSelectionZ()
    Returns the position of the current selection

    Block properties

    forge.hideSelection()
    Hides all blocks in current selection

    forge.showSelection()
    Shows all blocks in current selection

    forge.groupSelection(string name)
    Creates new group of currently selected blocks, optionally specify a name

    forge.ungroupSelection()
    Removes blocks from group

    forge.replaceSelection(string block)
    Replaces current selection with block of given type

    forge.deleteSelection()
    Remove blocks in current selection

    Blocks

    forge.getBlockType()
    Returns currently selected block type as string, if multiple are selected returns the first entry

    forge.build(string block, {0, 0, 0}, {0, 0, 0})
    Builds specified block at position, rotation (optional)

    forge.moveSelection({0, 0, 0})
    Move all blocks in current selection by vector

    forge.rotateSelection({0, 0, 0})
    Rotate all blocks in current selection by vector

    forge.scaleSelection({0, 0, 0})
    Scale all blocks in current selection by vector

    Materials

    forge.materialColor(string name, string hex)
    Sets the color of a material currently in the project

    Mastodon