kts.Graphic – create a new Graphic
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)
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. For the time being, this must refer to a file in the knights_data/client/std_files/ folder. Only alphanumeric characters, underscores and dots are allowed.
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.
The return value is the newly created Graphic (a Lua userdata object).
Errors can occur if the input parameters are incorrect or invalid.
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.
Currently only graphics shipped with the game (in the std_files folder) can be loaded. This prevents mods from including their own graphics. A future version of Knights will rectify this by allowing mods to load graphics from their own directory (or from other mods that they "depend" on).