暗黑战神Lua

思考并回答以下问题:

\server\scripts\common\public_config.lua

1
2
3
4
5
6
7
8
local cfg = 
{
MAP_TYPE_NORMAL = 0, --普通地图
MAP_TYPE_SPECIAL = 1, --副本地图
}

public_config = cfg
return public_config

\server\scripts\common\lua_util.lua

1
2
3
4
5
6
7
8
9
require "public_config"

local log_game_info = mogo.logInfo
local log_game_debug = mogo.logDebug
local log_game_error = mogo.logError
local log_game_warning = mogo.logWarning

lua_util = {}
lua_util.__index = lua_util

\server\scripts\cell\NPC.lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "lua_util"
require "SkillSystem"

local log_game_debug = lua_util.log_game_debug
local log_game_info = lua_util.log_name_info

NPC = {}
setmetatable(NPC, CellEntity)

--构造函数
function NPC:__ctor__()
log_name_debug("NPC.__ctor__", "id=%d", self:getId())

self.c_etype = public_config.ENTITY_TYPE_NPC
end

function NPC:onEnterSpace()
log_name_debug("NPC:onEnterSpace", "spaceId=%d", self:getSpaceId())

local sp = g_these_spaceloaders[self:getSpaceId()]
if sp then
sp.Register(self)
end
end
0%