-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlevel.lua
More file actions
132 lines (115 loc) · 7.63 KB
/
level.lua
File metadata and controls
132 lines (115 loc) · 7.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
--- Level related variables and functions.
...
--- The left-most boundary of the level. No blocks exist beyond those coordinates. The player will be safetied if they travel too far beyond these bounds. Read-only.
minX = 0
--- The right-most boundary of the level. No blocks exist beyond those coordinates. The player will be safetied if they travel too far beyond these bounds. Read-only.
maxX = 0
--- The top-most boundary of the level. No blocks exist beyond those coordinates. The player will be safetied if they travel too far beyond these bounds. Read-only.
minY = 0
--- The bottom-most boundary of the level. No blocks exist beyond those coordinates. The player will be safetied if they travel too far beyond these bounds. Read-only.
maxY = 0
--- Finds a block in the specific coordinates.
--- @tparam int x The absolute x position.
--- @tparam int y The absolute y position.
--- @treturn block Returns the found block, or nil if not found.
function getBlockAt(x, y)
end
--- Gets a list of all blocks existing in the level.
--- @return An AS3 array of all blocks in the level.
--- @see @{utils.totable|totable}
--- @usage local blocks = totable(game.level.getAllBlocks())
---- for i, v in pairs(blocks) do
---- v.setmetatable("index", i)
---- end
function getAllBlocks()
end
--- Given the coordinates of two blocks, turn all blocks in the level of each type into the other.
--- @tparam int x1 The absolute x position of the first block.
--- @tparam int y1 The absolute y position of the first block.
--- @tparam int x2 The absolute x position of the second block.
--- @tparam int y2 The absolute y position of the second block.
function switchblocks(x1, y1, x2, y2)
end
--- Summons a (client-sided) alien.
--- @tparam float speed The multiplier to apply to the alien's movement speed. By default 1.
--- @tparam float seed The seed number for the alien's pseudorandom number generator, which generates its behavior. A random seed will be generated if none is provided.
--- @param vars An AS3 object containing the parameters for the alien's behavior. By default nil. All fields listed in the alien module (except alienspeed) can be set via this vars object.
--- @treturn alien The summoned alien as an object. Can be used to get and set its x and y position, among other things.
--- @see alien
--- @usage local funnyAlien = game.level.newAlien(1, os.time(), toobject{damage = 9999})
----funnyAlien.x, funnyAlien.y = 0, 0
function newAlien(speed, seed, vars)
end
--- Removes all Lua-created aliens from the client.
function removeAllAliens()
end
--- Creates a (client-sided) `artlayer`, which can be drawn to via Lua, and have `sprite`s and `stamp`s applied to it. This function fails and returns nil if the player has backgrounds disabled in their settings.
--- @tparam float depth The depth of the art layer. By default 1.
--- @tparam int layerNum The layerNum of the art layer (equivalent to the ">" icon in Level Editor). By default 1. Greater layerNum layers are drawn above lesser layerNum layers, regardless of layer depth. layerNums of 2 or greater draw above blocks. 3 or greater draws above players, hats, projectiles, and other visual effects.
--- @treturn artlayer The new art layer, or nil if the player has backgrounds disabled in their settings.
--- @see artlayer
--- @usage local layer = tolua(game.level.newArtLayer(1, 3))
---- if layer then
---- layer.drawStamp(someStamp)
---- end
function newArtLayer(depth, layerNum)
end
--- Destroys all Lua-created art layers.
function destroyAllArtLayers()
end
--- Creates a new raster-graphics `stamp`, which can be drawn to via Lua, and be applied to `artlayer`s and other `stamp`s. This function fails and returns nil if the player has backgrounds disabled in their settings or if the given width and/or height were invalid.
---
--- "Raster graphics" refers to pixel data. Stamps are used for directly storing and manipulating pixel data before drawing to an `artlayer`, rather than performing the more artsy operations you'd find on a `sprite`.
--- Stamps are also used for certain sorts of effects that don't map well to vector graphics, such as perlin noise.
---
--- An example use case is to draw some pixel data and then draw it to an art layer with some translation, scaling, and/or rotation applied. Another example use case would be to draw the same pixels to multiple art layers. Instead of repeating the same draw operations for each layer, you can perform the operations to one stamp, and then draw the stamp to each layer.
--- @tparam int width The width of the stamp in pixels. By default 64. This value is clamped to the range of 1-1024.
--- @tparam int height The height of the stamp in pixels. By default 64. This value is clamped to the range of 1-1024.
--- @tparam boolean smoothing Whether the stamp will be smoothed when scaled and rotated or not. By default false.
--- @treturn stamp The new stamp, or nil if the player has backgrounds disabled in their settings.
--- @see stamp
--- @usage local stamp = tolua(game.level.newStamp(500, 500))
---- if stamp then
---- stamp.setRect(0, 0, 500, 500, 0xFF000000)
---- someLayer.drawStamp(stamp)
---- end
function newStamp(width, height, smoothing)
end
--- Destroys all Lua-created stamps. Does not undraw any stamps already drawn to any existing art layers.
function destroyAllStamps()
end
--- Creates a new vector-graphics `sprite`, which can be drawn to via Lua, and be applied to `artlayer`s and other `stamp`s. This function fails and returns nil if the player has backgrounds disabled in their settings.
---
--- "Vector graphics" refers to artsy shape data, such as lines, circles, gradients, text, etc. The functions available to a sprite are very similar to drawing tools you'd find in an art program or in the Level Editor / Block Editor. This contrasts to the raw data-driven manipulations available for a `stamp`.
---
--- A sprite may also be set as the "parent" of other display objects, meaning that they will also be rendered whenever the sprite is rendered to an art layer, and with the same transformations as the sprite.
--- @treturn sprite The new sprite, or nil if the player has backgrounds disabled in their settings.
--- @see sprite
--- @usage local sprite = tolua(game.level.newSprite())
---- if sprite then
---- sprite.beginFill(0xFF000000) -- Draw everything with a solid, fully opaque black.
---- sprite.drawCircle(0, 0, 250)
---- sprite.endFill()
---- someLayer.drawSprite(sprite)
---- end
function newSprite()
end
--- Destroys all Lua-created sprites. Does not undraw any sprites already rendered to any existing art layers or stamps.
function destroyAllSprites()
end
--- Creates a new text field, which can contain text, and be applied to `artlayer`s and `stamps`. This function fails and returns nil if the player has backgrounds disabled in their settings.
---
--- An example use case is for dynamic text: a text field can be added as a child of a sprite with background, and then drawn as part of a UI or such.
--- @tparam string text The text that the text field starts out with.
--- @tparam int size The size of the text in the text field.
--- @tparam int color The color of the text in the text field.
--- @param vars An AS3 object containing other variables to provide to the text field, see the text field page for reference.
--- @treturn textfield The new text field, or nil if the player has backgrounds disabled in their settings.
--- @see textfield
--- @usage local textField = tolua(game.level.newTextField("Awesome Text", 24, 0x80FFCC))
---- someLayer.drawTextField(text)
function newTextField(text, size, color, vars)
end
--- Destroys all Lua-created text fields. Does not undraw any text fields already rendered to any existing art layers or stamps.
function destroyAllTextFields()
end