mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-10-19 03:32:41 +00:00
Update Arena commands and add DNC API disable
This commit is contained in:
parent
1d039e6675
commit
4b62f9be25
1 changed files with 37 additions and 8 deletions
|
@ -43,7 +43,6 @@ local gGameLevels = {
|
||||||
_G.Arena = {
|
_G.Arena = {
|
||||||
add_level = function (levelNum, levelName)
|
add_level = function (levelNum, levelName)
|
||||||
table.insert(gGameLevels, { level = levelNum, name = levelName })
|
table.insert(gGameLevels, { level = levelNum, name = levelName })
|
||||||
update_chat_command_description('arena-level', string.format('[%s] sets level', get_level_choices()))
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,6 +401,14 @@ end
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
local function split(s)
|
||||||
|
local result = {}
|
||||||
|
for match in (s):gmatch(string.format("[^%s]+", " ")) do
|
||||||
|
table.insert(result, match)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
function level_check()
|
function level_check()
|
||||||
local np = gNetworkPlayers[0]
|
local np = gNetworkPlayers[0]
|
||||||
if np.currLevelNum ~= gGlobalSyncTable.currentLevel or np.currActNum ~= 1 or np.currAreaIndex ~= 1 then
|
if np.currLevelNum ~= gGlobalSyncTable.currentLevel or np.currActNum ~= 1 or np.currAreaIndex ~= 1 then
|
||||||
|
@ -447,11 +454,11 @@ function on_update()
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_gamemode_command(msg)
|
function on_gamemode_command(msg)
|
||||||
|
msg = msg:lower()
|
||||||
local setMode = nil
|
local setMode = nil
|
||||||
|
|
||||||
for i, gm in ipairs(gGameModes) do
|
for i, gm in ipairs(gGameModes) do
|
||||||
if msg == gm.shortName then
|
if msg == gm.shortName:lower() then
|
||||||
setMode = i
|
setMode = i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -475,14 +482,16 @@ function on_gamemode_command(msg)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
djui_chat_message_create("/arena \\#00ffff\\gamemode\\#ffff00\\ " .. string.format("[%s|random]\\#dcdcdc\\ sets gamemode", sGameModeShortTimes))
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_level_command(msg)
|
function on_level_command(msg)
|
||||||
|
msg = msg:lower()
|
||||||
local setLevel = nil
|
local setLevel = nil
|
||||||
|
|
||||||
for i, gl in ipairs(gGameLevels) do
|
for i, gl in ipairs(gGameLevels) do
|
||||||
if msg == gl.name then
|
if msg == gl.name:lower() then
|
||||||
setLevel = i
|
setLevel = i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -495,7 +504,24 @@ function on_level_command(msg)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
djui_chat_message_create("/arena \\#00ffff\\level\\#ffff00\\ " .. string.format("[%s]\\#dcdcdc\\ sets level", get_level_choices()))
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_arena_command(msg)
|
||||||
|
local args = split(msg)
|
||||||
|
if args[1] == "gamemode" then
|
||||||
|
return on_gamemode_command(args[2] or "")
|
||||||
|
elseif args[1] == "level" then
|
||||||
|
local name = args[2] or ""
|
||||||
|
if args[3] ~= nil then
|
||||||
|
name = name .. " " .. args[3]
|
||||||
|
end
|
||||||
|
return on_level_command(name or "")
|
||||||
|
end
|
||||||
|
|
||||||
|
djui_chat_message_create("/arena \\#00ffff\\[gamemode|level]")
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
hook_event(HOOK_ON_SYNC_VALID, on_sync_valid)
|
hook_event(HOOK_ON_SYNC_VALID, on_sync_valid)
|
||||||
|
@ -522,6 +548,9 @@ function get_level_choices()
|
||||||
end
|
end
|
||||||
|
|
||||||
if network_is_server() then
|
if network_is_server() then
|
||||||
hook_chat_command('arena-gamemode', string.format("[%s|random] sets gamemode", sGameModeShortTimes), on_gamemode_command)
|
hook_chat_command("arena", "\\#00ffff\\[gamemode|level]", on_arena_command)
|
||||||
hook_chat_command('arena-level', string.format('[%s] sets level', get_level_choices()), on_level_command)
|
end
|
||||||
|
|
||||||
|
if _G.dayNightCycleApi ~= nil then
|
||||||
|
_G.dayNightCycleApi.enable_day_night_cycle(false)
|
||||||
end
|
end
|
Loading…
Reference in a new issue