2 -- This script is executed every time an Entity finishes walking onto a tile.
4 -- We are called from within Entity::postMove() in entity.cpp. There, we are
5 -- passed some game data. We pass three variables to this script from the
6 -- Entity object: x, y, and entity, which represents the Entity itself.
8 -- We also have a C function we can call, gotoRandomTile, which takes an Entity
9 -- object as a parameter.
12 -- Returns true if we are standing on the specified X,Y location.
14 return x
== X
and y
== Y
17 -- Returns true if we are standing on any of the specified locations.
18 function onAny(locations
)
19 for _
,loc
in ipairs(locations
) do
20 if on(loc
.x
, loc
.y
) then
27 local redPortalLocations
= {
32 -- The red portals teleport us! *gasp* Excitement!
33 if onAny(redPortalLocations
) then
34 print("Lua says: Teleported!")
35 entity
:gotoRandomTile()