local tpPosition = {x = 1090, y = 1150, z = 7}
local validPositions = {
{x = 1091, y = 1150, z = 7},
{x = 1192, y = 1150, z = 7}
}
local i = 1
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid == 0 then
return
end
local nextPosition = validPositions[i]
doRemoveItem(oldTeleport.uid)
doCreateTeleport(1387, nextPosition, tpPosition)
i = i % #validPositions + 1
end
help me what i must write at script.You can use a globalevent and use a table with positions and an initial position then you just use getTileItemByType(pos, ITEM_TYPE_TELEPORT) remove that old tp and create a new one in a new random position using doCreateTeleport(itemid, toPosition, fromPosition)
<globalevent name="teleporttime" interval="600000" event="script" value="teleporttime.lua"/>
help me what i must write at script.
globalevent:
teleporttime.lua:Code:<globalevent name="teleporttime" interval="600000" event="script" value="teleporttime.lua"/>
local currentPosition = {x = 100, y = 100, z = 7}
local validPositions = {currentPosition, {x = 200, y = 200, z = 7}}
local destination = {x = 300, y = 300, z = 7}
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(currentPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid ~= 0 then
doRemoveItem(oldTeleport.uid)
end
local randomPosition = validPositions[math.random(#validPositions)]
doCreateTeleport(1387, destination, randomPosition)
currentPosition = randomPosition
end
sorry i was make wrong description. Not teleport position. destination position changing every 10 min. Can you help with this?Lua:local currentPosition = {x = 100, y = 100, z = 7} local validPositions = {currentPosition, {x = 200, y = 200, z = 7}} local destination = {x = 300, y = 300, z = 7} function onThink(interval, lastExecution, thinkInterval) local oldTeleport = getTileItemByType(currentPosition, ITEM_TYPE_TELEPORT) if oldTeleport.uid ~= 0 then doRemoveItem(oldTeleport.uid) end local randomPosition = validPositions[math.random(#validPositions)] doCreateTeleport(1387, destination, randomPosition) currentPosition = randomPosition end
sorry i was make wrong description. Not teleport position. destination position changing every 10 min. Can you help with this?
local tpPosition = {x = 100, y = 100, z = 7}
local validPositions = {{x = 200, y = 200, z = 7}, {x = 300, y = 300, z = 7}}
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid == 0 then
return
end
doRemoveItem(oldTeleport.uid)
local randomPosition = validPositions[math.random(#validPositions)]
doCreateTeleport(1387, randomPosition, tpPosition)
end
07/02/2017 20:33:49] [Error - LuaScriptInterface::loadFile] ...ryingdamson 0.3.6 (8.60) V8.2/data/globalevents/scripts/teleporttime.lua:2: '}' expected near 'z'Lua:local tpPosition = {x = 100, y = 100, z = 7} local validPositions = {{x = 200, y = 200, z = 7}, {x = 300, y = 300, z = 7}} function onThink(interval, lastExecution, thinkInterval) local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT) if oldTeleport.uid == 0 then return end doRemoveItem(oldTeleport.uid) local randomPosition = validPositions[math.random(#validPositions)] doCreateTeleport(1387, randomPosition, tpPosition) end
You made it wrong when modifing the script, I can't help you if you don't post your modified version.07/02/2017 20:33:49] [Error - LuaScriptInterface::loadFile] ...ryingdamson 0.3.6 (8.60) V8.2/data/globalevents/scripts/teleporttime.lua:2: '}' expected near 'z'
[07/02/2017 20:33:49] [Warning - Event::loadScript] Cannot load script (D:/Game/tibia own server/new 8.6/cryingdamson 0.3.6 (8.60) V8.2/data/globalevents/scripts/teleporttime.lua)
[07/02/2017 20:33:49] ...ryingdamson 0.3.6 (8.60) V8.2/data/globalevents/scripts/teleporttime.lua:2: '}' expected near 'z'
have error. not work. Maybe someting wrong?
globalevents:You made it wrong when modifing the script, I can't help you if you don't post your modified version.
<globalevent name="teleporttime" interval="600000" event="script" value="teleporttime.lua"/>
local tpPosition = {x = 1090, y = 1150, z = 7}
local validPositions = {{x = 1091, y = 1150, z = 7}, {x = 1192, y = 1150, z = 7}}
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid == 0 then
return
end
doRemoveItem(oldTeleport.uid)
local randomPosition = validPositions[math.random(#validPositions)]
doCreateTeleport(1387, randomPosition, tpPosition)
end
globalevents:
scripts:Code:<globalevent name="teleporttime" interval="600000" event="script" value="teleporttime.lua"/>
Code:local tpPosition = {x = 1090, y = 1150, z = 7} local validPositions = {{x = 1091, y = 1150, z = 7}, {x = 1192, y = 1150, z = 7}} function onThink(interval, lastExecution, thinkInterval) local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT) if oldTeleport.uid == 0 then return end doRemoveItem(oldTeleport.uid) local randomPosition = validPositions[math.random(#validPositions)] doCreateTeleport(1387, randomPosition, tpPosition) end
i modifing script.
local tpPosition = {x = 1090, y = 1150, z = 7}
local validPositions = {
{x = 1091, y = 1150, z = 7},
{x = 1192, y = 1150, z = 7}
}
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid == 0 then
return
end
local randomPosition = validPositions[math.random(#validPositions)]
doRemoveItem(oldTeleport.uid)
doCreateTeleport(1387, randomPosition, tpPosition)
end
all work good. But i no need random position i need change position first then second and then third fourth fifth and sixth. After six will start first again.Tested the script online and there was no errors, try replacing it again and see if it works, I can't find any issues with it.
Lua:local tpPosition = {x = 1090, y = 1150, z = 7} local validPositions = { {x = 1091, y = 1150, z = 7}, {x = 1192, y = 1150, z = 7} } function onThink(interval, lastExecution, thinkInterval) local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT) if oldTeleport.uid == 0 then return end local randomPosition = validPositions[math.random(#validPositions)] doRemoveItem(oldTeleport.uid) doCreateTeleport(1387, randomPosition, tpPosition) end
Cleaned the table atleast xD
local tpPosition = {x = 1090, y = 1150, z = 7}
local validPositions = {
{x = 1091, y = 1150, z = 7},
{x = 1192, y = 1150, z = 7}
}
nextPosition = 1 -- table index
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid == 0 then
return
end
doRemoveItem(oldTeleport.uid)
doCreateTeleport(1387, validPositions[nextPosition], tpPosition)
nextPosition = (validPositions[nextPosition + 1] and nextPosition + 1) or 1
return true
end
all work good. But i no need random position i need change position first then second and then third fourth fifth and sixth. After six will start first again.
local tpPosition = {x = 1090, y = 1150, z = 7}
local teleportPositions = {
[1] = {x = 1091, y = 1150, z = 7},
[2] = {x = 1192, y = 1150, z = 7}
}
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid == 0 then
return
end
local storageValue = getGlobalStorageValue(13425)
local nextValue = storageValue
if nextValue == -1 then
nextValue = 1
else
nextValue = storageValue == #teleportPositions and 1 or storageValue + 1
end
setGlobalStorageValue(13425, nextValue)
doRemoveItem(oldTeleport.uid)
doCreateTeleport(1387, teleportPositions[nextValue], tpPosition)
end
local tpPosition = {x = 1090, y = 1150, z = 7}
local validPositions = {
{x = 1091, y = 1150, z = 7},
{x = 1192, y = 1150, z = 7}
}
local i = 1
function onThink(interval, lastExecution, thinkInterval)
local oldTeleport = getTileItemByType(tpPosition, ITEM_TYPE_TELEPORT)
if oldTeleport.uid == 0 then
return
end
local nextPosition = validPositions[i]
doRemoveItem(oldTeleport.uid)
doCreateTeleport(1387, nextPosition, tpPosition)
i = i % #validPositions + 1
end
Who is the winner?all work good thx!
meWho is the winner?
yes you, your script work perfect