Set game objects
Aus EnigmaWiki
Available languages: Deutsch, English, Русский
Inhaltsverzeichnis
|
Now we'll learn how all the game objects can be used in the virtual world of enigma.
We assume that the level author has already written a level framework and the world has already been created.
Set floors
Floors can be laid in the following ways:
A single floor plate
set_floor(objectname, x, y [,attributes])
Synopsis: objectreference = set_floor(objectname, int, int, attributelist)
Description:
This function sets a floor objectname at the position x,y. Optionally it is possible to assign attributes attribute to the floor. These attributes must be assigned using a list {attribute1=value, attribute2=value, ...}.
Example:
set_floor("fl-tigris", 5, 10) set_floor("fl-bluegray", 1, 1, {name="bluegray"}) function setup_gradient_rose(x,y) set_floor("fl-gradient", x, y+1, {type=1}) set_floor("fl-gradient", x, y-1, {type=2}) set_floor("fl-gradient", x+1, y, {type=3}) set_floor("fl-gradient", x-1, y, {type=4}) end
Fill rectangular space with floor
fill_floor(objectname, x, y, w, h)
Synopsis: nil = fill_floor(objectname, int, int, int, int)
Description:
Fills a rectangle starting at the top left corner x,y and with the width w,h using the floor objectname.
Example:
fill_floor("fl-space", 0,0, level_width,level_height) -- these two lines fill_floor("fl-space") -- do the same fill_floor("fl-gray", 1, 1, level_width-2, level_height-2) fill_floor("fl-water", 24,47, 11,1)
Lay a floor plate line
draw_floor(objectname, {x, y}, {xstep, ystep}, n[, attributes])
Synopsis: nil = draw_floor(objectname, coordinates, table, int, attributelist)
Description:
Draws a line of floor plates starting at x,y with the inclination xstep,ystep and the length n.
Example:
draw_floor("fl-abyss", {3,0}, {0,1}, level_height) draw_floor("fl-gradient", {15, 5}, {1,0}, 4, {type=1}) draw_floor("fl-water", {level_width-4,3}, {0,1}, level_height-6)
Checkerboard floor
draw_checkerboard_floor(objectname1, objectname2, x, y, w, h[, attributes])
Synopsis: nil = draw_checkerboard_floor(objectname, objectname, int, int, int, int, attributelist)
Description:
Draws a checkerboard with the floor plates objectname1 and objectname2 starting at the top left corner x, y with the width w and the height h.
Example:
draw_checkerboard_floor("fl-abyss", "fl-rough", 2, 2, 23, 11) draw_checkerboard_floor("fl-normal", "fl-inverse", 0, 0, levelw, levelh)
Set stones
Stones can be set in the following ways:
Set a single stone
set_stone(objectname, x, y[, attributes])
Synopsis: objectreference = set_stone(objectname, int, int, attributelist)
Description:
This function sets a stone objectname at the position x,y. Optionally it is possible to assign attributes attribute to the stone. These attributes must be assigned using a list {attribute1=value, attribute2=value, ...}.
Example:
set_stone("st-yellow", 5, 10) set_stone("st-glass", 1, 1, {name="glasstein"}) set_stone("st-door", 18, 6, {name="door01", type="h"}) set_stone("st-bolder", 2, 11, {name="bolder01", direction=NORTH})
Fill rectangular space with stones
fill_stones(objectname, x, y, w, h)
Synopsis: nil = fill_stones(objectname, int, int, int, int)
Description:
Fills a rectangle starting at the top left corner x,y and with the width w,h using the stone objectname.
Example:
fill_stones("st-chameleon", 1, 1, 18, 11) fill_stones("st-grate1", 1, 5, 5, 7) fill_stones("st-death", 9, 5, 2, 2)
Set a line of stones
draw_stones(objectname, {x, y}, {xstep, ystep}, n[, attributes])
Synopsis: nil = draw_stones(objectname, coordinates, [[table]], int, attributelist)
Description:
Draws a line of stones starting at x,y with the inclination xstep,ystep and the length n.
Example:
draw_stones("st-grate1", {9,1},{0,1}, 5) draw_stones("st-stone_break", {21,1}, {1,0}, 10) function draw_border(stonename, x0, y0, w, h) draw_stones(stonename, {x0,y0}, {1,0}, w) draw_stones(stonename, {x0,y0+h-1},{1,0}, w) draw_stones(stonename, {x0,y0}, {0,1}, h) draw_stones(stonename, {x0+w-1,y0},{0,1}, h) end
Frame made of stones
draw_border(objectname[, x[, y[, w[, h]]]])
Synopsis: nil = draw_border(objectname, int, int, int, int)
Description:
Draws a border with the stone objectname. Optionally it is possible to set the coordinates of the top left corner x and y, the width w and theheight h. Omitting the optional arguments a border around the whole level is drawn.
Example:
draw_border("st-marble") draw_border("st-greenbrown", 0,5,3,3)
Several individual stones simultaneously
set_stones(objectname, positionlist[, attributes])
Synopsis: nil = set_stones(objectname, table with coordinates, attributelist)
Description:
The argument positionlist is a list containing lists of x- and y-coordinates. This method is suited for setting a large number of the same stones at randomly ordered places. Optionally it is possible to assign attributes attribute to the stone. These attributes must be assigned using a list {attribute1=value, attribute2=value, ...}.
Example:
set_stones("st-glass", {{1,6},{1,12},{34,1},{34,2},{35,2},{36,1},{36,2}}) set_stones(bordertile, {{34, 1}, {34, 5}, {34, 7}, {34, 11}}) ... set_stones("st-invisible", {{7,9}}) -- these two lines set_stone("st-invisible", 7, 9) -- do the same
Set Items
Items can be set in the following ways:
Set a single item
set_item(objectname, x, y[, attributes])
Synopsis: objectreference = set_item(objectname, int, int, attributelist)
Description:
This function sets an item objectname at the position x,y. Optionally it is possible to assign attributes attribute to the item. These attributes must be assigned using a list {attribute1=value, attribute2=value, ...}.
Example:
set_item("it-trigger", 34, 3, {action="openclose", target="bridge1"})
Fill rectangular space with items
fill_items(objectname, x, y, w, h)
Synopsis: nil = fill_items(objectname, int, int, int, int)
Description:
Fills a rectangle starting at the top left corner x,y and with the width w,h using the item objectname.
Example:
fill_items("it-wormhole", 1, 1, 3, 3) -- field of 3x3 wormholes
Draw a line of items
draw_items(objectname, {x, y}, {xstep, ystep}, n[ ,attributes])
Synopsis: nil = draw_items(objectname, coordinates, table, int, attributelist)
Description:
Draws a line of items starting at x,y with the inclination xstep,ystep and the length n.
Example:
draw_items("it-trigger", {3,3}, {2,0}, 8) draw_items("it-tinyhill", {5,3}, {2,0}, 7)
Set actors
set_actor(objectname, x, y [, attributes])
Synopsis: objectreference = set_actor(objectname, float, float, attributelist)
Description:
Sets an actor objectname at the position x,y (coordinates of the center of the ball). Optionally it is possible to assign attributes attribute to the actor. These attributes must be assigned using a list {attribute1=value, attribute2=value, ...}. The function has the alias SetActor(objectname, x, y [, attribute]).
Example:
set_actor("ac-bug", 5, 10) set_actor("ac-blackball", 1, 1, {player=0, mouseforce=1.5})

