• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Poprawka skryptu movements

Xadrian

Active Member
Joined
Feb 24, 2008
Messages
905
Reaction score
26
Location
Poland, Stalowa Wola
Więc tak, mam problem ze skryptem, w którym po wejściu na odpowiedni SQM powinien przesunąć kamień w odpowiednim kierunku.

Trochę danych:
2yu0g1w.png

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>
Tak więc może mi ktoś poprawić skrypt, aby nie było tego błędu i działał poprawnie?
 
PHP:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)

Sorry za offtopa, może się mylę, ale "actor" to powoduje. Nie widziałem nowego silnika więc nie wiem czy to to.
Code:
[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/[B]game.lua:1[/B]>
 
PHP:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
Sorry za offtopa, może się mylę, ale "actor" to powoduje. Nie widziałem nowego silnika więc nie wiem czy to to.
Code:
[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/[B]game.lua:1[/B]>
Nie, to nie może być to.
 
Tutaj sie odnosisz do tablicy 2-u wymiarowej:
Code:
        x = secondPlayerPositions[item.actionid][1],

A ona jest jedno :P
 
Code:
local newBlueStonePos = {
        x = firstPlayerPositions[item.actionid].blueStonePos.x,
        y = firstPlayerPositions[item.actionid].blueStonePos.y,
        z = 7
    }
 
W ogóle nie rozumiem sensu ten zmiany, w każdy razie nadal wywala błąd:
Code:
[25/02/2010 23:18:21] [Error - MoveEvents Interface] 
[25/02/2010 23:18:21] data/movements/scripts/game.lua:onStepIn
[25/02/2010 23:18:21] Description: 
[25/02/2010 23:18:21] data/movements/scripts/game.lua:19: attempt to index field 'blueStonePos' (a nil value)
[25/02/2010 23:18:21] stack traceback:
[25/02/2010 23:18:21]     data/movements/scripts/game.lua:19: in function <data/movements/scripts/game.lua:1>
 
Sry, musze leciec juz spac, ale sprobuj zobaczyc print(item.actionid).
 
Back
Top