leozynho123
Member
- Joined
- Sep 14, 2014
- Messages
- 128
- Reaction score
- 8
Good evening, I'm having a problem with movements, could anyone help me with this problem with the getTile function
try replaceSorry, but I could not understand, my friend.
Please provide code.
function onStepIn(creature, item, position, fromPosition)
item:transform(425)
if item.actionid == 30049 then
local new_position = Position(0, position.y, position.z)
for i = 5, 0, -1 do
new_position.x = position.x + 2 + i
local tile = new_position:getTile()
if i == 5 then
new_position.x = position.x + 2
else
new_position.x = new_position.x + 1
end
local itemCount = tile:getDownItemCount()
if itemCount > 0 then
tile:getThing(tile:getTopItemCount() + tile:getCreatureCount() + itemCount):moveTo(new_position)
end
end
elseif item.actionid == 30050 then
local new_position = Position(position.x, 0, position.z)
for i = 5, 0, -1 do
new_position.y = position.y + 2 + i
local tile = new_position:getTile()
if i == 5 then
new_position.y = position.y + 2
else
new_position.y = new_position.y + 1
end
local itemCount = tile:getDownItemCount()
if itemCount > 0 then
tile:getThing(tile:getTopItemCount() + tile:getCreatureCount() + itemCount):moveTo(new_position)
end
end
end
return true
end
function onStepOut(creature, item, position, fromPosition)
item:transform(426)
return true
end
local new_position = Position(0, position.y, position.z)
Tile(x, y, z)
Tile(position)
isthe proper way to define a position in lua?Code:local new_position = Position(0, position.y, position.z)
Im not sure if you can getTile just from position, I can't see this lua function in unmodified tfs
@edit
a yeah, there are the constructors. As Xeraphus said use
Code:Tile(x, y, z) Tile(position)
try replaceSorry, but I could not understand, my friend.
try replace
local tile = new_position:getTile()
with
local tile = Tile(new_position)
local walls = {
Position(32760, 32288, 14),
Position(32761, 32288, 14),
Position(32762, 32288, 14),
Position(32763, 32288, 14),
Position(32764, 32288, 14),
Position(32764, 32289, 14),
Position(32764, 32290, 14),
Position(32764, 32291, 14),
Position(32764, 32292, 14),
Position(32763, 32292, 14),
Position(32762, 32292, 14),
Position(32761, 32292, 14),
Position(32760, 32292, 14),
Position(32760, 32291, 14),
Position(32760, 32290, 14),
Position(32760, 32289, 14)
}
function onStepIn(cid, item, position)
local player = creature:getPlayer()
if not player then
return true
end
for i = 1, #walls do
if Tile(walls[I]):hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID) then
player:teleportTo(Position(32762, 32305, 14))
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
end
player:teleportTo(Position(32852, 32287, 14))
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
if Tile(walls[I]):hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID) then
if Tile(walls[i]):hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID) then
function Position.getTile(self)
return Tile(self)
end
also change:
toLua:if Tile(walls[I]):hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID) then
Lua:if Tile(walls[i]):hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID) then
change
toLua:function onStepIn(cid, item, position)
Lua:function onStepIn(creature, item, position)
also change:
toLua:if Tile(walls[I]):hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID) then
Lua:if Tile(walls[i]):hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID) then
Actually, if you use more scripts from the same data pack you may encounter more errors. It's possible position:getTile() is used in more places, considering their data pack includes this function which you apparently don't have:
Lua:function Position.getTile(self) return Tile(self) end
In such case you should probably include that function in your server.
local config = {
{position = Position(32845, 32264, 14), itemId = 2639},
{position = Position(32843, 32266, 14), itemId = 2639},
{position = Position(32843, 32268, 14), itemId = 2639},
{position = Position(32845, 32268, 14), itemId = 2639},
{position = Position(32844, 32267, 14), itemId = 2639},
{position = Position(32840, 32269, 14), itemId = 2639},
{position = Position(32841, 32269, 14), itemId = 2638},
{position = Position(32840, 32268, 14), itemId = 2638},
{position = Position(32842, 32267, 14), itemId = 2638}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
item:transform(item.itemid == 1945 and 1946 or 1945)
if item.itemid == 1945 then
local pillar
for x = 32835, 32838 do
pillar = Tile(Position(x, 32285, 14)):getItemById(1515)
if pillar then
pillar:remove()
end
end
else
local position
for x = 32835, 32838 do
position = Position(x, 32285, 14)
if not Tile(position):getItemById(1515) then
Game.createItem(1515, 1, position)
end
end
end
local tokens, ticTacToeItem = true
for i = 1, #config do
ticTacToeItem = Tile(config[i].position):getItemById(config[i].itemId)
if not ticTacToeItem then
tokens = false
break
end
end
if not tokens then
return true
end
local position = Position(32836, 32288, 14)
if item.itemid == 1945 then
local crack = Tile(position):getItemById(6299)
if crack then
crack:transform(1387)
crack:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 31245)
end
else
local teleport = Tile(position):getItemById(1387)
if teleport then
teleport:transform(6299)
end
end
return true
end
Because there isn't definied funcion Position:getTile() in default tfs.Gave a certain friend, I just could not understand why it works this way and the other does not
use an action id instead of unique id
it's protected for a reason
crack:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 31245)