Xadrian
Active Member
Więc tak, mam problem ze skryptem, w którym po wejściu na odpowiedni SQM powinien przesunąć kamień w odpowiednim kierunku.
Trochę danych:
Każdy z groundów na około gracza ma AID kolejno 8701, 8702, 8703, 8704 (zgodnie z wskazówkami zegara).
Kamień jak widać ma UID 34567.
Skrypt:
Błąd w konsoli:
Tak więc może mi ktoś poprawić skrypt, aby nie było tego błędu i działał poprawnie?
Trochę danych:
Każdy z groundów na około gracza ma AID kolejno 8701, 8702, 8703, 8704 (zgodnie z wskazówkami zegara).
Kamień jak widać ma UID 34567.
Skrypt:
LUA:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
local blueStonePos = getThingPos(34567)
local redStonePos = getThingPos(34568)
local firstPlayerPositions = {
[8701] = {blueStonePos.x, blueStonePos.y - 1},
[8702] = {blueStonePos.x + 1, blueStonePos.y},
[8703] = {blueStonePos.x, blueStonePos.y + 1},
[8704] = {blueStonePos.x - 1, blueStonePos.y},
}
local secondPlayerPositions = {
[8705] = {redStonePos.x, redStonePos.y - 1},
[8706] = {redStonePos.x + 1, redStonePos.y},
[8707] = {redStonePos.x, redStonePos.y + 1},
[8708] = {redStonePos.x - 1, redStonePos.y},
}
local newBlueStonePos = {
x = firstPlayerPositions[item.actionid][1],
y = firstPlayerPositions[item.actionid][2],
z = 7
}
local newRedStonePos = {
x = secondPlayerPositions[item.actionid][1],
y = secondPlayerPositions[item.actionid][2],
z = 7
}
-- Block creatures:
if(not isPlayer(cid)) then
return true
end
-- Player just logged in:
if(fromPosition.x == 0) then
fromPosition = getTownTemplePosition(getPlayerTown(cid))
doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
end
-- Script:
if(item.actionid == firstPlayerPositions[1]) then
doCreateItem(1354, 1, newBlueStonePos)
doRemoveItem(34567)
elseif(item.actionid == secondPlayerPositions[1]) then
doCreateItem(1355, 1, newRedStonePos)
doRemoveItem(34568)
end
doTeleportThing(cid, fromPosition, true)
return true
end
Błąd w konsoli:
Code:
[25/02/2010 21:06:52] [Error - MoveEvents Interface]
[25/02/2010 21:06:52] data/movements/scripts/game.lua:onStepIn
[25/02/2010 21:06:52] Description:
[25/02/2010 21:06:52] data/movements/scripts/game.lua:25: attempt to index field '?' (a nil value)
[25/02/2010 21:06:52] stack traceback:
[25/02/2010 21:06:52] data/movements/scripts/game.lua:25: in function <data/movements/scripts/game.lua:1>