tile.lua

main 56 lines · 1.1 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1function Tile.isCreature(self)
2 return false
3end
4
5function Tile.isItem(self)
6 return false
7end
8
9function Tile.isTile(self)
10 return true
11end
12
13function Tile.isContainer(self)
14 return false
15end
16
17function Tile.relocateTo(self, toPosition)
18 if self:getPosition() == toPosition or not Tile(toPosition) then
19 return false
20 end
21
22 for i = self:getThingCount() - 1, 0, -1 do
23 local thing = self:getThing(i)
24 if thing then
25 if thing:isItem() then
26 if thing:getFluidType() ~= 0 then
27 thing:remove()
28 elseif ItemType(thing:getId()):isMovable() then
29 thing:moveTo(toPosition)
30 end
31 elseif thing:isCreature() then
32 thing:teleportTo(toPosition)
33 end
34 end
35 end
36
37 return true
38end
39
40function Tile.isWalkable(self)
41 local ground = self:getGround()
42 if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
43 return false
44 end
45
46 local items = self:getItems()
47 for i = 1, self:getItemCount() do
48 local item = items[i]
49 local itemType = item:getType()
50 if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
51 return false
52 end
53 end
54 return true
55end
56
Top