Update docs, update builtin mods

This commit is contained in:
EmeraldLockdown 2026-03-25 11:10:23 -05:00
parent d5cedffecb
commit b56dc3e581
11 changed files with 144 additions and 114 deletions

View file

@ -9,36 +9,36 @@ function on_stream_play(msg)
if(msg == "load") then
audioStream = audio_stream_load("music.mp3")
audio_stream_set_looping(audioStream, true)
djui_chat_message_create("audio audioStream:" .. tostring(audioStream));
command_message_create("audio audioStream:" .. tostring(audioStream));
end
if(msg == "play") then
audio_stream_play(audioStream, true, 1);
djui_chat_message_create("playing audio");
command_message_create("playing audio");
end
if(msg == "resume") then
audio_stream_play(audioStream, false, 1);
djui_chat_message_create("resuming audio");
command_message_create("resuming audio");
end
if(msg == "pause") then
audio_stream_pause(audioStream);
djui_chat_message_create("pausing audio");
command_message_create("pausing audio");
end
if(msg == "stop") then
audio_stream_stop(audioStream);
djui_chat_message_create("stopping audio");
command_message_create("stopping audio");
end
if(msg == "destroy") then
audio_stream_destroy(audioStream);
djui_chat_message_create("destroyed audio");
command_message_create("destroyed audio");
end
if(msg == "getpos") then
djui_chat_message_create("pos: " .. tostring(audio_stream_get_position(audioStream)));
command_message_create("pos: " .. tostring(audio_stream_get_position(audioStream)));
end
return true;
@ -48,7 +48,7 @@ function on_sample_play(msg)
if(msg == "load") then
audioSample = audio_sample_load("sample.mp3");
djui_chat_message_create("audio audioStream:" .. tostring(audioSample));
command_message_create("audio audioStream:" .. tostring(audioSample));
return true;
end

View file

