kts.Graphic

Name

kts.Graphic – create a new Graphic

Synopsis

result = kts.Graphic(filename)

result = kts.Graphic(filename, r, g, b)

result = kts.Graphic(filename, r, g, b, x, y)

result = kts.Graphic(filename, r, g, b, x, y, size_num, size_denom)

Description

A "Graphic" represents a single graphic image (or sprite) used in the game.

Graphics are loaded from BMP files (other formats are not currently supported).

To create a Graphic, kts.Graphic is called. The first parameter is always the filename. This is specified relative to the directory of the currently executing Lua script.

If the r, g and b parameters are included (and set to values between 0 and 255), then the corresponding RGB colour is interpreted as a "transparency key" i.e. pixels of that exact colour will be considered transparent. (This is needed because the BMP format does not support transparency!)

If x and y are included then the "handle" position for the graphic is set to that location (relative to the top-left of the image).

If size_num and size_denom are included then the image will be scaled by the ratio size_num / size_denom before being displayed. (This is an experimental feature, and as far as I know, nothing is using it currently.)

Once a Graphic is created, it can be used for things like creating ItemTypes or Tiles, or several different Graphics can be assembled into an Anim or Overlay.

Return Value

The return value is the newly created Graphic (a Lua userdata object).

Errors

Errors can occur if the input parameters are incorrect or invalid.

Bugs

The correct values to use for the "handle position" parameters (x and y) are not particularly clear. Perhaps some kind of graphic/anim/overlay editor tool should be created.

See Also

kts.Anim

kts.Overlay