world
Everything in the level: the top of the Explorer. A thing is reached by its name: world.Door, world["My block"] for a name with a space, and world.House.Door for one inside another. With two of one name, the first one put there. One named like a word of world's own (raycast, name) is found with world:find. Like a thing, it has inside, find, waitFor and the rest.
world:raycastfunction
world:raycast(x: number, y: number, dx: number, dy: number, options: table or nil): hit or nilLooks along a line from x, y, going dx across and dy down (how far, not where to end), and gives the first thing in the way, or nil. Options: only, except, and kind (cat.Kind.object, cat.Kind.hazard, cat.Kind.solid, cat.Kind.floor, cat.Kind.text or cat.Kind.any). The page Raycasting shows how to use it.
| Value | Type | |
|---|---|---|
x | number | |
y | number | |
dx | number | |
dy | number | |
options | table or nil | May be left out. |
Gives: table or nil.
world:thingsInBoxfunction
world:thingsInBox(x: number, y: number, width: number, height: number, options: table or nil): list of thingA list of the things that touch a box whose middle is at x, y. Options as for world:raycast, and rotation (degrees the box is turned) and max (how many at most, 200 unless you say).
| Value | Type | |
|---|---|---|
x | number | |
y | number | |
width | number | |
height | number | |
options | table or nil | May be left out. |
Gives: list of thing.
world:thingsInCirclefunction
world:thingsInCircle(x: number, y: number, radius: number, options: table or nil): list of thingA list of the things that touch a circle round x, y. Options as for world:thingsInBox.
| Value | Type | |
|---|---|---|
x | number | |
y | number | |
radius | number | |
options | table or nil | May be left out. |
Gives: list of thing.
world:thingsInfunction
world:thingsIn(thing: thing, options: table or nil): list of thingA list of the things that touch a thing (its hitbox), without the thing itself. Options as for world:thingsInBox.
| Value | Type | |
|---|---|---|
thing | thing | |
options | table or nil | May be left out. |
Gives: list of thing.
world.namefunction
world.name: string"world".
world.pathfunction
world.path: string"world": where every path starts.
world.holderfunction
world.holder: nilAlways nil: world is in nothing.
world.existsfunction
world.exists: booleanAlways true.
world:insidefunction
world:inside(search: string or table or nil): list of thingA list of what is at the top, in the Explorer's order. A search works as in thing:inside.
| Value | Type | |
|---|---|---|
search | string or table or nil | May be left out. |
Gives: list of thing.
world:allInsidefunction
world:allInside(search: string or table or nil): list of thingA list of every thing in the level, in the Explorer's order. A search finds only some: world:allInside({ kind = cat.Kind.text }).
| Value | Type | |
|---|---|---|
search | string or table or nil | May be left out. |
Gives: list of thing.
world:findfunction
world:find(search: string or table, deep: boolean or nil): thing or nilThe first thing at the top that the search finds, or nil. With deep true: the first anywhere. It also finds a thing named like one of world's own words (raycast, name). A search needs a name, kind or tag.
| Value | Type | |
|---|---|---|
search | string or table | |
deep | boolean or nil | May be left out. |
Gives: thing or nil.
world:findHolderfunction
world:findHolder(search: string or table): nilAlways nil: world is in nothing.
| Value | Type | |
|---|---|---|
search | string or table |
Gives: nil.
world:holdsfunction
world:holds(other: thing): booleanIs the other thing still there? Every thing is in world.
| Value | Type | |
|---|---|---|
other | thing |
Gives: boolean.
world:isInfunction
world:isIn(other: thing or world): booleanAlways false.
| Value | Type | |
|---|---|---|
other | thing or world |
Gives: boolean.
world:waitForfunction
world:waitFor(name: string, seconds: number or nil): thing or nilThe thing at the top with that name. If there is none yet, it waits until one is put there, or until the seconds are up (then nil; 0 only looks). It doesn't look deeper: world:find(name, true) does.
| Value | Type | |
|---|---|---|
name | string | |
seconds | number or nil | May be left out. |
Gives: thing or nil.
world:clearInsidefunction
world:clearInside()Destroys every thing in the level.
world.thingAddedfunction
world.thingAdded: eventAn event that happens when a thing is put at the top: moved there, or made there (things.new).
A function joined to it is given:
thing(thing): the thing put at the top
world.thingAdded:connect(function(thing)
-- ...
end)world.thingRemovedfunction
world.thingRemoved: eventAn event that happens when a thing at the top leaves it: moved into another, or gone for good.
A function joined to it is given:
thing(thing): the thing that left
world.thingRemoved:connect(function(thing)
-- ...
end)world.addedInsidefunction
world.addedInside: eventAn event that happens when a thing is put anywhere: made, or moved. Every move is heard as removingInside, then addedInside.
A function joined to it is given:
thing(thing): the thing
world.addedInside:connect(function(thing)
-- ...
end)world.removingInsidefunction
world.removingInside: eventAn event that happens just before a thing goes for good or is moved (then addedInside follows). It can still be read here.
A function joined to it is given:
thing(thing): the thing
world.removingInside:connect(function(thing)
-- ...
end)world.holderChangedfunction
world.holderChanged: eventNever happens: world never moves. Every thing has this event, so world has it too.
world:nearestfunction
world:nearest(x: number, y: number, options: table or nil): found or nilThe thing nearest to a place: a table with thing, distance, and x, y (the nearest point of it), or nil. Options as for world:raycast, and within (how far to look, in tiles). The kind cat.Kind.water finds the nearest place with no floor.
| Value | Type | |
|---|---|---|
x | number | |
y | number | |
options | table or nil | May be left out. |
Gives: table or nil.