为azerothcore docker构建设置lua_scripts目录

问题描述

我正在运行AzerothCore服务器以通过LAN进行个人访问。我根据setup provided on the official website在docker上运行了服务器。我还设法通过AzerothCore GitHub上提供的module附加了Eluna lua。

调用docker-compose up之后收到此消息时,我看到Eluna已成功与worldserver一起编译:

ac-worldserver_1 | [Eluna]: Executed 0 Lua scripts in 0 ms

我也没有通过客户端登录并正常播放的问题。

现在,我遇到的问题是我似乎无法找到放置lua脚本的位置,以便服务器使用它们。浏览配置文件,我在azerothcore-wotlk/modules/mod-eluna-lua-engine/conf/mod_LuaEngine.conf.dist中找到了此参数:

Eluna.ScriptPath = "lua_scripts"

此常量已加载到主LuaEngine.cpp文件中,因此我确信这是查找的正确位置。但是,整个存储库(包括附带的模块)中没有lua_scripts目录。我尝试将它(和基本的hello_world.lua脚本)放置在多个子目录中无济于事。考虑到由于使用docker可能会在存储库之外找到它,我运行了sudo find / | grep lua_scripts在这个人迹罕至的位置找到了该文件夹的副本:

/var/snap/docker/common/var-lib-docker/overlay2/3d7f9d1de6602baf9a33ee24333ecdf01d537c2b7b439e90d645ff9643bfdd07/diff/azeroth-server/bin/lua_scripts

很明显,只能通过sudo访问此地址,我不能轻易地将此位置用于开发目的。

作为最后的选择,我尝试将Eluna.ScriptPath常量更改为存储库中的绝对路径,但这也没有成功。没有加载脚本,没有登录时的问候。有人知道我在哪里可以查找或放置目录吗?

hello_world.lua

local PLAYER_EVENT_ON_LOGIN = 3

local function OnLogin(event,player)
    player:SendbroadcastMessage("Hello world")
end

RegisterPlayerEvent(PLAYER_EVENT_ON_LOGIN,OnLogin)

解决方法

我通过添加绑定 from asyncio import run as arun from sys import argv from os import path,environ import subprocess from aiohttp import ClientSession from xbox.webapi.api.client import XboxLiveClient from xbox.webapi.authentication.manager import AuthenticationManager from xbox.webapi.authentication.models import OAuth2TokenResponse async def gamertags_to_xuids(gamertags,client_id=environ["client_id"],client_secret=environ["client_secret"],token_jar=path.join(environ["HOME"],".local","share","xbox","tokens.json")): assert len(gamertags) >= 1 global session auth_mgr = AuthenticationManager(session,client_id,client_secret,"") await freshen_tokens(auth_mgr,token_jar) xbl_client = XboxLiveClient(auth_mgr) ids = [] for gamertag in gamertags: profile = await xbl_client.profile.get_profile_by_gamertag(gamertag) ids.append(int(profile.profile_users[0].id)) xuids = [f"{id:016X}" for id in ids] return xuids async def freshen_tokens(auth_mgr,token_jar): with open(token_jar,"r+") as f: auth_mgr.oauth = OAuth2TokenResponse.parse_raw(f.read()) await auth_mgr.refresh_tokens() f.seek(0) f.truncate() f.write(auth_mgr.oauth.json()) async def amain(args): global session subprocess.run(["xbox-authenticate"],check=True)#TODO: avoid this system call async with ClientSession() as session: return await gamertags_to_xuids(args) def main(args=argv[1:]): return arun(amain(args)) if __name__ == '__main__': for xuid in main(): print(xuid) 文件夹中的 lua_scripts 来修复此问题

docker-compose.yml

- type: bind source: ./docker/worldserver/bin/lua_scripts target: /azeroth-server/bin/lua_scripts volumes 部分。我把它放在 docker-compose.yml 绑定下。

然后在 worldserver/bin 中设置 docker/worldserver/etc/mod_LuaEngine.conf 并将您的脚本放入 Eluna.ScriptPath = "/azeroth-server/bin/lua_scripts"

,

由于 docker-compose 返工(提交 380f406248bdc1f15227a7b2f8a75b4bf922f730),您应该能够更新您的 mod_LuaEngine.conf 文件以包括:

Eluna.ScriptPath = "/azerothcore/lua_scripts"

并在您的基本目录中创建一个 lua_scripts 文件夹(例如找到 docker.compose.yml 和 apps/ 文件夹的位置)。