RunState: LUA_ERROR: [string "devils_catacomb"]:1: 尝试调用字段 `get_devil_base'(空值)

嗨,我的英语不太好,我有一个问题

ERROR

SYSERR:Apr 11 14:16:12 :: RunState: LUA_ERROR: [string "devils_catacomb"]:1: 尝试调用字段 `get_devil_base'(空值)
SYSERR:Apr 11 14:16:12 :: WriteRunningStateToSyserr: LUA_ERROR: quest >devils_catacomb.start click
SYSERR:Apr 11 14:12:32 :: RunState: LUA_ERROR: >locale/turkey/quest/object/state/deviltower_zone:1: 尝试对全局变量`positions'进行索引(空值)
SYSERR:Apr 11 14:12:32 :: WriteRunningStateToSyserr: LUA_ERROR: quest >deviltower_zone.start click

我的 deviltower_zone.lua

//////// 错误的位置 /////////

function get_4floor_stone_pos()
    local positions, j, t = {{368, 629}, {419, 630}, {428, 653}, {422, 679},
{395, 689}, {369, 679}, {361, 658},}, number(i,7), positions[i];
    for i = 1, 6 do
        if (i != j) then
            local t = positions[i];
            positions[i] = positions[j];
            positions[j] = t;
        end
    end
    return positions
end

when 8016.kill with pc.get_map_index() >= 660000 and pc.get_map_index() <
670000 begin
    d.setf("level", 4)
    local positions, vid = deviltower_zone.get_4floor_stone_pos()
,d.spawn_mob(8017, positions[7][1], positions[7][2])
    for i = 1, 6 do d.set_unique("fake" .. i , d.spawn_mob(8017,
positions[i][1], positions[i][2])) end
    d.set_unique("real", vid)
    server_loop_timer('devil_stone4_update', 10, pc.get_map_index())
    server_timer('devil_stone4_fail1', 5*60, pc.get_map_index())
    notice_multiline(gameforge.deviltower_zone._50_dNotice,d.notice)

end
点赞
用户2805065
用户2805065

有几个地方你在归属中使用了右侧 positions 表中的 local positions。在 Lua 中,左侧在右侧之前总是进行完全评估,因此在这种情况下,positions 指的是全局变量。

第一次出现:在这一行中:

local positions,j,t = {{368, 629}, {419, 630}, {428, 653}, {422, 679}, {395, 689}, {369, 679}, {361, 658},},number(i,7), positions[i];

你可能是想这样做:

local positions = {{368, 629}, {419, 630}, {428, 653}, {422, 679}, {395, 689}, {369, 679}, {361, 658},}
local j, t = number(i,7), positions[i]

(虽然这不会 100% 生效,因为 i 还不存在,最好不要使用 t 变量。)

而在这一行:

local positions,vid = deviltower_zone.get_4floor_stone_pos(), d.spawn_mob(8017, positions[7][1], positions[7][2])

你可能是想这样做:

local positions = deviltower_zone.get_4floor_stone_pos()
local vid = d.spawn_mob(8017, positions[7][1], positions[7][2])
2017-04-11 14:25:06