Skip to content

utils.ogmo.wren

clsource edited this page Nov 16, 2020 · 4 revisions

Utility Classes for Parsing Ogmo Json files.

Based on https://github.com/Ogmo-Editor-3/ogmo-3-lib

  • Example:
import "domepunk/utils/ogmo" for Project, Level

class Game {
    static init() {
      var ogmo = Project.load("project.ogmo")
      System.print(ogmo.version)

      var level = Level.load("level.json")
      level.onTileLayerLoaded {|data, layer|
        System.print("onTileLayerLoaded triggered")
        System.print(data)
      }

      level.init()

    }
    static update() {}
    static draw(dt) {}
}
  • Since: 1.0.0
  • Dome: 1.4.0
  • Ogmo: 3.2.2

import "domepunk/utils/ogmo" for Project

// alias
import "domepunk/utils/ogmo" for OgmoProject, OProj

API

The Name of the Ogmo Project.

The version of Ogmo used

Array of paths that hold the Project's levels.

The Project's background color.

The color of the Grid displayed in the Project's Editor

Flag to set whether the Project describes rotations in Radians or Degrees. If set to true its in Radians. Otherwise it is in Degrees.

Sets the default exported file type of a Level.

Maximum Depth that the Editor will search for files for its File Tree.

Default size of newly created levels in the Editor.

Minimum size a level can be.

Maximum size a level can be.

Array of Value Templates for the Project's Levels.

Array containing all of the Project's available Entity Tags.

Array containing all of the Project's available Layer Templates.

Array containing all of the Project's available Entity Templates.

Array containing all of the Project's available Tilesets.

Creates an Ogmo Project from .ogmo data.

  • Signature: static load(path:String) -> Project
  • Parameter path: String to the file holding Ogmo data.
  • Returns: Project parsed from Ogmo file.

Attempts to get an ProjectEntity from an exportID.

  • Parameter exportID: The export id
  • Returns: ProjectEntity or null

Attempts to get an ProjectLayer from an exportID.

  • Parameter exportID: The export id
  • Returns: ProjectLayer or null

Attempts to get an ProjectTileset from an exportID.

  • Parameter name: The tileset name
  • Returns: ProjectTileset or null

import "domepunk/utils/ogmo" for Level

// alias
import "domepunk/utils/ogmo" for OgmoLevel, OLevel

API

Width of the Level.

Height of the Level.

Size (width, height)

Offset of the Level on the X axis. Useful for loading multiple chunked Levels.

Offset of the Level on the Y axis. Useful for loading multiple chunked Levels.

Point (offsetX, offsetY)

Array containing all of the Level's Layer Definitions.

Array containing all of the Level's custom values.

Callback triggered when a Decal layer is found after calling load() on a Level. The first argument is an Array holding the Layer's Decal Definitions. The second argument is the Layer Definition itself.

k triggered when an Entity layer is found after calling load() on a Level. The first argument is an Array holding the Layer's Entity Definitions. The second argument is the Layer Definition itself.

Callback triggered when a Grid layer exported with a 1D Data Array is found after calling load() on a Level. The first argument is a 1D Array holding the Layer's Grid Data. The second argument is the Layer Definition itself.

Callback triggered when a Grid layer exported with a 2D Data Array is found after calling load() on a Level. The first argument is a 2D Array holding the Layer's Grid Data. The second argument is the Layer Definition itself.

Callback triggered when a Tile layer exported with a 1D Data Array containing Tile IDs is found after calling load() on a Level. The first argument is a 1D Array holding the Layer's Tile ID Data. The second argument is the Layer Definition itself.

Callback triggered when a Tile layer exported with a 2D Data Array containing Tile IDs is found after calling load() on a Level. The first argument is a 2D Array holding the Layer's Tile ID Data. The second argument is the Layer Definition itself.

Callback triggered when a Tile layer exported with a 2D Data Array containing Tile Coords is found after calling load() on a Level. The first argument is a 2D Array holding the Layer's Tile Cordinate Data. The second argument is the Layer Definition itself.

Callback triggered when a Tile layer exported with a 3D Data Array containing Tile Coords is found after calling load() on a Level. The first argument is a 3D Array holding the Layer's Tile Coords Data. The second argument is the Layer Definition itself.

Loops through all layers, triggering each layer's callback if defined on this Level. Available Callbacks:

  • onTileLayerLoaded
  • onTile2DLayerLoaded
  • onTileCoordsLayerLoaded
  • onTileCoords2DLayerLoaded
  • onDecalLayerLoaded
  • onEntityLayerLoaded
  • onGridLayerLoaded
  • onGrid2DLayerLoaded

Creates a Level with .json data from Ogmo.

  • Signature: static load(Path:String) -> Level
  • Parameter path: Path string holding Ogmo Level Json data.
  • Returns: Level parsed from Json.

API


API


API

  • Signature: label: String
  • Signature: points: [Point]

API

  • Signature: color: Color

Data structure value for level, layers, entity

API

Name of the Value Template.

Definition of the Value Template.

Default value(s) for the Value Template.

Flag to set if the value is bounded with a min/max. Only available for Int and Float Value Templates.

Minimum value of a Float or Int. Only available for Int and Float Value Templates.

Maximum value of a Float or Int. Only available for Int and Float Value Templates.

Maximum length of a String. Only available for String Value Template.

Flag to set whether to remove whitespace from a String. Only available for String Value Template.

Available options of an Enum. Only available for Enum Value Template.

Flag to get whether to include the Alpha component on a Color. Only available for Color Value Template.


API

Name of the Layer Template.

Definition of the Layer Template.

Size of each cell in the Layer's Grid.

Unique Export ID of the Layer.

Enum to determine whether a Tile Layer exports it's Tile Data with IDs or Coords. Only available for Tile Layers.

Enum to determine whether a Tile or Grid Layer exports it's Data as a 1D Array or a 2D Array. Only available for Tile and Grid Layers.

Name of this Layer's default Tilemap. Only available for Tile Layers.

String Map describing a Grid Layers available Grid Cells. Only available for Grid Layers.

Array of Entity Tags that filters out any Entities that DO NOT have any of the Tags described. Only available for Entity Layers.

Array of Entity Tags that filters out any Entities that DO have any of the Tags described. Only available for Entity Layers.

Directory to search for Decal images. Only available for Decal Layers.

Flag to set whether image sequences are included as available Decals. Only available for Decal Layers.

Flag to set whether Decals on this layer are scaleable. Only available for Decal Layers.

Flag to set whether Decals on this layer are rotatable. Only available for Decal Layers.

Array of Value Templates for a Decal Layer. Only available for Decal Layers.


API


API

Name of the Tileset.

Path to the Tileset image, relative to the Project's path.

Base64 version of the Tileset image.

Width of a Tile in this Tileset.

Height of a Tile in this Tileset.

Size object of a tile

Empty pixels that separate each Tile on the X axis in this Tileset image.

Empty pixels that separate each Tile on the Y axis in this Tileset image.

Point object of a tile


API

flippedX and flippedY as a Point instance

  • Example: flipped.x, flipped.y

API

Clone this wiki locally