@ -27,12 +27,12 @@ function send_example_1(byte_param, short_param, long_param, float_param, double
network_send_bytestring(true, bytestring)
djui_chat_message_create('Sent bytestring packet example 1:')
djui_chat_message_create(' byte_param: ' .. byte_param)
djui_chat_message_create(' short_param: ' .. short_param)
djui_chat_message_create(' long_param: ' .. long_param)
djui_chat_message_create(' float_param: ' .. float_param)
djui_chat_message_create(' double_param: ' .. double_param)
command_message_create('Sent bytestring packet example 1:')
command_message_create(' byte_param: ' .. byte_param)
command_message_create(' short_param: ' .. short_param)
command_message_create(' long_param: ' .. long_param)
command_message_create(' float_param: ' .. float_param)
command_message_create(' double_param: ' .. double_param)
end
function on_packet_bytestring_receive_example_1(bytestring)
@ -55,11 +55,17 @@ function on_packet_bytestring_receive_example_1(bytestring)
---------------------------------------
djui_chat_message_create('Received bytestring packet example 1:')
log_to_console('Received bytestring packet example 1:')
djui_chat_message_create(' byte_param: ' .. byte_param)
log_to_console(' byte_param: ' .. byte_param)
djui_chat_message_create(' short_param: ' .. short_param)
log_to_console(' short_param: ' .. short_param)
djui_chat_message_create(' long_param: ' .. long_param)
log_to_console(' long_param: ' .. long_param)
djui_chat_message_create(' float_param: ' .. float_param)
log_to_console(' float_param: ' .. float_param)
djui_chat_message_create(' double_param: ' .. double_param)
log_to_console(' double_param: ' .. double_param)
end
---------------------------------------------------------------------------------------------------
@ -76,9 +82,9 @@ function send_example_2(long_param, string_param)
network_send_bytestring(true, bytestring)
djui_chat_message_create('Sent bytestring packet example 2:')
djui_chat_message_create(' byte_param: ' .. long_param)
djui_chat_message_create(' string_param: ' .. string_param)
command_message_create('Sent bytestring packet example 2:')
command_message_create(' byte_param: ' .. long_param)
command_message_create(' string_param: ' .. string_param)
end
function on_packet_bytestring_receive_example_2(bytestring)
@ -98,8 +104,11 @@ function on_packet_bytestring_receive_example_2(bytestring)
---------------------------------------
djui_chat_message_create('Received bytestring packet example 2:')
log_to_console('Received bytestring packet example 2:')
djui_chat_message_create(' long_param: ' .. long_param)
log_to_console(' long_param: ' .. long_param)
djui_chat_message_create(' string_param: ' .. string_param)
log_to_console(' string_param: ' .. string_param)
end
---------------------------------------------------------------------------------------------------

View file

@ -2,18 +2,6 @@
-- description: Run /matrix and a builtin texture name to replace with the digital rain
-- deluxe: true
if SM64COOPDX_VERSION == nil then
local first = false
hook_event(HOOK_ON_LEVEL_INIT, function()
if not first then
first = true
play_sound(SOUND_MENU_CAMERA_BUZZ, gMarioStates[0].marioObj.header.gfx.cameraToObject)
djui_chat_message_create("\\#ff7f7f\\Matrix Code is not supported with sm64ex-coop\nas it uses sm64coopdx exclusive Lua functionality.\n\\#dcdcdc\\To use this mod, try out sm64coopdx at\n\\#7f7fff\\https://sm64coopdx.com")
end
end)
return
end
local sMatrixFrames = {}
for i = 0, 10 do
sMatrixFrames[i] = get_texture_info("matrix_" .. i)

View file

@ -3,24 +3,24 @@
local function on_get_command(msg)
if not network_is_server() then
djui_chat_message_create("You need to be the host!")
command_message_create("You need to be the host!", CONSOLE_MESSAGE_ERROR)
return true
end
djui_chat_message_create(tostring(get_water_level(0)))
djui_chat_message_create(tostring(get_water_level(1)))
command_message_create(tostring(get_water_level(0)))
command_message_create(tostring(get_water_level(1)))
return true
end
local function on_set_command(msg)
if not network_is_server() then
djui_chat_message_create("You need to be the host!")
command_message_create("You need to be the host!", CONSOLE_MESSAGE_ERROR)
return true
end
local num = tonumber(msg)
if not num then
djui_chat_message_create("Not a number!")
command_message_create("Not a number!", CONSOLE_MESSAGE_ERROR)
return true
end

View file

@ -6,6 +6,7 @@ Hooks are a way for SM64 to trigger Lua code, whereas the functions listed in [f
# Supported Hooks
- [hook_behavior](#hook_behavior)
- [hook_chat_command](#hook_chat_command)
- [hook_console_command](#hook_console_command)
- [hook_event](#hook_event)
- [hook_mario_action](#hook_mario_action)
- [hook_on_sync_table_change](#hook_on_sync_table_change)
@ -54,7 +55,7 @@ id_bhvExample = hook_behavior(nil, OBJ_LIST_DEFAULT, true, bhv_example_init, bhv
<br />
## [hook_chat_command](#hook_chat_command)
`hook_chat_command()` allows Lua mods to react and respond to chat commands. Chat commands start with the `/` character. The function the mod passes to the hook should return `true` when the command was valid and `false` otherwise.
`hook_chat_command()` allows Lua mods to react and respond to chat commands. Chat commands start with the `/` character. The function the mod passes to the hook should return `true` when the command was valid and `false` otherwise. Use `command_message_create` to show any message to the user. Chat commands appear in the chat, console, and terminal.
### Parameters
@ -69,10 +70,10 @@ id_bhvExample = hook_behavior(nil, OBJ_LIST_DEFAULT, true, bhv_example_init, bhv
```lua
function on_test_command(msg)
if msg == "on" then
djui_chat_message_create("Test: enabled")
command_message_create("Test: enabled")
return true
elseif msg == "off" then
djui_chat_message_create("Test: disabled")
command_message_create("Test: disabled")
return true
end
return false
@ -85,6 +86,38 @@ hook_chat_command("test", "[on|off] turn test on or off", on_hide_and_seek_comma
<br />
## [hook_console_command](#hook_console_command)
`hook_console_command()` allows Lua mods to react and respond to console commands. The function the mod passes to the hook should return `true` when the command was valid and `false` otherwise. You should use `command_message_create` to show any messages to the user. Console messages only appear in the console and terminal.
### Parameters
| Field | Type |
| ----- | ---- |
| command | `string` |
| description | `string` |
| func | `Lua Function` (`string` message) -> `bool` |
### Lua Example
```lua
function on_test_command(msg)
if msg == "on" then
command_message_create("Test: enabled")
return true
elseif msg == "off" then
command_message_create("Test: disabled")
return true
end
return false
end
hook_console_command("test", "[on|off] turn test on or off", on_test_command)
```
[:arrow_up_small:](#)
<br />
## [hook_event](#hook_event)
The lua functions sent to `hook_event()` will be automatically called by SM64 when certain events occur.
@ -143,7 +176,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
| HOOK_ON_GEO_PROCESS | Called when a GeoLayout is processed **Note:** You must set the `hookProcess` field of the graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex |
| HOOK_BEFORE_GEO_PROCESS | Called before a GeoLayout is processed **Note:** You must set the `hookProcess` field of the graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex |
| HOOK_ON_GEO_PROCESS_CHILDREN | Called when the children of a GeoLayout node is processed **Note:** You must set the `hookProcess` field of the parent graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex |
| HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS | Called before running Mario's geometry input logic, return `false` to not run it. | [MarioState](../structs.md) m |
| HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS | Called before running Mario's geometry input logic, return `false` to not run it. | [MarioState](../structs.md) m |
| HOOK_ON_INTERACTIONS | Called when the Mario interactions are processed | [MarioState](../structs.md#MarioState) mario |
| HOOK_ALLOW_FORCE_WATER_ACTION | Called when executing a non-water action while under the water's surface, or vice versa. Return `false` to prevent the player from being forced out of the action at the water's surface | [MarioState](../structs.md#MarioState) mario, `boolean` isInWaterAction |
| HOOK_BEFORE_WARP | Called before the local player warps. Return a table with `destLevel`, `destArea`, `destWarpNode`, to override the warp | `integer` destLevel, `integer` destArea, `integer` destWarpNode, `integer` arg |

View file

@ -17,9 +17,9 @@ Save file locations:
<br />
## Tips
- When developing Lua mods, run the game from a console. Lua errors and logs will appear there, but only if the game is launched with the `--console` launch parameter.
- When developing Lua mods, open the console with `~` or `F1` to see Lua errors and warnings.
- When a function requests a time parameter, it is almost if not always in frames.
- You can use the `print()` command when debugging. Your logs will show up in the console.
- You can use the `print()` command when debugging. Your logs will show up in the console and terminal.
- You can create a folder within the mods folder containing multiple lua scripts as long as one script is called `main.lua`. Dynos actors can be placed inside this mod folder under `<your mod folder>/actors/`.
<br />
@ -30,7 +30,7 @@ Save file locations:
- [Structs](structs.md)
### Guides
- [Setting up Visual Studio Code](guides/vs-code-setup.md)
- [Setting up Visual Studio Code](guides/vs-code-setup.md)
- [Hooks](guides/hooks.md)
- [gMarioStates](guides/mario-state.md)
- [Behavior Object Lists](guides/object-lists.md)

View file

@ -378,7 +378,7 @@ function on_arena_player_death(victimGlobalId, attackerGlobalId)
if sAttacker.team ~= 0 then
local teamScore = calculate_team_score(sAttacker.team)
if teamScore >= gGameModes[gGlobalSyncTable.gameMode].scoreCap then
round_end()
round_end()
end
end
end
@ -472,7 +472,7 @@ function on_gamemode_command(msg)
end
if msg == 'random' then
djui_chat_message_create("[Arena] Setting to random gamemode.")
command_message_create("[Arena] Setting to random gamemode.")
sRandomizeMode = true
round_end()
sWaitTimer = 1
@ -481,7 +481,7 @@ function on_gamemode_command(msg)
end
if setMode ~= nil then
djui_chat_message_create("[Arena] Setting game mode.")
command_message_create("[Arena] Setting game mode.")
gGlobalSyncTable.gameMode = setMode
sRandomizeMode = false
round_end()
@ -490,7 +490,7 @@ function on_gamemode_command(msg)
return true
end
djui_chat_message_create("/arena \\#00ffff\\gamemode\\#ffff00\\ " .. string.format("[%s|random]\\#dcdcdc\\ sets gamemode", sGameModeShortTimes))
command_message_create("/arena \\#00ffff\\gamemode\\#ffff00\\ " .. string.format("[%s|random]\\#dcdcdc\\ sets gamemode", sGameModeShortTimes))
return true
end
@ -512,21 +512,21 @@ function on_level_command(msg)
return true
end
djui_chat_message_create("/arena \\#00ffff\\level\\#ffff00\\ " .. string.format("[%s]\\#dcdcdc\\ sets level", get_level_choices()))
command_message_create("/arena \\#00ffff\\level\\#ffff00\\ " .. string.format("[%s]\\#dcdcdc\\ sets level", get_level_choices()))
return true
end
function on_jump_leniency_command(msg)
local num = tonumber(msg)
if not network_is_server and not network_is_moderator() then
djui_chat_message_create("\\#ffa0a0\\[Arena] You need to be a moderator to use this command.")
command_message_create("\\#ffa0a0\\[Arena] You need to be a moderator to use this command.")
return true
elseif num == nil then
djui_chat_message_create("\\#ffa0a0\\[Arena] Invalid number!")
command_message_create("\\#ffa0a0\\[Arena] Invalid number!")
return true
else
gGlobalSyncTable.jumpLeniency = num
djui_chat_message_create("[Arena] The number of jump leniency frames has been set to " .. num)
command_message_create("[Arena] The number of jump leniency frames has been set to " .. num)
return true
end
end
@ -545,7 +545,7 @@ local function on_arena_command(msg)
return on_jump_leniency_command(args[2] or "")
end
djui_chat_message_create("/arena \\#00ffff\\[gamemode|level|jump-leniency]")
command_message_create("/arena \\#00ffff\\[gamemode|level|jump-leniency]")
return true
end

View file

@ -528,7 +528,7 @@ local function update_character_render_table()
end
end
end
if #characterTableRender > 0 then
-- Get icons for category based on name similarity
if category.icon1 == nil or category.icon2 == nil then
@ -902,7 +902,7 @@ local worldColor = {
ambient = {r = 255, g = 255, b = 255}
}
local menuOffsetX = 0
local menuOffsetY = 0
local menuOffsetY = 0
local camScale = 1
local prevMusicToggle = 1
local prevVisualToggle = 1
@ -919,7 +919,7 @@ local function mario_update(m)
set_all_models()
queueStorageFailsafe = false
end
local np = gNetworkPlayers[m.playerIndex]
local p = gCSPlayers[m.playerIndex]
@ -952,7 +952,7 @@ local function mario_update(m)
end
end
if djui_hud_is_pause_menu_created() then
if djui_hud_is_pause_menu_created() then
if prevBaseCharFrame ~= np.modelIndex then
force_set_character(np.modelIndex)
p.presetPalette = 0
@ -978,7 +978,7 @@ local function mario_update(m)
local charTable = characterTable[currChar]
p.saveName = charTable.saveName
p.currAlt = charTable.currAlt
p.modelId = charTable[charTable.currAlt].model
if charTable[charTable.currAlt].baseChar ~= nil then
p.baseChar = charTable[charTable.currAlt].baseChar
@ -1316,9 +1316,9 @@ function set_model(o, model)
if o.oOriginalModel == 0 then
o.oOriginalModel = obj_get_model_id_extended(o)
end
local model = run_func_or_get_var(currReplace, o, o.oOriginalModel)
if model ~= nil and visualToggle then
o.oModelHasBeenReplaced = 1
if obj_has_model_extended(o, model) == 0 then
@ -1601,7 +1601,7 @@ local function on_hud_render()
djui_hud_set_color(charColor.r*0.5 + 127, charColor.g*0.5 + 127, charColor.b*0.5 + 127, math.min(paletteTrans, 255))
djui_hud_print_text(paletteName, x, y, 0.5)
end
-- Render Background Wall
local wallWidth = TEX_WALL_LEFT.width
local wallHeight = TEX_WALL_LEFT.height
@ -1615,11 +1615,11 @@ local function on_hud_render()
djui_hud_render_texture_auto_interpolated("wall-l", TEX_WALL_LEFT, x, y, wallScale, wallScale)
djui_hud_set_color(playerPants.r, playerPants.g, playerPants.b, 255)
djui_hud_render_texture_auto_interpolated("wall-r", TEX_WALL_RIGHT, x, y, wallScale, wallScale)
-- Render Graffiti
local graffiti = characterGraffiti[currChar] or TEX_GRAFFITI_DEFAULT
local graffitiWidthScale = 120/graffiti.width
local graffitiHeightScale = 120/graffiti.width
local graffitiWidthScale = 120/graffiti.width
local graffitiHeightScale = 120/graffiti.width
djui_hud_set_color(255, 255, 255, 150)
djui_hud_render_texture_auto_interpolated("graffiti", graffiti, wallMiddle - graffiti.width*0.5*graffitiWidthScale - menuOffsetX, height*0.5 - graffiti.height*0.5*graffitiHeightScale - menuOffsetY, graffitiWidthScale, graffitiHeightScale)
@ -1638,7 +1638,7 @@ local function on_hud_render()
local scale = 0.35
local textScale = scale*1.5
local buttonSpacing = 32
if not gridMenu then
-- Render Character List
gridYOffset = lerp(gridYOffset, currCharRender*buttonSpacing, 0.1)
@ -1666,7 +1666,7 @@ local function on_hud_render()
-- Name Screen
djui_hud_set_color(charColor.r*0.5, charColor.g*0.5, charColor.b*0.5, 255)
djui_hud_print_text(charName, x + 112*scale + segments*16*scale*0.5 - charNameLength*textScale*0.5, y + 32*scale, textScale)
-- Bottom Info
djui_hud_render_rect(x + 112*scale, y + 84*scale, segments*16*scale, scale)
djui_hud_print_text(channel, x + 112*scale, y + 85*scale, 0.3*scale)
@ -1907,7 +1907,7 @@ local function on_hud_render()
djui_hud_print_text(TEXT_VERSION, 2, height - 7, 0.4)
local currMenu = gridMenu and MENU_BINDS_GRID or MENU_BINDS_DEFAULT
if options == OPTIONS_MAIN then
currMenu = MENU_BINDS_OPTIONS
currMenu = MENU_BINDS_OPTIONS
elseif options == OPTIONS_CREDITS then
currMenu = MENU_BINDS_GRID
end
@ -2091,7 +2091,7 @@ local function before_mario_update(m)
until update_character_render_table()
gearRotationTarget = gearRotationTarget + 0x10000/#characterCategories
categoryOpenTimer = 150
play_sound(SOUND_MENU_CAMERA_TURN, cameraToObject)
end
)
@ -2108,7 +2108,7 @@ local function before_mario_update(m)
play_sound(SOUND_MENU_CAMERA_TURN, cameraToObject)
end
)
if not gridMenu then
-- List Controls
run_func_with_condition_and_cooldown(FUNC_INDEX_VERTICAL,
@ -2150,7 +2150,7 @@ local function before_mario_update(m)
end
)
end
else
-- Grid Controls
run_func_with_condition_and_cooldown(FUNC_INDEX_VERTICAL,
@ -2186,7 +2186,7 @@ local function before_mario_update(m)
play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject)
end
)
-- Alt switcher
if #characterTable[currChar] > 1 then
run_func_with_condition_and_cooldown(FUNC_INDEX_ALT,
@ -2392,14 +2392,14 @@ local function chat_command(msg)
menu = not menu
return true
else
djui_chat_message_create(TEXT_PAUSE_UNAVAILABLE)
command_message_create(TEXT_PAUSE_UNAVAILABLE)
return true
end
end
-- Help Prompt Check
if msg == "?" or msg == "help" then
djui_chat_message_create("Character Select's Avalible Commands:" ..
command_message_create("Character Select's Avalible Commands:" ..
"\n\\#ffff33\\/char-select help\\#ffffff\\ - Returns Avalible Commands" ..
"\n\\#ffff33\\/char-select menu\\#ffffff\\ - Opens the Menu" ..
"\n\\#ffff33\\/char-select [name/num]\\#ffffff\\ - Switches to Character" ..
@ -2413,9 +2413,9 @@ local function chat_command(msg)
return true
end
-- Stop Character checks if API disallows it
-- Stop Character checks if API disallows it
if not menu_is_allowed() or charBeingSet then
djui_chat_message_create("Character Cannot be Changed")
command_message_create("Character Cannot be Changed")
return true
end
@ -2426,7 +2426,7 @@ local function chat_command(msg)
for a = 1, #characterTable[i] do
if msg == string.lower(characterTable[i][a].name) or msg == saveName then
force_set_character(i, msg ~= saveName and a or 1)
djui_chat_message_create('Character set to "' .. characterTable[i][characterTable[i].currAlt].name .. '" Successfully!')
command_message_create('Character set to "' .. characterTable[i][characterTable[i].currAlt].name .. '" Successfully!')
return true
end
end
@ -2441,12 +2441,12 @@ local function chat_command(msg)
altNum = altNum and altNum or 1
if charNum > 0 and charNum <= #characterTable and characterTable[charNum].locked ~= LOCKED_TRUE then
force_set_character(charNum, altNum)
djui_chat_message_create('Character set to "' .. characterTable[charNum][altNum].name .. '" Successfully!')
command_message_create('Character set to "' .. characterTable[charNum][altNum].name .. '" Successfully!')
return true
end
end
djui_chat_message_create("Character Not Found")
command_message_create("Character Not Found")
return true
end

View file

@ -333,12 +333,12 @@ end
local function on_set_command(msg)
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
if msg == "" then
djui_chat_message_create("/time \\#00ffff\\set\\#ffff00\\ [TIME]\\#dcdcdc\\ to set the time")
command_message_create("/time \\#00ffff\\set\\#ffff00\\ [TIME]\\#dcdcdc\\ to set the time")
return
end
@ -359,9 +359,9 @@ local function on_set_command(msg)
local amount = tonumber(msg)
if amount ~= nil then
gGlobalSyncTable.time = amount * SECOND
djui_chat_message_create("[Day Night Cycle] Time set to " .. math_floor(gGlobalSyncTable.time / SECOND))
command_message_create("[Day Night Cycle] Time set to " .. math_floor(gGlobalSyncTable.time / SECOND))
else
djui_chat_message_create(string.format("\\#ffa0a0\\[Day Night Cycle] Could not set time to '%s'", msg))
command_message_create(string.format("\\#ffa0a0\\[Day Night Cycle] Could not set time to '%s'", msg), CONSOLE_MESSAGE_ERROR)
end
end
@ -373,13 +373,13 @@ end
local function on_add_command(msg)
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
local amount = tonumber(msg)
if amount == nil then
djui_chat_message_create("/time \\#00ffff\\add\\#ffff00\\ [AMOUNT]\\#dcdcdc\\ to add to the time")
command_message_create("/time \\#00ffff\\add\\#ffff00\\ [AMOUNT]\\#dcdcdc\\ to add to the time")
return
end
local oldTime = gGlobalSyncTable.time
@ -388,7 +388,7 @@ local function on_add_command(msg)
update_mod_menu_element_inputbox(modMenuTimeModifier, msg)
djui_chat_message_create("[Day Night Cycle] Time set to " .. math_floor(gGlobalSyncTable.time / SECOND))
command_message_create("[Day Night Cycle] Time set to " .. math_floor(gGlobalSyncTable.time / SECOND))
save_time()
end
@ -397,13 +397,13 @@ end
local function on_scale_command(msg)
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
local scale = tonumber(msg)
if scale == nil then
djui_chat_message_create("/time \\#00ffff\\scale\\#ffff00\\ [SCALE]\\#dcdcdc\\ to scale the rate at which time passes")
command_message_create("/time \\#00ffff\\scale\\#ffff00\\ [SCALE]\\#dcdcdc\\ to scale the rate at which time passes")
return
end
gGlobalSyncTable.timeScale = scale
@ -411,13 +411,13 @@ local function on_scale_command(msg)
update_mod_menu_element_slider(modMenuTimeScale, scale)
djui_chat_message_create("[Day Night Cycle] Time scale set to " .. scale)
command_message_create("[Day Night Cycle] Time scale set to " .. scale)
save_time()
end
local function on_query_command()
djui_chat_message_create(string.format("[Day Night Cycle] Time is %d (%s), day %d", math_floor(gGlobalSyncTable.time / SECOND), get_time_string(gGlobalSyncTable.time), get_day_count()))
command_message_create(string.format("[Day Night Cycle] Time is %d (%s), day %d", math_floor(gGlobalSyncTable.time / SECOND), get_time_string(gGlobalSyncTable.time), get_day_count()))
end
local function on_24h_command()
@ -430,11 +430,11 @@ end
local function on_sync_command()
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
djui_chat_message_create("[Day Night Cycle] Attempting to sync in-game time with real life time...")
command_message_create("[Day Night Cycle] Attempting to sync in-game time with real life time...")
local dateTime = get_date_and_time()
gGlobalSyncTable.time = get_day_count() * (MINUTE * 24) + (MINUTE * dateTime.hour) + (SECOND * dateTime.minute)
@ -446,25 +446,25 @@ end
local function on_sync_sun_command()
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
if dayNightCycleApi.lockSunHours then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] Changing sun hours has been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] Changing sun hours has been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
syncSun = not syncSun
mod_storage_save_bool("sync_sun", syncSun)
if syncSun then
djui_chat_message_create("[Day Night Cycle] Syncing sunrise and sunset times to real life...")
command_message_create("[Day Night Cycle] Syncing sunrise and sunset times to real life...")
local month = get_date_and_time().month + 1
set_sun_hours(gSunriseTimes[month], gSunsetTimes[month])
else
djui_chat_message_create("[Day Night Cycle] Resetting sunrise and sunset times...")
command_message_create("[Day Night Cycle] Resetting sunrise and sunset times...")
set_sun_hours(HOUR_SUNRISE_START_BASE, HOUR_SUNSET_START_BASE)
end
@ -475,13 +475,13 @@ end
local function on_music_command()
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
playNightMusic = not playNightMusic
mod_storage_save_bool("night_music", playNightMusic)
djui_chat_message_create("[Day Night Cycle] Night music status: " .. on_or_off(playNightMusic))
command_message_create("[Day Night Cycle] Night music status: " .. on_or_off(playNightMusic))
update_mod_menu_element_checkbox(modMenuMusic, playNightMusic)
end
@ -489,13 +489,13 @@ end
local function on_display_time_command()
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
displayTime = not displayTime
mod_storage_save_bool("display_time", displayTime)
djui_chat_message_create("[Day Night Cycle] Display time status: " .. on_or_off(displayTime))
command_message_create("[Day Night Cycle] Display time status: " .. on_or_off(displayTime))
update_mod_menu_element_checkbox(modMenuDisplayTime, displayTime)
end
@ -506,19 +506,19 @@ local function on_time_command(msg)
if args[1] == "set" then
if not network_is_server() then
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time set")
command_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time set", CONSOLE_MESSAGE_ERROR)
else
on_set_command(args[2] or "")
end
elseif args[1] == "add" then
if not network_is_server() then
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time add")
command_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time add", CONSOLE_MESSAGE_ERROR)
else
on_add_command(args[2] or "")
end
elseif args[1] == "scale" then
if not network_is_server() then
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time scale")
command_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time scale", CONSOLE_MESSAGE_ERROR)
else
on_scale_command(args[2] or "")
end
@ -528,7 +528,7 @@ local function on_time_command(msg)
on_24h_command()
elseif args[1] == "sync" then
if not network_is_server() then
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time sync")
command_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to run /time sync", CONSOLE_MESSAGE_ERROR)
else
on_sync_command()
end
@ -539,13 +539,13 @@ local function on_time_command(msg)
elseif args[1] == "display-time" then
on_display_time_command()
elseif args[1] ~= nil then
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] Unrecognized command '" .. args[1] .. "'")
command_message_create("\\#ffa0a0\\[Day Night Cycle] Unrecognized command '" .. args[1] .. "'", CONSOLE_MESSAGE_ERROR)
else
if not network_is_server() then
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to enable or disable Day Night Cycle")
command_message_create("\\#ffa0a0\\[Day Night Cycle] You do not have permission to enable or disable Day Night Cycle", CONSOLE_MESSAGE_ERROR)
else
gGlobalSyncTable.dncEnabled = not gGlobalSyncTable.dncEnabled
djui_chat_message_create("[Day Night Cycle] Status: " .. on_or_off(gGlobalSyncTable.dncEnabled))
command_message_create("[Day Night Cycle] Status: " .. on_or_off(gGlobalSyncTable.dncEnabled))
end
end
@ -586,7 +586,7 @@ end
local function on_set_dnc_enabled(_, value)
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
@ -597,7 +597,7 @@ end
local function on_set_time_scale(index, value)
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
@ -610,7 +610,7 @@ end
local function on_set_time_modifier(_, value)
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end
@ -621,7 +621,7 @@ end
local function on_add_hour()
if dayNightCycleApi.lockTime then
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.")
command_message_create("\\#ffa0a0\\[Day Night Cycle] The Day Night Cycle settings have been locked by another mod.", CONSOLE_MESSAGE_ERROR)
return
end

View file

@ -389,31 +389,31 @@ end
local function on_touch_tag_command()
gGlobalSyncTable.touchTag = not gGlobalSyncTable.touchTag
djui_chat_message_create("Touch tag: " .. on_or_off(gGlobalSyncTable.touchTag))
command_message_create("Touch tag: " .. on_or_off(gGlobalSyncTable.touchTag))
return true
end
local function on_hider_cap_command()
gGlobalSyncTable.hiderCaps = not gGlobalSyncTable.hiderCaps
djui_chat_message_create("Hider Caps: " .. on_or_off(gGlobalSyncTable.hiderCaps))
command_message_create("Hider Caps: " .. on_or_off(gGlobalSyncTable.hiderCaps))
return true
end
local function on_seeker_cap_command()
gGlobalSyncTable.seekerCaps = not gGlobalSyncTable.seekerCaps
djui_chat_message_create("Seeker Caps: " .. on_or_off(gGlobalSyncTable.seekerCaps))
command_message_create("Seeker Caps: " .. on_or_off(gGlobalSyncTable.seekerCaps))
return true
end
local function on_koopa_shell_command()
gGlobalSyncTable.banKoopaShell = not gGlobalSyncTable.banKoopaShell
djui_chat_message_create("Koopa Shells: " .. on_or_off(not gGlobalSyncTable.banKoopaShell))
command_message_create("Koopa Shells: " .. on_or_off(not gGlobalSyncTable.banKoopaShell))
return true
end
local function on_blj_command()
gGlobalSyncTable.disableBLJ = not gGlobalSyncTable.disableBLJ
djui_chat_message_create("BLJS: " .. on_or_off(not gGlobalSyncTable.disableBLJ))
command_message_create("BLJS: " .. on_or_off(not gGlobalSyncTable.disableBLJ))
return true
end

View file

@ -23,9 +23,9 @@ end
local function on_swap_command()
local np = gNetworkPlayers[0]
if np.currAreaIndex == 1 then
djui_chat_message_create("Swapping to Extreme Edition")
command_message_create("Swapping to Extreme Edition")
else
djui_chat_message_create("Swapping to normal edition")
command_message_create("Swapping to normal edition")
end
warp_to_level(np.currLevelNum, np.currAreaIndex ~ 3, np.currActNum)
return true