代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/wesnoth 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
-- join.lua --
-- Try to join a game called "Test"
local function plugin()
local function log(text)
std_print("join: " .. text)
end
local counter = 0
local events, context, info
local function find_test_game(game_info)
local g = game_info.game_list()
if g then
local gamelist = wml.get_child(g, "gamelist")
if gamelist then
for i = 1, #gamelist do
local t = gamelist[i]
if t[1] == "game" then
local game = t[2]
if game.scenario == "Test" then
return game.id
end
end
end
end
end
return nil
end
local function idle_text(text)
counter = counter + 1
if counter >= 100 then
counter = 0
log("idling " .. text)
end
end
log("hello world")
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for titlescreen or lobby")
until info.name == "titlescreen" or info.name == "Multiplayer Lobby"
local tries = 0
while info.name == "titlescreen" and tries < 100 do
context.play_multiplayer({})
tries = tries + 1
log("playing multiplayer...")
events, context, info = coroutine.yield()
end
if info.name == "titlescreen" then
context.exit({code = 1})
coroutine.yield()
end
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for lobby")
until info.name == "Multiplayer Lobby"
events, context, info = coroutine.yield()
context.chat({message = "waiting for test game to join..."})
local test_game = nil
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for test game")
for i,v in ipairs(events) do
if v[1] == "chat" then
std_print("chat:", v[2].message)
end
end
test_game = find_test_game(info)
until test_game
log("found a test game, joining... id = " .. test_game)
context.chat({message = "found test game"})
context.select_game({id = test_game})
events, context, info = coroutine.yield()
context.chat({message = "going to join"})
context.join({})
events, context, info = coroutine.yield()
-- Don't know why THIS context has to chat member but it doesn't
-- Adding the guard if to bypass a script crash and get mp_tests running.
-- GAL 28NOV2017
if context.chat then
context.chat({message = "done first join"})
end
while not (info.name == "Dialog" or info.name == "Multiplayer Join") do
if context.join then
context.join({})
else
std_print("did not find join...")
end
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for leader select dialog")
end
if info.name == "Dialog" then
log("got a leader select dialog...")
context.skip_dialog({})
events, context, info = coroutine.yield()
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for mp join")
until info.name == "Multiplayer Join"
end
log("got to multiplayer join...")
context.chat({message = "ready"})
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for game")
until info.name == "Game"
log("got to a game context...")
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for the last scenario")
until info.scenario_name ~= nil and info.scenario_name().scenario_name == "Multiplayer Unit Test test2"
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for not game")
until info.name ~= "Game"
log("left a game context...")
repeat
context.quit({})
log("quitting a " .. info.name .. " context...")
events, context, info = coroutine.yield()
until info.name == "titlescreen"
context.exit({code = 0})
coroutine.yield()
end
return plugin
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。