mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
[build] Update built-in mods
Cjes & VL's code looks kinda messy...
This commit is contained in:
parent
02bd7917cb
commit
b93d2eb5ff
5 changed files with 286 additions and 87 deletions
|
|
@ -1,47 +1,202 @@
|
|||
-- name: [CS] VL-Tone & Cjes Luigi
|
||||
-- description: [CS] \\#00ff00\\VL-Tone \\#dcdcdc\\& \\#00ff00\\Cjes Luigi\n\\#dcdcdc\\By: Coop Deluxe Team\n\nReturn of TWO nostalgic Luigi's dating back to the 2000s!\n\n\\#00ff00\\Model Credits:\n\\#dcdcdc\\VL-Tone\nCJes\n\n\\#00ff00\\Model Porting:\n\\#dcdcdc\\AngelicMiracles "Yuyake"\nFluffaMario\nSonicDark
|
||||
|
||||
local MOD_NAME = "VL & Cjes Luigi"
|
||||
-- name: [CS] \\#00ff00\\VL-Tone & Cjes Luigi
|
||||
-- description: [CS] VL-Tone & Cjes Luigi\nBy Coop Deluxe Team\n\nThis Character Select pack adds VL-Tone Luigi and Cjes Luigi, who was originally the model for luigi in earlier versions of sm64ex-coop.
|
||||
|
||||
if not _G.charSelectExists then
|
||||
djui_popup_create("\\#ffffa0\\"..MOD_NAME.." requires\nCharacter Select to be enabled.\n\nPlease rehost with it enabled.", 4)
|
||||
local first = false
|
||||
hook_event(HOOK_ON_LEVEL_INIT, function()
|
||||
if not first then
|
||||
first = true
|
||||
play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource)
|
||||
djui_chat_message_create("\\#ffffa0\\Extra Characters requires Character Select to be enabled.\nPlease rehost with it enabled.")
|
||||
end
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
-- localize functions to improve performance
|
||||
local table_insert,play_sound,djui_hud_get_screen_width,maxf,math_sin,djui_hud_set_color,djui_hud_set_font,string_format,djui_hud_measure_text,djui_hud_print_text,djui_hud_set_resolution,min,math_min,math_max,djui_hud_set_rotation,djui_hud_render_rect = table.insert,play_sound,djui_hud_get_screen_width,maxf,math.sin,djui_hud_set_color,djui_hud_set_font,string.format,djui_hud_measure_text,djui_hud_print_text,djui_hud_set_resolution,min,math.min,math.max,djui_hud_set_rotation,djui_hud_render_rect
|
||||
|
||||
--Loads Models
|
||||
local E_MODEL_VL = smlua_model_util_get_id("vl_geo")
|
||||
local E_MODEL_CJES = smlua_model_util_get_id("cjes_geo")
|
||||
|
||||
--Loads Mod Name
|
||||
local TEXT_MOD_NAME = "VL-Tone & Cjes Luigi"
|
||||
local TEXT_MOD_VERSION = "4.1"
|
||||
|
||||
--Palettes
|
||||
local PALETTE_VL = {
|
||||
[PANTS] = { r = 0x20, g = 0x14, b = 0x7c }, -- 20147C
|
||||
[SHIRT] = { r = 0x00, g = 0x98, b = 0x00 }, -- 009800
|
||||
[GLOVES] = { r = 0xff, g = 0xff, b = 0xff }, -- FFFFFF
|
||||
[SHOES] = { r = 0x48, g = 0x20, b = 0x18 }, -- 482018
|
||||
[HAIR] = { r = 0x68, g = 0x24, b = 0x14 }, -- 682414
|
||||
[SKIN] = { r = 0xfe, g = 0xc1, b = 0x79 }, -- FEC179
|
||||
[CAP] = { r = 0x00, g = 0x98, b = 0x00 }, -- 009800
|
||||
[EMBLEM] = { r = 0x00, g = 0x98, b = 0x00 }, -- 009800
|
||||
[PANTS] = {r = 0x20, g = 0x14, b = 0x7c}, -- 20147C
|
||||
[SHIRT] = {r = 0x00, g = 0x98, b = 0x00}, -- 009800
|
||||
[GLOVES] = {r = 0xff, g = 0xff, b = 0xff}, -- FFFFFF
|
||||
[SHOES] = {r = 0x48, g = 0x20, b = 0x18}, -- 482018
|
||||
[HAIR] = {r = 0x68, g = 0x24, b = 0x14}, -- 682414
|
||||
[SKIN] = {r = 0xfe, g = 0xc1, b = 0x79}, -- FEC179
|
||||
[CAP] = {r = 0x00, g = 0x98, b = 0x00}, -- 009800
|
||||
[EMBLEM] = {r = 0x00, g = 0x98, b = 0x00}, -- 009800
|
||||
}
|
||||
|
||||
local PALETTE_CJES = {
|
||||
[PANTS] = { r = 0x00, g = 0x00, b = 0xff }, -- 0000FF
|
||||
[SHIRT] = { r = 0x00, g = 0x8c, b = 0x00 }, -- 008C00
|
||||
[GLOVES] = { r = 0xff, g = 0xff, b = 0xff }, -- FFFFFF
|
||||
[SHOES] = { r = 0x50, g = 0x16, b = 0x07 }, -- 501607
|
||||
[HAIR] = { r = 0x73, g = 0x06, b = 0x00 }, -- 730600
|
||||
[SKIN] = { r = 0xfe, g = 0xc1, b = 0x79 }, -- FEC179
|
||||
[CAP] = { r = 0x00, g = 0x8c, b = 0x00 }, -- 008C00
|
||||
[EMBLEM] = { r = 0x00, g = 0x8c, b = 0x00 }, -- 008C00
|
||||
[PANTS] = {r = 0x00, g = 0x00, b = 0xff}, -- 0000FF
|
||||
[SHIRT] = {r = 0x00, g = 0x8c, b = 0x00}, -- 008C00
|
||||
[GLOVES] = {r = 0xff, g = 0xff, b = 0xff}, -- FFFFFF
|
||||
[SHOES] = {r = 0x50, g = 0x16, b = 0x07}, -- 501607
|
||||
[HAIR] = {r = 0x73, g = 0x06, b = 0x00}, -- 730600
|
||||
[SKIN] = {r = 0xfe, g = 0xc1, b = 0x79}, -- FEC179
|
||||
[CAP] = {r = 0x00, g = 0x8c, b = 0x00}, -- 008C00
|
||||
[EMBLEM] = {r = 0x00, g = 0x8c, b = 0x00}, -- 008C00
|
||||
}
|
||||
local CT_VL = 0
|
||||
local function on_character_select_load()
|
||||
CT_VL = _G.charSelect.character_add("VL and Cjes", {"A Fanmade model of Luigi that", "are a big nostalgic throwback for", "the Super Mario 64 community!", "", "VL was created as an easter egg", "for Toads Tool 64, a level editor", "released back in 2007!",}, "VL-Tone", PALETTE_VL[CAP], E_MODEL_VL, CT_LUIGI, "L")
|
||||
_G.charSelect.character_edit(CT_VL, "VL Luigi")
|
||||
_G.charSelect.character_add_costume(CT_VL, "Cjes Luigi", {"A Fanmade model of Luigi that", "are a big nostalgic throwback for", "the Super Mario 64 community!", "", "Cjes was the original model for", "SM64EX-Coop before it was", "eventually replaced."}, "Cjes", PALETTE_CJES[CAP], E_MODEL_CJES, CT_LUIGI, gTextures.luigi_head)
|
||||
_G.charSelect.character_add_palette_preset(E_MODEL_VL, PALETTE_VL)
|
||||
_G.charSelect.character_add_palette_preset(E_MODEL_CJES, PALETTE_CJES)
|
||||
|
||||
--Character Adds
|
||||
local CT_VL_AND_CJES = _G.charSelect.character_add("VL & CJes", {"Fanmade models of Luigi that are a", "big nostalgic throwback to", "Super Mario 64 fan community!", "", "VL was created as an easter egg", "for Toads Tool 64, a romhack editor.", "", "CJES was the original model for exCoop before", "it was eventually replaced!"}, "VL-Tone and CJes", {r = 0, g = 152, b = 0}, E_MODEL_VL, CT_LUIGI, gTextures.luigi_head)
|
||||
|
||||
--Set Palettes
|
||||
_G.charSelect.character_add_palette_preset(E_MODEL_VL, PALETTE_VL)
|
||||
_G.charSelect.character_add_palette_preset(E_MODEL_CJES, PALETTE_CJES)
|
||||
|
||||
--------------------------------------------
|
||||
--- Alt Costume code from Paper Partners ---
|
||||
------------ Modified by Squishy -----------
|
||||
--------------------------------------------
|
||||
|
||||
local character_edit = _G.charSelect.character_edit
|
||||
local character_get_current_number = _G.charSelect.character_get_current_number
|
||||
local character_get_current_table = _G.charSelect.character_get_current_table
|
||||
local get_options_status = _G.charSelect.get_options_status
|
||||
local get_menu_color = _G.charSelect.get_menu_color
|
||||
local hook_render_in_menu = _G.charSelect.hook_render_in_menu
|
||||
|
||||
local table_insert = table.insert
|
||||
local play_sound = play_sound
|
||||
local djui_hud_get_screen_width = djui_hud_get_screen_width
|
||||
local djui_hud_measure_text = djui_hud_measure_text
|
||||
local djui_hud_set_color = djui_hud_set_color
|
||||
local djui_hud_set_resolution = djui_hud_set_resolution
|
||||
local djui_hud_set_rotation = djui_hud_set_rotation
|
||||
local djui_hud_set_font = djui_hud_set_font
|
||||
local djui_hud_print_text = djui_hud_print_text
|
||||
local djui_hud_render_rect = djui_hud_render_rect
|
||||
local maxf = maxf
|
||||
local math_min = math.min
|
||||
local math_max = math.max
|
||||
local math_sin = math.sin
|
||||
|
||||
local altCostumes = {
|
||||
[CT_VL_AND_CJES] = {
|
||||
currSkin = 1,
|
||||
{name = " VL ", model = E_MODEL_VL,},
|
||||
{name = " CJES ", model = E_MODEL_CJES,},
|
||||
},
|
||||
}
|
||||
|
||||
local function update_character_skin(currChar, currAlt)
|
||||
local currSkin = altCostumes[currChar][currAlt]
|
||||
if altCostumes[currChar].desc == nil then
|
||||
altCostumes[currChar].desc = character_get_current_table().description
|
||||
end
|
||||
local description = {}
|
||||
for i = 1, #altCostumes[currChar].desc do
|
||||
table_insert(description, altCostumes[currChar].desc[i])
|
||||
end
|
||||
if currSkin.name ~= "" then
|
||||
table_insert(description, "")
|
||||
table_insert(description, "Current Outfit: "..currSkin.name)
|
||||
end
|
||||
character_edit(currChar, nil, description, nil, nil, currSkin.model, nil, nil)
|
||||
local cameraToObject = gMarioStates[0].marioObj.header.gfx.cameraToObject
|
||||
play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject)
|
||||
end
|
||||
|
||||
hook_event(HOOK_ON_MODS_LOADED, on_character_select_load)
|
||||
local inputLockTimer = 0
|
||||
local buttonAnimTimer = 0
|
||||
|
||||
local MATH_DIVIDE_320 = 1/320
|
||||
|
||||
local latencyValueTable = {12, 6, 3}
|
||||
|
||||
local function hud_render()
|
||||
local width = djui_hud_get_screen_width() + 1.4
|
||||
local widthScale = maxf(width, 321.4) * MATH_DIVIDE_320
|
||||
local currChar = character_get_current_number()
|
||||
local charColors = character_get_current_table().color
|
||||
|
||||
-- Mimick button swaying, which is missing from the paper code
|
||||
local buttonAnim = 0
|
||||
local charSelectAnim = get_options_status(_G.charSelect.optionTableRef.anims)
|
||||
if charSelectAnim > 0 then
|
||||
buttonAnimTimer = buttonAnimTimer + 1
|
||||
buttonAnim = math_sin(buttonAnimTimer * 0.05) * 2.5 + 5
|
||||
else
|
||||
buttonAnim = 10
|
||||
end
|
||||
|
||||
local inputLockTimerTo = latencyValueTable[get_options_status(_G.charSelect.optionTableRef.inputLatency) + 1]
|
||||
|
||||
if altCostumes[currChar] ~= nil then
|
||||
-- Render Mod Variond under CS version
|
||||
local menuColor = get_menu_color()
|
||||
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
|
||||
djui_hud_set_font(FONT_TINY)
|
||||
local string = TEXT_MOD_NAME.." ("..TEXT_MOD_VERSION..")"
|
||||
djui_hud_print_text(string, width - 5 - djui_hud_measure_text(string)*0.5, 3, 0.5)
|
||||
|
||||
---@type Controller
|
||||
local c = _G.charSelect.controller
|
||||
local currAlts = altCostumes[currChar]
|
||||
|
||||
djui_hud_set_font(FONT_NORMAL)
|
||||
djui_hud_set_resolution(RESOLUTION_N64)
|
||||
local inputLockTimerAnim = 0
|
||||
|
||||
local buttonX = 20 * widthScale + buttonAnim
|
||||
local x1 = buttonX - 4
|
||||
local x2 = x1 + 73
|
||||
local y = 97
|
||||
|
||||
if charSelectAnim > 0 then
|
||||
inputLockTimerAnim = inputLockTimer/inputLockTimerTo * 3
|
||||
x1 = x1 + math_min(inputLockTimerAnim, 0)
|
||||
x2 = x2 + math_max(inputLockTimerAnim, 0)
|
||||
end
|
||||
-- Left Arrow
|
||||
if currAlts.currSkin > 1 then
|
||||
djui_hud_set_color(charColors.r, charColors.g, charColors.b, 255)
|
||||
djui_hud_set_rotation(0x2000, 0.5, 0.5)
|
||||
djui_hud_render_rect(x1, y, 5, 5)
|
||||
djui_hud_set_color(0, 0, 0, 255)
|
||||
djui_hud_set_rotation(0x0000, 0.5, 0.5)
|
||||
djui_hud_render_rect(x1 + 2.5, y - 2, 6, 8)
|
||||
djui_hud_set_color(charColors.r, charColors.g, charColors.b, 255)
|
||||
djui_hud_render_rect(buttonX, y - 3, 1, 10)
|
||||
|
||||
if inputLockTimer == 0 and (c.buttonDown & L_JPAD ~= 0 or c.stickX < -0.5) then
|
||||
currAlts.currSkin = math_max(currAlts.currSkin - 1, 1)
|
||||
update_character_skin(currChar, currAlts.currSkin)
|
||||
inputLockTimer = -inputLockTimerTo
|
||||
end
|
||||
end
|
||||
-- Right Arrow
|
||||
if currAlts.currSkin < #currAlts then
|
||||
-- Changed arrows to mimick the ones seen in the options menu
|
||||
djui_hud_set_color(charColors.r, charColors.g, charColors.b, 255)
|
||||
djui_hud_set_rotation(0x2000, 0.5, 0.5)
|
||||
djui_hud_render_rect(x2, y, 5, 5)
|
||||
djui_hud_set_color(0, 0, 0, 255)
|
||||
djui_hud_set_rotation(0x0000, 0.5, 0.5)
|
||||
djui_hud_render_rect(x2 - 3.5, y - 2, 6, 8)
|
||||
djui_hud_set_color(charColors.r, charColors.g, charColors.b, 255)
|
||||
djui_hud_render_rect(buttonX + 69, y - 3, 1, 10)
|
||||
|
||||
if inputLockTimer == 0 and (c.buttonDown & R_JPAD ~= 0 or c.stickX > 0.5) then
|
||||
currAlts.currSkin = currAlts.currSkin + 1
|
||||
update_character_skin(currChar, currAlts.currSkin)
|
||||
inputLockTimer = inputLockTimerTo
|
||||
end
|
||||
end
|
||||
-- use an input lock to prevent cycling too fast
|
||||
if inputLockTimer > 0 then
|
||||
inputLockTimer = inputLockTimer - 1
|
||||
elseif inputLockTimer < 0 then
|
||||
inputLockTimer = inputLockTimer + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hook_render_in_menu(hud_render)
|
||||
|
|
@ -36,17 +36,17 @@ end
|
|||
--- @param a number
|
||||
--- @param b number
|
||||
--- @param t number
|
||||
--- Linearly interpolates between two points using a delta but rounds the final value
|
||||
function lerp_round(a, b, t)
|
||||
return math_round(lerp(a, b, t))
|
||||
--- Linearly interpolates between two points using a delta but ceils the final value
|
||||
function lerp_ceil(a, b, t)
|
||||
return math_ceil(lerp(a, b, t))
|
||||
end
|
||||
|
||||
--- @param a number
|
||||
--- @param b number
|
||||
--- @param t number
|
||||
--- Linearly interpolates between two points using a delta but ceils the final value
|
||||
function lerp_ceil(a, b, t)
|
||||
return math_ceil(lerp(a, b, t))
|
||||
--- Linearly interpolates between two points using a delta but rounds the final value
|
||||
function lerp_round(a, b, t)
|
||||
return math_round(lerp(a, b, t))
|
||||
end
|
||||
|
||||
--- @param a Color
|
||||
|
|
@ -119,4 +119,26 @@ function check_common_hud_render_cancels()
|
|||
gNetworkPlayers[0].currLevelNum == LEVEL_BOWSER_3 or
|
||||
gNetworkPlayers[0].currLevelNum == LEVEL_ENDING or
|
||||
action == ACT_END_PEACH_CUTSCENE or action == ACT_END_WAVING_CUTSCENE or action == ACT_CREDITS_CUTSCENE
|
||||
end
|
||||
|
||||
local function tobool(value)
|
||||
local type = type(value)
|
||||
if type == "boolean" then
|
||||
return value
|
||||
elseif type == "number" then
|
||||
return value == 1
|
||||
elseif type == "string" then
|
||||
return value == "true"
|
||||
elseif type == "table" or type == "function" or type == "thread" or type == "userdata" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- @param key string
|
||||
--- `mod_storage_load_bool` except it returns true by default
|
||||
function mod_storage_load_bool_2(key)
|
||||
local value = mod_storage_load(key)
|
||||
if value == nil then return true end
|
||||
return tobool(value)
|
||||
end
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
-- version
|
||||
DNC_VERSION_MAJOR = 2
|
||||
DNC_VERSION_MINOR = 3
|
||||
DNC_VERSION_PATCH = 1
|
||||
DNC_VERSION_MINOR = 4
|
||||
DNC_VERSION_PATCH = 0
|
||||
DNC_VERSION = math.tointeger(string.format("%d%d%d", DNC_VERSION_MAJOR, DNC_VERSION_MINOR, DNC_VERSION_PATCH))
|
||||
|
||||
-- skybox constants
|
||||
|
|
@ -26,18 +26,21 @@ MINUTE = SECOND * 60 -- how many frames are in 1 minute
|
|||
|
||||
|
||||
-- Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
|
||||
gSunriseTimes = { 6, 6, 6, 5, 5, 4, 4, 4, 5, 6, 6, 6 }
|
||||
gSunriseTimes = { 6, 5, 6, 6, 5, 4, 4, 4, 5, 6, 6, 6 }
|
||||
gSunsetTimes = { 15, 16, 17, 18, 18, 19, 19, 19, 18, 17, 15, 14 }
|
||||
|
||||
local month = get_date_and_time().month + 1
|
||||
syncSun = if_then_else(mod_storage_exists("sync_sun"), mod_storage_load_bool("sync_sun"), true)
|
||||
syncSun = mod_storage_load_bool_2("sync_sun")
|
||||
|
||||
HOUR_SUNRISE_START_BASE = 4
|
||||
HOUR_SUNSET_START_BASE = 19
|
||||
|
||||
HOUR_SUNRISE_DURATION = 1
|
||||
HOUR_SUNRISE_START = if_then_else(syncSun, gSunriseTimes[month], 4)
|
||||
HOUR_SUNRISE_START = if_then_else(syncSun, gSunriseTimes[month], HOUR_SUNRISE_START_BASE)
|
||||
HOUR_SUNRISE_END = HOUR_SUNRISE_START + HOUR_SUNRISE_DURATION
|
||||
|
||||
HOUR_SUNSET_DURATION = 1
|
||||
HOUR_SUNSET_START = if_then_else(syncSun, gSunsetTimes[month], 19)
|
||||
HOUR_SUNSET_START = if_then_else(syncSun, gSunsetTimes[month], HOUR_SUNSET_START_BASE)
|
||||
HOUR_SUNSET_END = HOUR_SUNSET_START + HOUR_SUNSET_DURATION
|
||||
|
||||
HOUR_DAY_START = HOUR_SUNRISE_END + HOUR_SUNRISE_DURATION
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ mod_storage_remove("night-music")
|
|||
use24h = mod_storage_load_bool("24h")
|
||||
|
||||
--- @type boolean
|
||||
playNightMusic = if_then_else(mod_storage_exists("night_music"), mod_storage_load_bool("night_music"), true)
|
||||
playNightMusic = mod_storage_load_bool_2("night_music")
|
||||
playingNightMusic = false
|
||||
|
||||
--- Returns the amount of days that have passed
|
||||
|
|
@ -76,16 +76,12 @@ function set_time_scale(scale)
|
|||
gGlobalSyncTable.timeScale = scale
|
||||
end
|
||||
|
||||
--- @param time number
|
||||
--- @param time number|nil
|
||||
--- Returns the properly formatted time string
|
||||
--- * `time` is optional, if not provided then the in-game time will automatically be used
|
||||
function get_time_string(time)
|
||||
if type(time) ~= "number" then
|
||||
error("get_time_string: Parameter 'time' must be a number")
|
||||
if use24h then
|
||||
return "12:00 AM"
|
||||
else
|
||||
return "0:00"
|
||||
end
|
||||
time = gGlobalSyncTable.time
|
||||
end
|
||||
|
||||
local minutes = (time / MINUTE) % 24
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- name: Day Night Cycle DX
|
||||
-- incompatible: light day-night-cycle
|
||||
-- description: Day Night Cycle DX v2.3.1\nBy \\#ec7731\\Agent X\n\n\\#dcdcdc\\This mod adds a fully featured day & night cycle system with night, sunrise, day and sunset to sm64coopdx. It includes an API and hook system for interfacing with several components of the mod externally. This mod was originally made for sm64ex-coop but has been practically rewritten for sm64coopdx.\n\nDays last 24 minutes and with the /time command, you can get/set the time or change your settings.\n\nThere is also now a new menu in the pause menu for Day Night Cycle DX!\n\nSpecial thanks to \\#e06de4\\MaiskX3\\#dcdcdc\\ for the night time music.\nSpecial thanks to \\#00ffff\\AngelicMiracles\\#dcdcdc\\ for the sunset, sunrise and night time skyboxes.\nSpecial thanks to \\#344ee1\\eros71\\#dcdcdc\\ for salvaging\nthe mod files.
|
||||
-- description: Day Night Cycle DX v2.4\nBy \\#ec7731\\Agent X\n\n\\#dcdcdc\\This mod adds a fully featured day & night cycle system with night, sunrise, day and sunset to sm64coopdx. It includes an API and hook system for interfacing with several components of the mod externally. This mod was originally made for sm64ex-coop but has been practically rewritten for sm64coopdx.\n\nDays last 24 minutes and with the /time command, you can get/set the time or change your settings.\n\nThere is also now a new menu in the pause menu for Day Night Cycle DX!\n\nSpecial thanks to \\#e06de4\\MaiskX3\\#dcdcdc\\ for the night time music.\nSpecial thanks to \\#00ffff\\AngelicMiracles\\#dcdcdc\\ for the sunset, sunrise and night time skyboxes.\nSpecial thanks to \\#344ee1\\eros71\\#dcdcdc\\ for salvaging\nthe mod files.
|
||||
|
||||
--- @class Vec2f
|
||||
--- @field public x number
|
||||
|
|
@ -12,8 +12,9 @@ gGlobalSyncTable.timeScale = tonumber(mod_storage_load("scale")) or 1.0
|
|||
gGlobalSyncTable.sunrise = HOUR_SUNRISE_START
|
||||
gGlobalSyncTable.sunset = HOUR_SUNSET_START
|
||||
|
||||
local init = true
|
||||
local init = false
|
||||
local timeModifier = 0
|
||||
local displayTime = mod_storage_load_bool_2("display_time")
|
||||
|
||||
-- localize functions to improve performance
|
||||
local math_floor,table_insert,get_skybox,set_lighting_dir,set_lighting_color,set_vertex_color,set_fog_color,set_fog_intensity,network_check_singleplayer_pause,network_player_connected_count,obj_get_first_with_behavior_id,network_is_server,spawn_non_sync_object,obj_scale,clampf,set_lighting_color_ambient,djui_hud_set_resolution,djui_hud_set_font,hud_get_value,hud_is_hidden,djui_hud_get_screen_width,djui_hud_measure_text,djui_hud_get_screen_height,djui_hud_set_color,play_sound,djui_chat_message_create,string_format,mod_storage_save_number,mod_storage_save_bool,get_date_and_time = math.floor,table.insert,get_skybox,set_lighting_dir,set_lighting_color,set_vertex_color,set_fog_color,set_fog_intensity,network_check_singleplayer_pause,network_player_connected_count,obj_get_first_with_behavior_id,network_is_server,spawn_non_sync_object,obj_scale,clampf,set_lighting_color_ambient,djui_hud_set_resolution,djui_hud_set_font,hud_get_value,hud_is_hidden,djui_hud_get_screen_width,djui_hud_measure_text,djui_hud_get_screen_height,djui_hud_set_color,play_sound,djui_chat_message_create,string.format,mod_storage_save_number,mod_storage_save_bool,get_date_and_time
|
||||
|
|
@ -105,7 +106,7 @@ local function update()
|
|||
if network_player_connected_count() == 1 and obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then return end
|
||||
|
||||
if network_is_server() then time_tick() end
|
||||
if not init then update_night_music() end
|
||||
if init then update_night_music() end
|
||||
|
||||
-- spawn skyboxes
|
||||
local skybox = get_skybox()
|
||||
|
|
@ -261,15 +262,22 @@ local function update()
|
|||
set_fog_color(1, fogColor.g)
|
||||
set_fog_color(2, fogColor.b)
|
||||
set_fog_intensity(intensity)
|
||||
|
||||
-- lighting engine compatibility
|
||||
if obj_get_first_with_behavior_id(id_bhvAmbientLight) ~= nil then
|
||||
mix = color_lerp(color, COLOR_WHITE, 0.5) -- make the color less intense
|
||||
le_set_ambient_color(mix.r, mix.g, mix.b)
|
||||
end
|
||||
else
|
||||
reset_lighting()
|
||||
end
|
||||
|
||||
init = false
|
||||
init = true
|
||||
end
|
||||
|
||||
local function on_hud_render_behind()
|
||||
if not is_dnc_enabled() or not dayNightCycleApi.displayTime then return end -- API checks
|
||||
if not is_dnc_enabled() then return end -- option check
|
||||
if not dayNightCycleApi.displayTime or not displayTime then return end -- API checks
|
||||
if check_common_hud_render_cancels() then return end -- game checks
|
||||
|
||||
djui_hud_set_resolution(RESOLUTION_N64)
|
||||
|
|
@ -397,6 +405,8 @@ local function on_add_command(msg)
|
|||
gGlobalSyncTable.time = gGlobalSyncTable.time + (amount * SECOND)
|
||||
dnc_call_hook(DNC_HOOK_SET_TIME, oldTime, gGlobalSyncTable.time)
|
||||
|
||||
update_mod_menu_element_inputbox(modMenuTimeModifier, msg)
|
||||
|
||||
djui_chat_message_create("[Day Night Cycle] Time set to " .. math_floor(gGlobalSyncTable.time / SECOND))
|
||||
|
||||
save_time()
|
||||
|
|
@ -418,6 +428,8 @@ local function on_scale_command(msg)
|
|||
gGlobalSyncTable.timeScale = scale
|
||||
mod_storage_save_number("scale", scale)
|
||||
|
||||
update_mod_menu_element_slider(modMenuTimeScale, scale) -- I wonder
|
||||
|
||||
djui_chat_message_create("[Day Night Cycle] Time scale set to " .. scale)
|
||||
|
||||
save_time()
|
||||
|
|
@ -430,6 +442,8 @@ end
|
|||
local function on_24h_command()
|
||||
use24h = not use24h
|
||||
mod_storage_save_bool("24h", use24h)
|
||||
|
||||
update_mod_menu_element_checkbox(modMenu24h, use24h)
|
||||
end
|
||||
|
||||
local function on_sync_command()
|
||||
|
|
@ -439,7 +453,7 @@ local function on_sync_command()
|
|||
return
|
||||
end
|
||||
|
||||
djui_chat_message_create("[Day Night Cycle] Attempting to sync in-game time with real world time...")
|
||||
djui_chat_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)
|
||||
|
|
@ -471,8 +485,10 @@ local function on_sync_sun_command()
|
|||
else
|
||||
djui_chat_message_create("[Day Night Cycle] Resetting sunrise and sunset times...")
|
||||
|
||||
set_sun_hours(4, 19)
|
||||
set_sun_hours(HOUR_SUNRISE_START_BASE, HOUR_SUNSET_START_BASE)
|
||||
end
|
||||
|
||||
update_mod_menu_element_checkbox(modMenuSyncSun, syncSun)
|
||||
end
|
||||
|
||||
local function on_music_command()
|
||||
|
|
@ -483,8 +499,24 @@ local function on_music_command()
|
|||
end
|
||||
|
||||
playNightMusic = not playNightMusic
|
||||
mod_storage_save_bool("night-music", playNightMusic)
|
||||
mod_storage_save_bool("night_music", playNightMusic)
|
||||
djui_chat_message_create("[Day Night Cycle] Night music status: " .. on_or_off(playNightMusic))
|
||||
|
||||
update_mod_menu_element_checkbox(modMenuMusic, playNightMusic)
|
||||
end
|
||||
|
||||
local function on_display_time_command()
|
||||
if _G.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.")
|
||||
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))
|
||||
|
||||
update_mod_menu_element_checkbox(modMenuDisplayTime, displayTime)
|
||||
end
|
||||
|
||||
--- @param msg string
|
||||
|
|
@ -523,6 +555,8 @@ local function on_time_command(msg)
|
|||
on_sync_sun_command()
|
||||
elseif args[1] == "music" then
|
||||
on_music_command()
|
||||
elseif args[1] == "display-time" then
|
||||
on_display_time_command()
|
||||
elseif args[1] ~= "" then
|
||||
djui_chat_message_create("\\#ffa0a0\\[Day Night Cycle] Unrecognized command '" .. args[1] .. "'")
|
||||
else
|
||||
|
|
@ -578,24 +612,6 @@ local function on_set_dnc_enabled(_, value)
|
|||
gGlobalSyncTable.dncEnabled = value
|
||||
end
|
||||
|
||||
--- @param value boolean
|
||||
local function on_set_24h_time(_, value)
|
||||
use24h = value
|
||||
mod_storage_save_bool("24h", value)
|
||||
end
|
||||
|
||||
--- @param value boolean
|
||||
local function on_set_night_time_music(_, value)
|
||||
if _G.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.")
|
||||
return
|
||||
end
|
||||
|
||||
playNightMusic = value
|
||||
mod_storage_save_bool("night_music", value)
|
||||
end
|
||||
|
||||
--- @param value integer
|
||||
local function on_set_time_scale(index, value)
|
||||
if _G.dayNightCycleApi.lockTime then
|
||||
|
|
@ -774,19 +790,26 @@ hook_event(HOOK_ON_WARP, on_warp)
|
|||
hook_event(HOOK_ON_EXIT, on_exit)
|
||||
hook_event(HOOK_ON_HUD_RENDER_BEHIND, on_hud_render_behind)
|
||||
|
||||
hook_chat_command("time", "\\#00ffff\\[set|add|scale|query|24h|sync|sync-sun|music]\\#dcdcdc\\ - The command handle for Day Night Cycle DX \\#7f7f7f\\(leave blank to toggle Day Night Cycle on or off)", on_time_command)
|
||||
hook_chat_command("time", "\\#00ffff\\[set|add|scale|query|24h|sync|sync-sun|music|display-time]\\#dcdcdc\\ - The command handle for Day Night Cycle DX \\#7f7f7f\\(leave blank to toggle Day Night Cycle on or off)", on_time_command)
|
||||
|
||||
hook_on_sync_table_change(gGlobalSyncTable, "sunrise", 0, on_sunrise_changed)
|
||||
hook_on_sync_table_change(gGlobalSyncTable, "sunset", 0, on_sunset_changed)
|
||||
|
||||
hook_mod_menu_checkbox("24 Hour Time", use24h, on_set_24h_time)
|
||||
hook_mod_menu_checkbox("Night Time Music", playNightMusic, on_set_night_time_music)
|
||||
hook_mod_menu_text(string.format("Version %d.%d.%d", DNC_VERSION_MAJOR, DNC_VERSION_MINOR, DNC_VERSION_PATCH))
|
||||
|
||||
if network_is_server() then hook_mod_menu_checkbox("Enable Day Night Cycle", gGlobalSyncTable.dncEnabled, on_set_dnc_enabled) end
|
||||
|
||||
modMenuDisplayTime = hook_mod_menu_checkbox("Display Time On HUD", displayTime, on_display_time_command)
|
||||
modMenu24h = hook_mod_menu_checkbox("24 Hour Time", use24h, on_24h_command)
|
||||
modMenuMusic = hook_mod_menu_checkbox("Night Time Music", playNightMusic, on_music_command)
|
||||
|
||||
if network_is_server() then
|
||||
hook_mod_menu_checkbox("Enable Day Night Cycle", gGlobalSyncTable.dncEnabled, on_set_dnc_enabled)
|
||||
hook_mod_menu_checkbox("Use Real Life Sunrise/Sunset Times", syncSun, on_sync_sun_command)
|
||||
hook_mod_menu_slider("Time Scale: " .. gGlobalSyncTable.timeScale, gGlobalSyncTable.timeScale, 0, 20, on_set_time_scale)
|
||||
hook_mod_menu_inputbox("Time Modifier", "0", 8, on_set_time_modifier)
|
||||
modMenuSyncSun = hook_mod_menu_checkbox("Use Real Life Sunrise/Sunset Times", syncSun, on_sync_sun_command)
|
||||
|
||||
modMenuTimeScale = hook_mod_menu_slider("Time Scale: " .. gGlobalSyncTable.timeScale, gGlobalSyncTable.timeScale, 0, 20, on_set_time_scale)
|
||||
modMenuTimeModifier = hook_mod_menu_inputbox("Time Modifier", "0", 8, on_set_time_modifier)
|
||||
hook_mod_menu_button("Add To Time", on_add_hour)
|
||||
hook_mod_menu_button("Query Time", on_query_command)
|
||||
end
|
||||
hook_mod_menu_button("Sync To Real Life Time", on_sync_command)
|
||||
end
|
||||
|
||||
hook_mod_menu_button("Query Time", on_query_command)
|
||||
Loading…
Add table
Reference in a new issue