Luawe All pages

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 nil

Looks 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.

ValueType
xnumber
ynumber
dxnumber
dynumber
optionstable or nilMay 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 thing

A 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).

ValueType
xnumber
ynumber
widthnumber
heightnumber
optionstable or nilMay be left out.

Gives: list of thing.

world:thingsInCirclefunction

world:thingsInCircle(x: number, y: number, radius: number, options: table or nil): list of thing

A list of the things that touch a circle round x, y. Options as for world:thingsInBox.

ValueType
xnumber
ynumber
radiusnumber
optionstable or nilMay be left out.

Gives: list of thing.

world:thingsInfunction

world:thingsIn(thing: thing, options: table or nil): list of thing

A list of the things that touch a thing (its hitbox), without the thing itself. Options as for world:thingsInBox.

ValueType
thingthing
optionstable or nilMay 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: nil

Always nil: world is in nothing.

world.existsfunction

world.exists: boolean

Always true.

world:insidefunction

world:inside(search: string or table or nil): list of thing

A list of what is at the top, in the Explorer's order. A search works as in thing:inside.

ValueType
searchstring or table or nilMay be left out.

Gives: list of thing.

world:allInsidefunction

world:allInside(search: string or table or nil): list of thing

A list of every thing in the level, in the Explorer's order. A search finds only some: world:allInside({ kind = cat.Kind.text }).

ValueType
searchstring or table or nilMay be left out.

Gives: list of thing.

world:findfunction

world:find(search: string or table, deep: boolean or nil): thing or nil

The 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.

ValueType
searchstring or table
deepboolean or nilMay be left out.

Gives: thing or nil.

world:findHolderfunction

world:findHolder(search: string or table): nil

Always nil: world is in nothing.

ValueType
searchstring or table

Gives: nil.

world:holdsfunction

world:holds(other: thing): boolean

Is the other thing still there? Every thing is in world.

ValueType
otherthing

Gives: boolean.

world:isInfunction

world:isIn(other: thing or world): boolean

Always false.

ValueType
otherthing or world

Gives: boolean.

world:waitForfunction

world:waitFor(name: string, seconds: number or nil): thing or nil

The 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.

ValueType
namestring
secondsnumber or nilMay be left out.

Gives: thing or nil.

world:clearInsidefunction

world:clearInside()

Destroys every thing in the level.

world.thingAddedfunction

world.thingAdded: event

An 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: event

An 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: event

An 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:

world.addedInside:connect(function(thing)
    -- ...
end)

world.removingInsidefunction

world.removingInside: event

An 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:

world.removingInside:connect(function(thing)
    -- ...
end)

world.holderChangedfunction

world.holderChanged: event

Never 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 nil

The 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.

ValueType
xnumber
ynumber
optionstable or nilMay be left out.

Gives: table or nil.