Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Tile.getThing

hjnilsson edited this page Jul 24, 2012 · 6 revisions

Returns the item at the index specified by the parameter.

[[Thing]] [[Tile]].getThing([[Integer]] index)

Return Value

Returns the item at the specified stackpos, or nil if there is no such item.

Parameters

  • Integer index - The index of the thing to retrieve, index is counted as follows, from the bottom of the tile.
    • Ground, if there is no ground, the next thing has index 0.

    • topItems, topItems are items with the ALWAYS_ON_TOP flag these include, but are not limited to walls, borders, rocks etc.

    • Creatures downItems, downItems are most moveable items, like weapons, books, torches etc.

    • A negative index means that the items are counted from the top of the tile instead. So -1 means the item ontop of the tile.

Examples

If the tile contains:

Index Item
0 dirt ground (id 103)
1 grass border (id 4550)
2 swamp plant (id 2776)
3 a rat
4 a fire sword (id 2393)
```lua -- 'tile' is the tile above
--The following returns the ground item
item = tile:getThing(0)
item:getItemID() -- returns 103
 
-- The following returns the rat
rat = tile:getThing(3)
rat:turn(NORTH) -- makes the rat face north
 
--The following returns the fire sword
fire_sword = tile:getThing(-1) -- -1 is the top item
fire_sword:getName() -- returns "fire sword"
Clone this wiki locally