update CS [build]
Some checks failed
Build coop / build-linux (push) Has been cancelled
Build coop / build-steamos (push) Has been cancelled
Build coop / build-windows-opengl (push) Has been cancelled
Build coop / build-windows-directx (push) Has been cancelled
Build coop / build-macos-arm (push) Has been cancelled
Build coop / build-macos-intel (push) Has been cancelled

This commit is contained in:
Agent X 2025-05-17 21:25:46 -04:00
parent 258db1f6e7
commit 68051b907b
29 changed files with 888 additions and 404 deletions

View file

@ -0,0 +1,3 @@
GITHUB_COMMIT_TIME = '05/16/2025 07:27:43 PM PST'
GITHUB_COMMIT_ID = '115b65e'
GITHUB_REPO = 'Squishy6094/character-select-coop'

View file

@ -1,6 +1,14 @@
-- localize functions to improve performance - a-utils.lua -- localize functions to improve performance - a-utils.lua
local string_lower,string_format,table_insert,get_date_and_time = string.lower,string.format,table.insert,get_date_and_time local string_lower,string_format,table_insert,get_date_and_time = string.lower,string.format,table.insert,get_date_and_time
-- Version Data --
MOD_VERSION_API = 1
MOD_VERSION_MAJOR = 14
MOD_VERSION_MINOR = 1
MOD_VERSION_INDEV = false
MOD_VERSION_STRING = tostring(MOD_VERSION_API) .. "." .. tostring(MOD_VERSION_MAJOR) .. (MOD_VERSION_MINOR > 0 and ("." .. tostring(MOD_VERSION_MINOR)) or "") .. (MOD_VERSION_INDEV and " (In-Dev)" or "")
MOD_VERSION_DEBUG = tostring(GITHUB_REPO) .. " | " .. tostring(GITHUB_COMMIT_ID) .. " | " .. tostring(GITHUB_COMMIT_TIME)
if VERSION_NUMBER < 38 then if VERSION_NUMBER < 38 then
djui_popup_create("\n\\#FFAAAA\\Character Select requires\n the latest version of CoopDX to use!\n\nYou can find CoopDX here:\n\\#6666FF\\https://sm64coopdx.com", 5) djui_popup_create("\n\\#FFAAAA\\Character Select requires\n the latest version of CoopDX to use!\n\nYou can find CoopDX here:\n\\#6666FF\\https://sm64coopdx.com", 5)
incompatibleClient = true incompatibleClient = true
@ -9,6 +17,8 @@ end
local dependacyFiles = { local dependacyFiles = {
-- Required Lua File -- Required Lua File
--"a-github.lua",
"dialog.lua",
"main.lua", "main.lua",
"n-hud.lua", "n-hud.lua",
"o-api.lua", "o-api.lua",
@ -24,41 +34,42 @@ local legacyFiles = {
"z-anims.lua", "z-anims.lua",
} }
local fileErrorList = {}
-- Check for Missing Files -- Check for Missing Files
local missingDependacyFiles = false
for i = 1, #dependacyFiles do for i = 1, #dependacyFiles do
if not mod_file_exists(dependacyFiles[i]) then if not mod_file_exists(dependacyFiles[i]) then
log_to_console("Character Select file missing: '" .. dependacyFiles[i] .. "'", CONSOLE_MESSAGE_ERROR) log_to_console("Character Select file missing: '" .. dependacyFiles[i] .. "'", CONSOLE_MESSAGE_WARNING)
missingDependacyFiles = true table_insert(fileErrorList, "Missing File '" .. dependacyFiles[i] .. "'")
end end
end end
if missingDependacyFiles then
djui_popup_create("\n\\#FFAAAA\\Character Select is missing\nan important file!\n\nYou can find a list of\nmissing files in the console!", 5)
incompatibleClient = true
return 0
end
-- Check for Legacy Files -- Check for Legacy Files
local foundLegacyFiles = false
for i = 1, #legacyFiles do for i = 1, #legacyFiles do
if mod_file_exists(legacyFiles[i]) then if mod_file_exists(legacyFiles[i]) then
log_to_console("Character Select legacy file found: '" .. legacyFiles[i] .. "'", CONSOLE_MESSAGE_ERROR) log_to_console("Character Select legacy file found: '" .. legacyFiles[i] .. "'", CONSOLE_MESSAGE_WARNING)
foundLegacyFiles = true table_insert(fileErrorList, "Legacy File '" .. legacyFiles[i] .. "'")
end end
end end
if foundLegacyFiles then if #fileErrorList > 0 then
djui_popup_create("\n\\#FFAAAA\\Character Select is loading\nan outdated file!\n\nYou can find a list of\nold files in the console!", 5)
incompatibleClient = true incompatibleClient = true
local frameCount = 0
hook_event(HOOK_UPDATE, function ()
frameCount = frameCount + 1
if frameCount == 5 then
local errorString = "\\#FFAAAA\\Character Select File Issues:"
djui_popup_create("\\#FFAAAA\\Character Select is having\nfile issues and cannot load!\n\nErrors have been logged in chat!", 4)
for i = 1, #fileErrorList do
errorString = errorString .. "\n" .. fileErrorList[i]
end
errorString = errorString .. "\n\nThe best way to resolve these issues is to delete your current version of Character Select and then install the latest version!"
log_to_console(errorString)
djui_chat_message_create(errorString)
end
end)
return 0 return 0
end end
-- Version Data --
MOD_VERSION_API = 1
MOD_VERSION_MAJOR = 13
MOD_VERSION_MINOR = 1
MOD_VERSION_INDEV = false
MOD_VERSION_STRING = tostring(MOD_VERSION_API) .. "." .. tostring(MOD_VERSION_MAJOR) .. (MOD_VERSION_MINOR > 0 and ("." .. tostring(MOD_VERSION_MINOR)) or "") .. (MOD_VERSION_INDEV and " (In-Dev)" or "")
ommActive = false ommActive = false
for i in pairs(gActiveMods) do for i in pairs(gActiveMods) do
if gActiveMods[i].relativePath == "omm-coop" then if gActiveMods[i].relativePath == "omm-coop" then
@ -67,49 +78,51 @@ for i in pairs(gActiveMods) do
end end
end end
E_MODEL_ARMATURE = smlua_model_util_get_id("armature_geo")
local saveableCharacters = { local saveableCharacters = {
["1"] = true, ["1"] = 1,
["2"] = true, ["2"] = 1,
["3"] = true, ["3"] = 1,
["4"] = true, ["4"] = 1,
["5"] = true, ["5"] = 1,
["6"] = true, ["6"] = 1,
["7"] = true, ["7"] = 1,
["8"] = true, ["8"] = 1,
["9"] = true, ["9"] = 1,
["0"] = true, ["0"] = 1,
["a"] = true, ["a"] = 1,
["b"] = true, ["b"] = 1,
["c"] = true, ["c"] = 1,
["d"] = true, ["d"] = 1,
["e"] = true, ["e"] = 1,
["f"] = true, ["f"] = 1,
["g"] = true, ["g"] = 1,
["h"] = true, ["h"] = 1,
["i"] = true, ["i"] = 1,
["j"] = true, ["j"] = 1,
["k"] = true, ["k"] = 1,
["l"] = true, ["l"] = 1,
["m"] = true, ["m"] = 1,
["n"] = true, ["n"] = 1,
["o"] = true, ["o"] = 1,
["p"] = true, ["p"] = 1,
["q"] = true, ["q"] = 1,
["r"] = true, ["r"] = 1,
["s"] = true, ["s"] = 1,
["t"] = true, ["t"] = 1,
["u"] = true, ["u"] = 1,
["v"] = true, ["v"] = 1,
["w"] = true, ["w"] = 1,
["x"] = true, ["x"] = 1,
["y"] = true, ["y"] = 1,
["z"] = true, ["z"] = 1,
["_"] = true, ["_"] = 1,
["-"] = true, ["-"] = 1,
["."] = true, ["."] = 1,
-- Replace with Underscore -- Replace with Underscore
[" "] = false, [" "] = 0,
} }
--- @param string string --- @param string string
@ -126,9 +139,9 @@ function string_space_to_underscore(string)
local s = '' local s = ''
for i = 1, #string do for i = 1, #string do
local c = string:sub(i,i) local c = string:sub(i,i)
if saveableCharacters[string_lower(c)] then if saveableCharacters[string_lower(c)] == 1 then
s = s .. c s = s .. c
elseif saveableCharacters[string_lower(c)] ~= nil then elseif saveableCharacters[string_lower(c)] == 0 then
s = s .. "_" s = s .. "_"
end end
end end
@ -137,9 +150,12 @@ end
--- @param string string --- @param string string
--- Splits a string into a table by spaces --- Splits a string into a table by spaces
function string_split(string) function string_split(string, splitAt)
if splitAt == nil then
splitAt = " "
end
local result = {} local result = {}
for match in string:gmatch(string_format("[^%s]+", " ")) do for match in string:gmatch(string_format("[^%s]+", splitAt)) do
table_insert(result, match) table_insert(result, match)
end end
return result return result

View file

@ -1,3 +1,5 @@
if incompatibleClient then return 0 end
-- Original Made by EliteMasterEric along with CoopDX PR #321 to replace dialog depending on character -- -- Original Made by EliteMasterEric along with CoopDX PR #321 to replace dialog depending on character --
-- https://github.com/coop-deluxe/sm64coopdx/pull/321 -- -- https://github.com/coop-deluxe/sm64coopdx/pull/321 --
-- Eric's Original stuffs will be added as soon as there is some way to directly get dialog strings -- Eric's Original stuffs will be added as soon as there is some way to directly get dialog strings
@ -107,7 +109,7 @@ define_cs_dialog(DIALOG_086, 1, 3, 30, 200, ("Running around in circles\nmakes s
define_cs_dialog(DIALOG_087, 1, 4, 30, 200, ("Santa Claus isn't the only\none who can go down a\nchimney! Come on in!\n/--Cabin Proprietor")) define_cs_dialog(DIALOG_087, 1, 4, 30, 200, ("Santa Claus isn't the only\none who can go down a\nchimney! Come on in!\n/--Cabin Proprietor"))
define_cs_dialog(DIALOG_088, 1, 5, 30, 200, ("Work Elevator\nFor those who get off\nhere: Grab the pole to the\nleft and slide carefully\ndown.")) define_cs_dialog(DIALOG_088, 1, 5, 30, 200, ("Work Elevator\nFor those who get off\nhere: Grab the pole to the\nleft and slide carefully\ndown."))
define_cs_dialog(DIALOG_089, 1, 5, 95, 200, ("Both ways fraught with\ndanger! Watch your feet!\nThose who can't do the\nLong Jump, tsk, tsk. Make\nyour way to the right.\nRight: Work Elevator\n/// Cloudy Maze\nLeft: Black Hole\n///Underground Lake\n\nRed Circle: Elevator 2\n//// Underground Lake\nArrow: You are here")) define_cs_dialog(DIALOG_089, 1, 5, 95, 200, ("Both ways fraught with\ndanger! Watch your feet!\nThose who can't do the\nLong Jump, tsk, tsk. Make\nyour way to the right.\nRight: Work Elevator\n/// Cloudy Maze\nLeft: Black Hole\n///Underground Lake\n\nRed Circle: Elevator 2\n//// Underground Lake\nArrow: You are here"))
define_cs_dialog(DIALOG_090, 1, 6, 30, 200, ("Bwa ha ha ha!\nYou've stepped right into\nmy trap, just as I knew\nyou would! I warn you,\n『Friend,』 watch your\nstep!")) define_cs_dialog(DIALOG_090, 1, 6, 30, 200, ("Bwa ha ha ha!\nYou've stepped right into\nmy trap, just as I knew\nyou would! I warn you,\n" .. ' "Friend," ' .. "watch your\nstep!"))
define_cs_dialog(DIALOG_091, 2, 2, 30, 200, ("Danger!\nStrong Gusts!\nBut the wind makes a\ncomfy ride.")) define_cs_dialog(DIALOG_091, 2, 2, 30, 200, ("Danger!\nStrong Gusts!\nBut the wind makes a\ncomfy ride."))
define_cs_dialog(DIALOG_092, 1, 5, 30, 200, ("Pestering me again, are\nyou, Mario? Can't you see\nthat I'm having a merry\nlittle time, making\nmischief with my minions?\nNow, return those Stars!\nMy troops in the walls\nneed them! Bwa ha ha!")) define_cs_dialog(DIALOG_092, 1, 5, 30, 200, ("Pestering me again, are\nyou, Mario? Can't you see\nthat I'm having a merry\nlittle time, making\nmischief with my minions?\nNow, return those Stars!\nMy troops in the walls\nneed them! Bwa ha ha!"))
define_cs_dialog(DIALOG_093, 1, 5, 30, 200, ("Mario! You again! Well\nthat's just fine--I've\nbeen looking for something\nto fry with my fire\nbreath!\nYour Star Power is\nuseless against me!\nYour friends are all\ntrapped within the\nwalls...\nAnd you'll never see the\nPrincess again!\nBwa ha ha ha!")) define_cs_dialog(DIALOG_093, 1, 5, 30, 200, ("Mario! You again! Well\nthat's just fine--I've\nbeen looking for something\nto fry with my fire\nbreath!\nYour Star Power is\nuseless against me!\nYour friends are all\ntrapped within the\nwalls...\nAnd you'll never see the\nPrincess again!\nBwa ha ha ha!"))
@ -201,7 +203,7 @@ local function dialog_swap(charName)
for i = DIALOG_000, #dialogTable do for i = DIALOG_000, #dialogTable do
if dialogTable[i] ~= nil then if dialogTable[i] ~= nil then
local dialog = dialogTable[i] local dialog = dialogTable[i]
charName = charName:gsub('"', "'") charName = charName:gsub('"', "''")
local replaced_dialog = dialog.str:gsub(DIALOG_NAME, charName) local replaced_dialog = dialog.str:gsub(DIALOG_NAME, charName)
real_dialog_replace(i, dialog.unused, dialog.linesPerBox, dialog.leftOffset, dialog.width, replaced_dialog) real_dialog_replace(i, dialog.unused, dialog.linesPerBox, dialog.leftOffset, dialog.width, replaced_dialog)
end end

View file

@ -1,10 +1,27 @@
-- name: Character Select -- name: Character Select
-- description:\\#ffff33\\-- Character Select Coop v1.13.1 --\n\n\\#dcdcdc\\A Library / API made to make adding and using Custom Characters as simple as possible!\nUse\\#ffff33\\ /char-select\\#dcdcdc\\ to get started!\n\nCreated by:\\#008800\\ Squishy6094\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop -- description:\\#ffff33\\-- Character Select Coop v1.14.1 --\n\n\\#dcdcdc\\A Library / API made to make adding and using Custom Characters as simple as possible!\nUse\\#ffff33\\ /char-select\\#dcdcdc\\ to get started!\n\nCreated by:\\#008800\\ Squishy6094\n\n\\#AAAAFF\\Updates can be found on\nCharacter Select's Github:\n\\#6666FF\\Squishy6094/character-select-coop
-- pausable: false -- pausable: false
-- category: cs -- category: cs
if incompatibleClient then return 0 end if incompatibleClient then return 0 end
--- @param hookEventType LuaHookedEventType
local function create_hook_wrapper(hookEventType)
local callbacks = {}
hook_event(hookEventType, function(...)
for _, func in pairs(callbacks) do
func(...)
end
end)
return function(func)
table.insert(callbacks, func)
end
end
cs_hook_mario_update = create_hook_wrapper(HOOK_MARIO_UPDATE)
-- localize functions to improve performance - main.lua -- localize functions to improve performance - main.lua
local mod_storage_load,tonumber,mod_storage_save,djui_popup_create,tostring,djui_chat_message_create,is_game_paused,obj_get_first_with_behavior_id,djui_hud_is_pause_menu_created,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,type,get_id_from_behavior,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,nearest_player_to_object,math_random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,min,math_min,math_ceil,math_abs,math_sin,minf,djui_hud_set_rotation,table_insert,djui_hud_print_text_interpolated,math_max,play_sound,play_character_sound,string_lower = mod_storage_load,tonumber,mod_storage_save,djui_popup_create,tostring,djui_chat_message_create,is_game_paused,obj_get_first_with_behavior_id,djui_hud_is_pause_menu_created,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,type,get_id_from_behavior,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,nearest_player_to_object,math.random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,min,math.min,math.ceil,math.abs,math.sin,minf,djui_hud_set_rotation,table.insert,djui_hud_print_text_interpolated,math.max,play_sound,play_character_sound,string.lower local mod_storage_load,tonumber,mod_storage_save,djui_popup_create,tostring,djui_chat_message_create,is_game_paused,obj_get_first_with_behavior_id,djui_hud_is_pause_menu_created,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,type,get_id_from_behavior,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,nearest_player_to_object,math_random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,min,math_min,math_ceil,math_abs,math_sin,minf,djui_hud_set_rotation,table_insert,djui_hud_print_text_interpolated,math_max,play_sound,play_character_sound,string_lower = mod_storage_load,tonumber,mod_storage_save,djui_popup_create,tostring,djui_chat_message_create,is_game_paused,obj_get_first_with_behavior_id,djui_hud_is_pause_menu_created,camera_freeze,hud_hide,vec3f_copy,set_mario_action,set_mario_animation,camera_unfreeze,hud_show,type,get_id_from_behavior,obj_has_behavior_id,network_local_index_from_global,obj_has_model_extended,obj_set_model_extended,nearest_player_to_object,math.random,djui_hud_set_resolution,djui_hud_set_font,djui_hud_get_screen_width,maxf,djui_hud_set_color,djui_hud_render_rect,djui_hud_measure_text,djui_hud_print_text,min,math.min,math.ceil,math.abs,math.sin,minf,djui_hud_set_rotation,table.insert,djui_hud_print_text_interpolated,math.max,play_sound,play_character_sound,string.lower
@ -14,6 +31,8 @@ options = false
local credits = false local credits = false
local creditsAndTransition = false local creditsAndTransition = false
currChar = 1 currChar = 1
currCharRender = 1
currCategory = 1
local currOption = 1 local currOption = 1
local creditScroll = 0 local creditScroll = 0
local prevCreditScroll = creditScroll local prevCreditScroll = creditScroll
@ -35,6 +54,8 @@ function header_set_texture(texture)
TEX_OVERRIDE_HEADER = texture TEX_OVERRIDE_HEADER = texture
end end
CS_ANIM_MENU = CHAR_ANIM_MAX + 1
local TEXT_PREF_LOAD_NAME = "Default" local TEXT_PREF_LOAD_NAME = "Default"
local TEXT_PREF_LOAD_ALT = 1 local TEXT_PREF_LOAD_ALT = 1
@ -48,6 +69,8 @@ local TEXT_PREF_LOAD_ALT = 1
characterTable = { characterTable = {
[1] = { [1] = {
saveName = "Default", saveName = "Default",
category = "All_CoopDX",
ogNum = 1,
currAlt = 1, currAlt = 1,
hasMoveset = false, hasMoveset = false,
locked = false, locked = false,
@ -85,6 +108,12 @@ characterTable = {
lifeIcon = gTextures.luigi_head, lifeIcon = gTextures.luigi_head,
starIcon = gTextures.star, starIcon = gTextures.star,
camScale = 1.0, camScale = 1.0,
healthTexture = {
label = {
left = get_texture_info("char-select-luigi-meter-left"),
right = get_texture_info("char-select-luigi-meter-right"),
}
}
}, },
[3] = { [3] = {
name = "Toad", name = "Toad",
@ -102,6 +131,12 @@ characterTable = {
lifeIcon = gTextures.toad_head, lifeIcon = gTextures.toad_head,
starIcon = gTextures.star, starIcon = gTextures.star,
camScale = 0.8, camScale = 0.8,
healthTexture = {
label = {
left = get_texture_info("char-select-toad-meter-left"),
right = get_texture_info("char-select-toad-meter-right"),
}
}
}, },
[4] = { [4] = {
name = "Waluigi", name = "Waluigi",
@ -119,6 +154,12 @@ characterTable = {
lifeIcon = gTextures.waluigi_head, lifeIcon = gTextures.waluigi_head,
starIcon = gTextures.star, starIcon = gTextures.star,
camScale = 1.1, camScale = 1.1,
healthTexture = {
label = {
left = get_texture_info("char-select-waluigi-meter-left"),
right = get_texture_info("char-select-waluigi-meter-right"),
}
}
}, },
[5] = { [5] = {
name = "Wario", name = "Wario",
@ -137,10 +178,52 @@ characterTable = {
lifeIcon = gTextures.wario_head, lifeIcon = gTextures.wario_head,
starIcon = gTextures.star, starIcon = gTextures.star,
camScale = 1.0, camScale = 1.0,
healthTexture = {
label = {
left = get_texture_info("char-select-wario-meter-left"),
right = get_texture_info("char-select-wario-meter-right"),
}
}
}, },
}, },
} }
characterCategories = {
"All",
"CoopDX",
"Locked",
}
local characterTableRender = {}
local function update_character_render_table()
local ogNum = currChar
currChar = 1
currCharRender = 1
local category = characterCategories[currCategory]
if category == nil then return false end
characterTableRender = {}
local listCount = 0
for i = 1, #characterTable do
local charCategories = string_split(characterTable[i].category, "_")
for c = 1, #charCategories do
if category == charCategories[c] and not characterTable[i].locked then
table_insert(characterTableRender, characterTable[i])
if ogNum == i then
currChar = ogNum
currCharRender = #characterTableRender
end
end
end
end
if #characterTableRender > 0 then
currChar = (characterTableRender[currCharRender] and characterTableRender[currCharRender].ogNum or characterTableRender[1].ogNum)
return true
else
return false
end
end
characterCaps = {} characterCaps = {}
characterCelebrationStar = {} characterCelebrationStar = {}
characterColorPresets = {} characterColorPresets = {}
@ -148,22 +231,27 @@ characterAnims = {}
characterMovesets = {[1] = {}} characterMovesets = {[1] = {}}
characterUnlock = {} characterUnlock = {}
tableRefNum = 0
local function make_table_ref_num()
tableRefNum = tableRefNum + 1
return tableRefNum
end
optionTableRef = { optionTableRef = {
-- Menu -- Menu
openInputs = 1, openInputs = make_table_ref_num(),
notification = 2, notification = make_table_ref_num(),
menuColor = 3, menuColor = make_table_ref_num(),
anims = 4, anims = make_table_ref_num(),
inputLatency = 5, inputLatency = make_table_ref_num(),
showLocked = 6,
-- Characters -- Characters
localMoveset = 7, localMoveset = make_table_ref_num(),
localModels = 8, localModels = make_table_ref_num(),
localVoices = 9, localVoices = make_table_ref_num(),
-- CS -- CS
credits = 10, credits = make_table_ref_num(),
debugInfo = 11, debugInfo = make_table_ref_num(),
resetSaveData = 12, resetSaveData = make_table_ref_num(),
} }
optionTable = { optionTable = {
@ -183,7 +271,7 @@ optionTable = {
toggleDefault = 1, toggleDefault = 1,
toggleMax = 2, toggleMax = 2,
toggleNames = {"Off", "On", "Pop-ups Only"}, toggleNames = {"Off", "On", "Pop-ups Only"},
description = {"Toggles wheather Pop-ups and", "Chat Messages display"} description = {"Toggles whether Pop-ups and", "Chat Messages display"}
}, },
[optionTableRef.menuColor] = { [optionTableRef.menuColor] = {
name = "Menu Color", name = "Menu Color",
@ -212,14 +300,6 @@ optionTable = {
toggleNames = {"Slow", "Normal", "Fast"}, toggleNames = {"Slow", "Normal", "Fast"},
description = {"Sets how fast you scroll", "throughout the Menu"} description = {"Sets how fast you scroll", "throughout the Menu"}
}, },
[optionTableRef.showLocked] = {
name = "Show Locked Chars",
toggle = tonumber(mod_storage_load("showLocked")),
toggleSaveName = "showLocked",
toggleDefault = 1,
toggleMax = 1,
description = {"Toggles if Locked Characters", "Display In-Menu"}
},
[optionTableRef.localMoveset] = { [optionTableRef.localMoveset] = {
name = "Character Moveset", name = "Character Moveset",
toggle = tonumber(mod_storage_load("localMoveset")), toggle = tonumber(mod_storage_load("localMoveset")),
@ -329,6 +409,7 @@ local prefCharColor = {r = 255, g = 50, b = 50}
local function load_preferred_char() local function load_preferred_char()
local savedChar = mod_storage_load("PrefChar") local savedChar = mod_storage_load("PrefChar")
local savedAlt = tonumber(mod_storage_load("PrefAlt")) local savedAlt = tonumber(mod_storage_load("PrefAlt"))
local savedPalette = tonumber(mod_storage_load("PrefPalette"))
if savedChar == nil or savedChar == "" then if savedChar == nil or savedChar == "" then
mod_storage_save("PrefChar", "Default") mod_storage_save("PrefChar", "Default")
savedChar = "Default" savedChar = "Default"
@ -337,29 +418,38 @@ local function load_preferred_char()
mod_storage_save("PrefAlt", "1") mod_storage_save("PrefAlt", "1")
savedAlt = 1 savedAlt = 1
end end
if savedChar ~= nil and savedChar ~= "Default" then if savedPalette == nil then
local paletteSave = savedChar ~= "Default" and 1 or 0
mod_storage_save("PrefAlt", tostring(paletteSave))
savedPalette = paletteSave
end
if savedChar ~= "Default" and optionTable[optionTableRef.localModels].toggle == 1 then
for i = 2, #characterTable do for i = 2, #characterTable do
local char = characterTable[i] local char = characterTable[i]
if char.saveName == savedChar and not char.locked then if char.saveName == savedChar and not char.locked then
currChar = i currChar = i
currCharRender = i
if savedAlt > 0 and savedAlt <= #char then if savedAlt > 0 and savedAlt <= #char then
char.currAlt = savedAlt char.currAlt = savedAlt
end end
if optionTable[optionTableRef.localModels].toggle == 1 then local model = characterTable[currChar][savedAlt].model
if optionTable[optionTableRef.notification].toggle > 0 then if characterColorPresets[model] ~= nil then
djui_popup_create('Character Select:\nYour Preferred Character\n"' .. string_underscore_to_space(char[char.currAlt].name) .. '"\nwas applied successfully!', 4) gCSPlayers[0].presetPalette = savedPalette
end characterColorPresets[model].currPalette = savedPalette
end
if optionTable[optionTableRef.notification].toggle > 0 then
djui_popup_create('Character Select:\nYour Preferred Character\n"' .. string_underscore_to_space(char[char.currAlt].name) .. '"\nwas applied successfully!', 4)
end end
break break
end end
end end
end end
characterTable[1].currAlt = gNetworkPlayers[0].modelIndex + 1 characterTable[1].currAlt = gNetworkPlayers[0].modelIndex + 1
local savedCharColors = mod_storage_load("PrefCharColor") local savedCharColors = mod_storage_load("PrefCharColor")
if savedCharColors ~= nil and savedCharColors ~= "" then if savedCharColors ~= nil and savedCharColors ~= "" then
local savedCharColorsTable = string_split(string_underscore_to_space(savedCharColors)) local savedCharColorsTable = string_split(savedCharColors, "_")
prefCharColor = { prefCharColor = {
r = tonumber(savedCharColorsTable[1]), r = tonumber(savedCharColorsTable[1]),
g = tonumber(savedCharColorsTable[2]), g = tonumber(savedCharColorsTable[2]),
@ -376,12 +466,14 @@ local function load_preferred_char()
end end
TEXT_PREF_LOAD_NAME = savedChar TEXT_PREF_LOAD_NAME = savedChar
TEXT_PREF_LOAD_ALT = savedAlt TEXT_PREF_LOAD_ALT = savedAlt
update_character_render_table()
end end
local function mod_storage_save_pref_char(charTable) local function mod_storage_save_pref_char(charTable)
mod_storage_save("PrefChar", charTable.saveName) mod_storage_save("PrefChar", charTable.saveName)
mod_storage_save("PrefAlt", tostring(charTable.currAlt)) mod_storage_save("PrefAlt", tostring(charTable.currAlt))
mod_storage_save("PrefCharColor", tostring(charTable[charTable.currAlt].color.r) .. "_" .. tostring(charTable[charTable.currAlt].color.g) .. "_" .. tostring(charTable[charTable.currAlt].color.b)) mod_storage_save("PrefCharColor", tostring(charTable[charTable.currAlt].color.r) .. "_" .. tostring(charTable[charTable.currAlt].color.g) .. "_" .. tostring(charTable[charTable.currAlt].color.b))
mod_storage_save("PrefPalette", tostring(gCSPlayers[0].presetPalette))
TEXT_PREF_LOAD_NAME = charTable.saveName TEXT_PREF_LOAD_NAME = charTable.saveName
TEXT_PREF_LOAD_ALT = charTable.currAlt TEXT_PREF_LOAD_ALT = charTable.currAlt
prefCharColor = charTable[charTable.currAlt].color prefCharColor = charTable[charTable.currAlt].color
@ -467,6 +559,7 @@ local function menu_is_allowed(m)
return true return true
end end
--[[
local function get_next_unlocked_char() local function get_next_unlocked_char()
for i = currChar, #characterTable do for i = currChar, #characterTable do
if not characterTable[i].locked then if not characterTable[i].locked then
@ -484,6 +577,7 @@ local function get_last_unlocked_char()
end end
return 1 return 1
end end
]]
------------------- -------------------
-- Model Handler -- -- Model Handler --
@ -493,11 +587,6 @@ local stallFrame = 0
CUTSCENE_CS_MENU = 0xFA CUTSCENE_CS_MENU = 0xFA
local ignoredSurfaces = {
SURFACE_BURNING, SURFACE_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_INSTANT_MOVING_QUICKSAND, SURFACE_DEEP_MOVING_QUICKSAND, SURFACE_INSTANT_QUICKSAND, SURFACE_DEEP_QUICKSAND, SURFACE_SHALLOW_MOVING_QUICKSAND,
SURFACE_SHALLOW_QUICKSAND, SURFACE_WARP, SURFACE_LOOK_UP_WARP, SURFACE_WOBBLING_WARP, SURFACE_INSTANT_WARP_1B, SURFACE_INSTANT_WARP_1C, SURFACE_INSTANT_WARP_1D, SURFACE_INSTANT_WARP_1E
}
local TYPE_FUNCTION = "function" local TYPE_FUNCTION = "function"
local TYPE_BOOLEAN = "boolean" local TYPE_BOOLEAN = "boolean"
local TYPE_STRING = "string" local TYPE_STRING = "string"
@ -506,31 +595,6 @@ local TYPE_TABLE = "table"
local MATH_PI = math.pi local MATH_PI = math.pi
local menuActBlacklist = {
-- Star Acts
[ACT_FALL_AFTER_STAR_GRAB] = true,
[ACT_STAR_DANCE_EXIT] = true,
[ACT_STAR_DANCE_NO_EXIT] = true,
[ACT_STAR_DANCE_WATER] = true,
-- Key Acts
[ACT_UNLOCKING_KEY_DOOR] = true,
[ACT_UNLOCKING_STAR_DOOR] = true,
-- Cutscene Acts
[ACT_INTRO_CUTSCENE] = true,
[ACT_CREDITS_CUTSCENE] = true,
[ACT_WARP_DOOR_SPAWN] = true,
[ACT_PULLING_DOOR] = true,
[ACT_PUSHING_DOOR] = true,
[ACT_UNLOCKING_KEY_DOOR] = true,
[ACT_UNLOCKING_STAR_DOOR] = true,
[ACT_IN_CANNON] = true,
-- Dialog Acts
[ACT_READING_NPC_DIALOG] = true,
[ACT_WAITING_FOR_DIALOG] = true,
[ACT_EXIT_LAND_SAVE_DIALOG] = true,
[ACT_READING_AUTOMATIC_DIALOG] = true,
}
local prevBaseCharFrame = gNetworkPlayers[0].modelIndex local prevBaseCharFrame = gNetworkPlayers[0].modelIndex
local prevAnim = 0 local prevAnim = 0
local animTimer = 0 local animTimer = 0
@ -565,24 +629,22 @@ local function mario_update(m)
end end
prevBaseCharFrame = np.modelIndex prevBaseCharFrame = np.modelIndex
local defaultTable = characterTable[1] if optionTable[optionTableRef.localModels].toggle == 0 then
currCategory = 1
currChar = 1
currCharRender = 1
end
local charTable = characterTable[currChar] local charTable = characterTable[currChar]
p.saveName = charTable.saveName p.saveName = charTable.saveName
p.currAlt = charTable.currAlt p.currAlt = charTable.currAlt
if optionTable[optionTableRef.localModels].toggle > 0 then p.modelId = charTable[charTable.currAlt].model
p.modelId = charTable[charTable.currAlt].model if charTable[charTable.currAlt].forceChar ~= nil then
if charTable[charTable.currAlt].forceChar ~= nil then p.forceChar = charTable[charTable.currAlt].forceChar
p.forceChar = charTable[charTable.currAlt].forceChar
end
p.modelEditOffset = charTable[charTable.currAlt].model - charTable[charTable.currAlt].ogModel
m.marioObj.hookRender = 1
else
p.modelId = nil
p.forceChar = defaultTable.forceChar
p.modelEditOffset = 0
currChar = 1
end end
p.modelEditOffset = charTable[charTable.currAlt].model - charTable[charTable.currAlt].ogModel
m.marioObj.hookRender = 1
if menuAndTransition then if menuAndTransition then
--play_secondary_music(0, 0, 0.5, 0) --play_secondary_music(0, 0, 0.5, 0)
@ -603,7 +665,7 @@ local function mario_update(m)
gLakituState.pos.x = m.pos.x + sins(faceAngle) * 500 * camScale gLakituState.pos.x = m.pos.x + sins(faceAngle) * 500 * camScale
gLakituState.pos.y = m.pos.y + 100 * camScale gLakituState.pos.y = m.pos.y + 100 * camScale
gLakituState.pos.z = m.pos.z + coss(faceAngle) * 500 * camScale gLakituState.pos.z = m.pos.z + coss(faceAngle) * 500 * camScale
set_window_title("Character Select v".. MOD_VERSION_STRING .. " - " .. string_underscore_to_space(charTable[charTable.currAlt].name)) set_window_title("Character Select v".. MOD_VERSION_STRING .. " - " .. string_underscore_to_space(charTable[charTable.currAlt].name) .. " (CoopDX)")
p.inMenu = true p.inMenu = true
else else
if p.inMenu then if p.inMenu then
@ -632,15 +694,18 @@ local function mario_update(m)
if type(unlock) == TYPE_FUNCTION then if type(unlock) == TYPE_FUNCTION then
if unlock() then if unlock() then
currChar.locked = false currChar.locked = false
if stallFrame == 3 and notif then
if optionTable[optionTableRef.notification].toggle > 0 then
djui_popup_create('Character Select:\nUnlocked '..currChar.name..'\nas a Playable Character!', 3)
end
end
end end
elseif type(unlock) == TYPE_BOOLEAN then elseif type(unlock) == TYPE_BOOLEAN then
currChar.locked = not unlock currChar.locked = not unlock
end end
if not currChar.locked then -- Character was unlocked
update_character_render_table()
if stallFrame == 3 and notif then
if optionTable[optionTableRef.notification].toggle > 0 then
djui_popup_create('Character Select:\nUnlocked '..tostring(currChar[1].name)..'\nas a Playable Character!', 3)
end
end
end
end end
end end
@ -663,8 +728,10 @@ local function mario_update(m)
p.movesetToggle = optionTable[optionTableRef.localMoveset].toggle ~= 0 p.movesetToggle = optionTable[optionTableRef.localMoveset].toggle ~= 0
end end
if p.inMenu and m.forwardVel == 0 and m.pos.y == m.floorHeight and not ignoredSurfaces[m.floor.type] and m.health > 255 and not menuActBlacklist[m.action] then if p.inMenu and m.action & ACT_FLAG_ALLOW_FIRST_PERSON ~= 0 then
set_mario_animation(m, MARIO_ANIM_FIRST_PERSON) set_mario_animation(m, (characterAnims[p.modelId] and characterAnims[p.modelId][CS_ANIM_MENU]) and CS_ANIM_MENU or MARIO_ANIM_IDLE_HEAD_LEFT)
set_anim_to_frame(m, 0)
m.marioObj.header.gfx.angle.y = m.faceAngle.y
end end
local marioGfx = m.marioObj.header.gfx local marioGfx = m.marioObj.header.gfx
@ -674,12 +741,7 @@ local function mario_update(m)
end end
animTimer = animTimer + 1 animTimer = animTimer + 1
np.overrideModelIndex = p.forceChar ~= nil and p.forceChar or CT_MARIO
if p.forceChar ~= nil then
np.overrideModelIndex = p.forceChar
else
np.overrideModelIndex = CT_MARIO
end
-- Character Animations -- Character Animations
if characterAnims[p.modelId] then if characterAnims[p.modelId] then
@ -709,12 +771,13 @@ local function on_star_or_key_grab(m, o, type)
end end
end end
local settingModel
function set_model(o, model) function set_model(o, model)
if settingModel then return end
if optionTable[optionTableRef.localModels].toggle == 0 then return end if optionTable[optionTableRef.localModels].toggle == 0 then return end
-- Player Models
if obj_has_behavior_id(o, id_bhvMario) ~= 0 then if obj_has_behavior_id(o, id_bhvMario) ~= 0 then
local i = network_local_index_from_global(o.globalPlayerIndex) local i = network_local_index_from_global(o.globalPlayerIndex)
local prevModelData = obj_get_model_id_extended(o)
local localModelData = nil local localModelData = nil
for c = 1, #characterTable do for c = 1, #characterTable do
if gCSPlayers[i].saveName == characterTable[c].saveName then if gCSPlayers[i].saveName == characterTable[c].saveName then
@ -725,27 +788,23 @@ function set_model(o, model)
end end
if localModelData ~= nil then if localModelData ~= nil then
if obj_has_model_extended(o, localModelData) == 0 then if obj_has_model_extended(o, localModelData) == 0 then
settingModel = true
obj_set_model_extended(o, localModelData) obj_set_model_extended(o, localModelData)
settingModel = false
end end
else else
-- Original/Backup -- Original/Backup
if gCSPlayers[i].modelId ~= nil and obj_has_model_extended(o, gCSPlayers[i].modelId) == 0 then if gCSPlayers[i].modelId ~= nil and obj_has_model_extended(o, gCSPlayers[i].modelId) == 0 then
settingModel = true
obj_set_model_extended(o, gCSPlayers[i].modelId) obj_set_model_extended(o, gCSPlayers[i].modelId)
settingModel = false
end end
end end
return return
end end
-- Star Models
if obj_has_behavior_id(o, id_bhvCelebrationStar) ~= 0 and o.parentObj ~= nil then if obj_has_behavior_id(o, id_bhvCelebrationStar) ~= 0 and o.parentObj ~= nil then
local i = network_local_index_from_global(o.parentObj.globalPlayerIndex) local i = network_local_index_from_global(o.parentObj.globalPlayerIndex)
local starModel = characterCelebrationStar[gCSPlayers[i].modelId] local starModel = characterCelebrationStar[gCSPlayers[i].modelId]
if gCSPlayers[i].modelId ~= nil and starModel ~= nil and obj_has_model_extended(o, starModel) == 0 and not BowserKey then if gCSPlayers[i].modelId ~= nil and starModel ~= nil and obj_has_model_extended(o, starModel) == 0 and not BowserKey then
settingModel = true
obj_set_model_extended(o, starModel) obj_set_model_extended(o, starModel)
settingModel = false
end end
return return
end end
@ -773,15 +832,14 @@ function set_model(o, model)
capModel = capModels.metalWing capModel = capModels.metalWing
end end
if capModel ~= E_MODEL_NONE and capModel ~= E_MODEL_ERROR_MODEL and capModel ~= nil then if capModel ~= E_MODEL_NONE and capModel ~= E_MODEL_ERROR_MODEL and capModel ~= nil then
settingModel = true
obj_set_model_extended(o, capModel) obj_set_model_extended(o, capModel)
settingModel = false
end end
end end
end end
end end
hook_event(HOOK_MARIO_UPDATE, mario_update) --hook_event(HOOK_MARIO_UPDATE, mario_update)
cs_hook_mario_update(mario_update)
hook_event(HOOK_ON_INTERACT, on_star_or_key_grab) hook_event(HOOK_ON_INTERACT, on_star_or_key_grab)
hook_event(HOOK_OBJECT_SET_MODEL, set_model) hook_event(HOOK_OBJECT_SET_MODEL, set_model)
@ -808,8 +866,9 @@ local yearsOfCS = get_date_and_time().year - 123 -- Zero years as of 2023
local TEXT_VERSION = "Version: " .. MOD_VERSION_STRING .. " | sm64coopdx" .. (seasonalEvent == SEASON_EVENT_BIRTHDAY and (" | " .. tostring(yearsOfCS) .. " year" .. (yearsOfCS > 1 and "s" or "") .. " of Character Select!") or "") local TEXT_VERSION = "Version: " .. MOD_VERSION_STRING .. " | sm64coopdx" .. (seasonalEvent == SEASON_EVENT_BIRTHDAY and (" | " .. tostring(yearsOfCS) .. " year" .. (yearsOfCS > 1 and "s" or "") .. " of Character Select!") or "")
local TEXT_RATIO_UNSUPPORTED = "Your Current Aspect-Ratio isn't Supported!" local TEXT_RATIO_UNSUPPORTED = "Your Current Aspect-Ratio isn't Supported!"
local TEXT_DESCRIPTION = "Character Description:" local TEXT_DESCRIPTION = "Character Description:"
local TEXT_PREF_SAVE = "Press A to Set as Preferred Character" local TEXT_PREF_SAVE = "Preferred Char (A)"
local TEXT_PREF_SAVE_AND_PALETTE = "A - Set Preference | Y - Toggle Palette" local TEXT_PREF_PALETTE = "Toggle Palette (Y)"
local TEXT_MOVESET_INFO = "Moveset Info (Z)"
local TEXT_PAUSE_Z_OPEN = "Z Button - Character Select" local TEXT_PAUSE_Z_OPEN = "Z Button - Character Select"
local TEXT_PAUSE_UNAVAILABLE = "Character Select is Unavailable" local TEXT_PAUSE_UNAVAILABLE = "Character Select is Unavailable"
local TEXT_PAUSE_CURR_CHAR = "Current Character: " local TEXT_PAUSE_CURR_CHAR = "Current Character: "
@ -839,6 +898,8 @@ local TEXT_MENU_CLOSE = "Press B to Exit Menu"
local TEXT_OPTIONS_SELECT = "A - Select | B - Exit " local TEXT_OPTIONS_SELECT = "A - Select | B - Exit "
local TEXT_LOCAL_MODEL_OFF = "Locally Display Models is Off" local TEXT_LOCAL_MODEL_OFF = "Locally Display Models is Off"
local TEXT_LOCAL_MODEL_OFF_OPTIONS = "You can turn it back on in the Options Menu" local TEXT_LOCAL_MODEL_OFF_OPTIONS = "You can turn it back on in the Options Menu"
local TEXT_LOCAL_MODEL_ERROR = "Failed to find a Character Model"
local TEXT_LOCAL_MODEL_ERROR_FIX = "Please Verify the Integrity of the Pack!"
--Credit Text --Credit Text
local TEXT_CREDITS_HEADER = "Credits" local TEXT_CREDITS_HEADER = "Credits"
@ -861,22 +922,34 @@ local targetMenuColor = {r = 0 , g = 0, b = 0}
menuColor = targetMenuColor menuColor = targetMenuColor
local menuColorHalf = menuColor local menuColorHalf = menuColor
local transSpeed = 0.1 local transSpeed = 0.1
local prevBindText = ""
local bindText = 1
local bindTextTimerLoop = 150
local bindTextTimer = 0
local bindTextOpacity = -255
function update_menu_color() function update_menu_color()
if optionTable[optionTableRef.menuColor].toggle > 1 then if optionTable[optionTableRef.menuColor].toggle == nil then return end
targetMenuColor = menuColorTable[optionTable[optionTableRef.menuColor].toggle - 1] if optionTable[optionTableRef.localModels].toggle == 1 then
elseif optionTable[optionTableRef.menuColor].toggle == 1 then if optionTable[optionTableRef.menuColor].toggle > 1 then
optionTable[optionTableRef.menuColor].toggleNames[2] = string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. ((TEXT_PREF_LOAD_ALT ~= 1 and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "") .. " (Pref)" targetMenuColor = menuColorTable[optionTable[optionTableRef.menuColor].toggle - 1]
targetMenuColor = prefCharColor elseif optionTable[optionTableRef.menuColor].toggle == 1 then
elseif characterTable[currChar] ~= nil then optionTable[optionTableRef.menuColor].toggleNames[2] = string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. ((TEXT_PREF_LOAD_ALT ~= 1 and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "") .. " (Pref)"
local char = characterTable[currChar] targetMenuColor = prefCharColor
targetMenuColor = char[char.currAlt].color elseif characterTable[currChar] ~= nil then
local char = characterTable[currChar]
targetMenuColor = char[char.currAlt].color
end
else
targetMenuColor = menuColorTable[9]
end end
if optionTable[optionTableRef.anims].toggle > 0 then if optionTable[optionTableRef.anims].toggle > 0 then
menuColor.r = lerp(menuColor.r, targetMenuColor.r, transSpeed) menuColor.r = lerp(menuColor.r, targetMenuColor.r, transSpeed)
menuColor.g = lerp(menuColor.g, targetMenuColor.g, transSpeed) menuColor.g = lerp(menuColor.g, targetMenuColor.g, transSpeed)
menuColor.b = lerp(menuColor.b, targetMenuColor.b, transSpeed) menuColor.b = lerp(menuColor.b, targetMenuColor.b, transSpeed)
else else
menuColor = targetMenuColor menuColor.r = targetMenuColor.r
menuColor.g = targetMenuColor.g
menuColor.b = targetMenuColor.b
end end
menuColorHalf = { menuColorHalf = {
r = menuColor.r * 0.5 + 127, r = menuColor.r * 0.5 + 127,
@ -893,20 +966,24 @@ end
local buttonAltAnim = 0 local buttonAltAnim = 0
local menuOpacity = 245 local menuOpacity = 245
local menuText = {}
local function on_hud_render() local function on_hud_render()
local FONT_USER = djui_menu_get_font() local FONT_USER = djui_menu_get_font()
djui_hud_set_resolution(RESOLUTION_N64)
djui_hud_set_font(FONT_ALIASED) djui_hud_set_font(FONT_ALIASED)
djui_hud_set_resolution(RESOLUTION_DJUI)
local width = djui_hud_get_screen_width() + 1.4 local djuiWidth = djui_hud_get_screen_width()
local djuiHeight = djui_hud_get_screen_height()
djui_hud_set_resolution(RESOLUTION_N64)
local width = djuiWidth * (240/djuiHeight) -- Get accurate, unrounded width
local height = 240 local height = 240
local widthHalf = width * 0.5 local widthHalf = width * 0.5
local heightHalf = height * 0.5 local heightHalf = height * 0.5
local widthScale = maxf(width, 321.4) * MATH_DIVIDE_320 local widthScale = maxf(width, 320) * MATH_DIVIDE_320
update_menu_color() update_menu_color()
if menuAndTransition then if menuAndTransition then
if optionTable[optionTableRef.localModels].toggle == 0 then if optionTable[optionTableRef.localModels].toggle == 0 then
djui_hud_set_color(0, 0, 0, 200) djui_hud_set_color(0, 0, 0, 200)
djui_hud_render_rect(0, 0, width, height) djui_hud_render_rect(0, 0, width, height)
@ -915,6 +992,14 @@ local function on_hud_render()
djui_hud_print_text(TEXT_LOCAL_MODEL_OFF_OPTIONS, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF_OPTIONS) * 0.1 * widthScale, heightHalf + 10 * widthScale, 0.2 * widthScale) djui_hud_print_text(TEXT_LOCAL_MODEL_OFF_OPTIONS, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_OFF_OPTIONS) * 0.1 * widthScale, heightHalf + 10 * widthScale, 0.2 * widthScale)
end end
if characterTable[currChar][characterTable[currChar].currAlt].model == E_MODEL_ARMATURE then
djui_hud_set_color(0, 0, 0, 200)
djui_hud_render_rect(0, 0, width, height)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_print_text(TEXT_LOCAL_MODEL_ERROR, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_ERROR) * 0.15 * widthScale, heightHalf, 0.3 * widthScale)
djui_hud_print_text(TEXT_LOCAL_MODEL_ERROR_FIX, widthHalf - djui_hud_measure_text(TEXT_LOCAL_MODEL_ERROR_FIX) * 0.1 * widthScale, heightHalf + 10 * widthScale, 0.2 * widthScale)
end
local x = 135 * widthScale * 0.8 local x = 135 * widthScale * 0.8
-- Render All Black Squares Behind Below API -- Render All Black Squares Behind Below API
@ -926,7 +1011,6 @@ local function on_hud_render()
-- Header -- Header
djui_hud_render_rect(2, 2, width - 4, 46) djui_hud_render_rect(2, 2, width - 4, 46)
-- API Rendering (Below Text) -- API Rendering (Below Text)
if #renderInMenuTable.back > 0 then if #renderInMenuTable.back > 0 then
for i = 1, #renderInMenuTable.back do for i = 1, #renderInMenuTable.back do
@ -953,16 +1037,7 @@ local function on_hud_render()
local TEXT_NAME = string_underscore_to_space(character.name) local TEXT_NAME = string_underscore_to_space(character.name)
local TEXT_CREDIT = "Credit: " .. character.credit local TEXT_CREDIT = "Credit: " .. character.credit
local TEXT_DESCRIPTION_TABLE = character.description local TEXT_DESCRIPTION_TABLE = character.description
local TEXT_PRESET = "Preset Character Palette: "..((paletteCount > 1 and "("..currPaletteTable.currPalette.."/"..paletteCount..")" or (currPaletteTable.currPalette > 0 and "On" or "Off")) or "Off") local TEXT_PREF_LOAD_NAME = string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. ((TEXT_PREF_LOAD_ALT ~= 1 and TEXT_PREF_LOAD_NAME ~= "Default" and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "")
local TEXT_PREF = "Preferred Character:"
local TEXT_PREF_LOAD_NAME = ' "' .. string_underscore_to_space(TEXT_PREF_LOAD_NAME) .. '"' .. ((TEXT_PREF_LOAD_ALT ~= 1 and TEXT_PREF_LOAD_NAME ~= "Default" and currChar ~= 1) and " ("..TEXT_PREF_LOAD_ALT..")" or "")
if djui_hud_measure_text(TEXT_PREF_LOAD_NAME) / widthScale > 110 then
TEXT_PREF = "Preferred Char:"
end
if djui_hud_measure_text(TEXT_PREF_LOAD_NAME) / widthScale > 164 then
TEXT_PREF = "Pref Char:"
end
TEXT_PREF = TEXT_PREF .. TEXT_PREF_LOAD_NAME
local textX = x * 0.5 local textX = x * 0.5
djui_hud_print_text(TEXT_NAME, width - textX - djui_hud_measure_text(TEXT_NAME) * 0.3, 55, 0.6) djui_hud_print_text(TEXT_NAME, width - textX - djui_hud_measure_text(TEXT_NAME) * 0.3, 55, 0.6)
@ -989,17 +1064,46 @@ local function on_hud_render()
end end
end end
menuText = {
TEXT_PREF_SAVE .. " - " .. TEXT_PREF_LOAD_NAME
}
local modelId = gCSPlayers[0].modelId local modelId = gCSPlayers[0].modelId
djui_hud_print_text(TEXT_PREF, width - textX - djui_hud_measure_text(TEXT_PREF) * 0.15, height - 22, 0.3) local TEXT_PRESET_TOGGLE = ((currPaletteTable[currPaletteTable.currPalette] ~= nil and currPaletteTable[currPaletteTable.currPalette].name ~= nil) and (currPaletteTable[currPaletteTable.currPalette].name .. " - ") or "") .. ((paletteCount > 1 and "("..currPaletteTable.currPalette.."/"..paletteCount..")" or (currPaletteTable.currPalette > 0 and "On" or "Off")) or "Off")
local text = TEXT_PREF_SAVE
if characterColorPresets[modelId] and not stopPalettes then if characterColorPresets[modelId] and not stopPalettes then
djui_hud_print_text(TEXT_PRESET, width - textX - djui_hud_measure_text(TEXT_PRESET) * 0.15, height - 31, 0.3) table_insert(menuText, TEXT_PREF_PALETTE .. " - " .. TEXT_PRESET_TOGGLE)
text = TEXT_PREF_SAVE_AND_PALETTE
elseif stopPalettes then elseif stopPalettes then
djui_hud_print_text(TEXT_PALETTE_RESTRICTED, width - textX - djui_hud_measure_text(TEXT_PALETTE_RESTRICTED) * 0.15, height - 31, 0.3) table_insert(menuText, TEXT_PALETTE_RESTRICTED)
end end
djui_hud_set_font(FONT_TINY) if #menuText > 1 then
djui_hud_print_text(text, width - textX - djui_hud_measure_text(TEXT_PREF_SAVE) * 0.25, height - 13, 0.5) bindTextTimer = (bindTextTimer + 1)%(bindTextTimerLoop)
end
if bindTextTimer == 0 then
bindText = bindText + 1
bindTextOpacity = -254
end
if bindText > #menuText or not menuText[bindText] then
bindText = 1
end
if menuText[bindText] ~= prevBindText and bindTextOpacity == -255 then
bindTextOpacity = -254
end
if bindTextOpacity > -255 and bindTextOpacity < 255 then
bindTextOpacity = math.min(bindTextOpacity + 25, 255)
if bindTextOpacity == 255 then
bindTextOpacity = -255
prevBindText = menuText[bindText]
end
end
--local bindTextOpacity = clamp(math.abs(math.sin(bindTextTimer*MATH_PI/bindTextTimerLoop)), 0, 0.2) * 5 * 255
local fadeOut = math_abs(clamp(bindTextOpacity, -255, 0))
local fadeIn = math_abs(clamp(bindTextOpacity, 0, 255))
local bindTextScale = math.min((x - 10)/(djui_hud_measure_text(menuText[bindText]) * 0.3), 1)*0.3
local prevBindTextScale = math.min((x - 10)/(djui_hud_measure_text(prevBindText) * 0.3), 1)*0.3
djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, fadeOut)
djui_hud_print_text(prevBindText, width - textX - djui_hud_measure_text(prevBindText) * prevBindTextScale*0.5, height - 15, prevBindTextScale)
djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, fadeIn)
djui_hud_print_text(menuText[bindText], width - textX - djui_hud_measure_text(menuText[bindText]) * bindTextScale*0.5, height - 15, bindTextScale)
djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255)
else else
-- Debugging Info -- -- Debugging Info --
local TEXT_NAME = "Name: " .. character.name local TEXT_NAME = "Name: " .. character.name
@ -1129,24 +1233,8 @@ local function on_hud_render()
local charNum = -1 local charNum = -1
for i = -1, 4 do for i = -1, 4 do
-- Hide Locked Characters based on Toggle -- Hide Locked Characters based on Toggle
charNum = currChar + i charNum = currCharRender + i
local char = characterTable[charNum] local char = characterTableRender[charNum]
if optionTable[optionTableRef.showLocked].toggle == 0 and char ~= nil and char.locked then
if i < 0 then
repeat
charNum = charNum - 1
until characterTable[charNum] == nil or (not characterTable[charNum].locked)
charNum = charNum + 1
else
repeat
charNum = charNum + 1
until characterTable[charNum] == nil or (not characterTable[charNum].locked)
charNum = charNum - 1
end
charNum = charNum + i
end
local char = characterTable[charNum]
if char ~= nil then if char ~= nil then
if not char.locked then if not char.locked then
buttonColor = char[char.currAlt].color buttonColor = char[char.currAlt].color
@ -1189,7 +1277,7 @@ local function on_hud_render()
end end
-- Scroll Bar -- Scroll Bar
local MATH_DIVIDE_CHARACTERS = 1/#characterTable local MATH_DIVIDE_CHARACTERS = 1/#characterTableRender
local MATH_7_WIDTHSCALE = 7 * widthScale local MATH_7_WIDTHSCALE = 7 * widthScale
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_render_rect(MATH_7_WIDTHSCALE, 55, 1, 170) djui_hud_render_rect(MATH_7_WIDTHSCALE, 55, 1, 170)
@ -1197,10 +1285,11 @@ local function on_hud_render()
djui_hud_render_rect(MATH_7_WIDTHSCALE + 6, 55, 1, 170) djui_hud_render_rect(MATH_7_WIDTHSCALE + 6, 55, 1, 170)
djui_hud_render_rect(MATH_7_WIDTHSCALE, 224, 7, 1) djui_hud_render_rect(MATH_7_WIDTHSCALE, 224, 7, 1)
djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255) djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255)
djui_hud_render_rect(MATH_7_WIDTHSCALE + 2, 57 + 166 * ((currChar - 1) * MATH_DIVIDE_CHARACTERS) - (buttonScroll * MATH_DIVIDE_30) * (166 * MATH_DIVIDE_CHARACTERS), 3, 166 * MATH_DIVIDE_CHARACTERS) djui_hud_render_rect(MATH_7_WIDTHSCALE + 2, 57 + 166 * ((currCharRender - 1) * MATH_DIVIDE_CHARACTERS) - (buttonScroll * MATH_DIVIDE_30) * (166 * MATH_DIVIDE_CHARACTERS), 3, 166 * MATH_DIVIDE_CHARACTERS)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
local TEXT_CHAR_COUNT = currChar .. "/" .. #characterTable local TEXT_CHAR_COUNT = currCharRender .. "/" .. #characterTableRender
djui_hud_print_text(TEXT_CHAR_COUNT, (11 - djui_hud_measure_text(TEXT_CHAR_COUNT) * 0.2) * widthScale, height - 12, 0.4) djui_hud_print_text(TEXT_CHAR_COUNT, (11 - djui_hud_measure_text(TEXT_CHAR_COUNT) * 0.2) * widthScale, height - 12, 0.4)
djui_hud_print_text("- "..characterCategories[currCategory] .. " (L/R)", (11 + djui_hud_measure_text(TEXT_CHAR_COUNT) * 0.2) * widthScale, height - 12, 0.4)
--Character Select Header --Character Select Header
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
@ -1216,10 +1305,10 @@ local function on_hud_render()
end end
djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255) djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255)
djui_hud_set_font(FONT_TINY) djui_hud_set_font(FONT_TINY)
djui_hud_print_text(TEXT_VERSION, 5, 3, 0.5) djui_hud_print_text(optionTable[optionTableRef.debugInfo].toggle == 0 and TEXT_VERSION or MOD_VERSION_DEBUG, 5, 3, 0.5)
--Unsupported Res Warning --Unsupported Res Warning
if width < 321.2 or width > 575 then if width < 319 or width > 575 then
djui_hud_print_text(TEXT_RATIO_UNSUPPORTED, 5, 39, 0.5) djui_hud_print_text(TEXT_RATIO_UNSUPPORTED, 5, 39, 0.5)
end end
@ -1393,7 +1482,7 @@ local function on_hud_render()
local widthScaleLimited = minf(widthScale, 1.42) local widthScaleLimited = minf(widthScale, 1.42)
djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255) djui_hud_set_color(menuColor.r, menuColor.g, menuColor.b, 255)
djui_hud_render_rect(widthHalf - 50 * widthScale, height - 25 * widthScaleLimited, 100 * widthScale, 26 * widthScaleLimited) djui_hud_render_rect(widthHalf - 50 * widthScale, height - 25 * widthScaleLimited, 100 * widthScale, 26 * widthScaleLimited)
djui_hud_set_color(0, 0, 0, menuOpacity) djui_hud_set_color(menuColorHalf.r * 0.1, menuColorHalf.g * 0.1, menuColorHalf.b * 0.1, menuOpacity)
djui_hud_render_rect(widthHalf - 50 * widthScale + 2, height - 25 * widthScaleLimited + 2, 100 * widthScale - 4, 22 * widthScaleLimited) djui_hud_render_rect(widthHalf - 50 * widthScale + 2, height - 25 * widthScaleLimited + 2, 100 * widthScale - 4, 22 * widthScaleLimited)
djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255) djui_hud_set_color(menuColorHalf.r, menuColorHalf.g, menuColorHalf.b, 255)
djui_hud_render_rect(widthHalf - 50 * widthScale, height - 2, 100 * widthScale, 2) djui_hud_render_rect(widthHalf - 50 * widthScale, height - 2, 100 * widthScale, 2)
@ -1430,6 +1519,7 @@ local function on_hud_render()
optionAnimTimer = optionAnimTimerCap optionAnimTimer = optionAnimTimerCap
credits = false credits = false
creditsCrossFade = 0 creditsCrossFade = 0
bindTextTimer = 0
end end
-- Fade in/out of menu -- Fade in/out of menu
@ -1507,6 +1597,8 @@ local function on_hud_render()
djui_hud_render_rect(0, 0, width, height) djui_hud_render_rect(0, 0, width, height)
end end
local prevMouseScroll = 0
local mouseScroll = 0
local function before_mario_update(m) local function before_mario_update(m)
if m.playerIndex ~= 0 then return end if m.playerIndex ~= 0 then return end
local controller = m.controller local controller = m.controller
@ -1533,55 +1625,12 @@ local function before_mario_update(m)
return return
end end
mouseScroll = mouseScroll + djui_hud_get_mouse_scroll_y()
local cameraToObject = m.marioObj.header.gfx.cameraToObject local cameraToObject = m.marioObj.header.gfx.cameraToObject
if menuAndTransition and not options then if menuAndTransition and not options then
if menu then if menu then
if inputStallTimerDirectional == 0 and optionTable[optionTableRef.localModels].toggle ~= 0 and not charBeingSet then if inputStallTimerDirectional == 0 and not charBeingSet then
if (controller.buttonPressed & D_JPAD) ~= 0 or (controller.buttonPressed & D_CBUTTONS) ~= 0 or controller.stickY < -60 then
currChar = currChar + 1
local character = characterTable[currChar]
if character ~= nil and character.locked then
currChar = get_next_unlocked_char()
end
if (controller.buttonPressed & D_CBUTTONS) == 0 then
inputStallTimerDirectional = inputStallToDirectional
else
inputStallTimerDirectional = 3 -- C-Scrolling
end
if currChar > #characterTable then
buttonScroll = -buttonScrollCap * #characterTable
else
buttonScroll = buttonScrollCap
end
play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject)
if currChar > #characterTable then currChar = 1 end
if characterColorPresets[characterTable[currChar]] ~= nil then
characterColorPresets[characterTable[currChar]].currPalette = 0
end
end
if (controller.buttonPressed & U_JPAD) ~= 0 or (controller.buttonPressed & U_CBUTTONS) ~= 0 or controller.stickY > 60 then
currChar = currChar - 1
local character = characterTable[currChar]
if character ~= nil and character.locked then
currChar = get_last_unlocked_char()
end
if (controller.buttonPressed & U_CBUTTONS) == 0 then
inputStallTimerDirectional = inputStallToDirectional
else
inputStallTimerDirectional = 3 -- C-Scrolling
end
if currChar < 1 then
buttonScroll = buttonScrollCap * (#characterTable - 1)
else
buttonScroll = -buttonScrollCap
end
play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject)
if currChar < 1 then currChar = #characterTable end
if characterColorPresets[characterTable[currChar]] ~= nil then
characterColorPresets[characterTable[currChar]].currPalette = 0
end
end
-- Alt switcher -- Alt switcher
if #characterTable[currChar] > 1 then if #characterTable[currChar] > 1 then
local character = characterTable[currChar] local character = characterTable[currChar]
@ -1600,6 +1649,83 @@ local function before_mario_update(m)
if character.currAlt > #character then character.currAlt = 1 end if character.currAlt > #character then character.currAlt = 1 end
if character.currAlt < 1 then character.currAlt = #character end if character.currAlt < 1 then character.currAlt = #character end
end end
if optionTable[optionTableRef.localModels].toggle ~= 0 then
if (controller.buttonPressed & D_JPAD) ~= 0 or (controller.buttonPressed & D_CBUTTONS) ~= 0 or controller.stickY < -60 or prevMouseScroll < mouseScroll then
currCharRender = currCharRender + 1
--[[
local character = characterTableRender[currCharRender]
if character ~= nil and character.locked then
currCharRender = get_next_unlocked_char()
end
]]
if (controller.buttonPressed & D_CBUTTONS) == 0 then
inputStallTimerDirectional = inputStallToDirectional
else
inputStallTimerDirectional = 3 -- C-Scrolling
end
if currCharRender > #characterTableRender then
buttonScroll = -buttonScrollCap * #characterTableRender
else
buttonScroll = buttonScrollCap
end
play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject)
if currCharRender > #characterTableRender then currCharRender = 1 end
currChar = characterTableRender[currCharRender].ogNum
if characterColorPresets[characterTable[currChar]] ~= nil then
characterColorPresets[characterTable[currChar]].currPalette = 0
end
prevMouseScroll = mouseScroll
end
if (controller.buttonPressed & U_JPAD) ~= 0 or (controller.buttonPressed & U_CBUTTONS) ~= 0 or controller.stickY > 60 or prevMouseScroll > mouseScroll then
currCharRender = currCharRender - 1
--[[
local character = characterTableRender[currCharRender]
if character ~= nil and character.locked then
currCharRender = get_last_unlocked_char()
end
]]
if (controller.buttonPressed & U_CBUTTONS) == 0 then
inputStallTimerDirectional = inputStallToDirectional
else
inputStallTimerDirectional = 3 -- C-Scrolling
end
if currCharRender < 1 then
buttonScroll = buttonScrollCap * (#characterTableRender - 1)
else
buttonScroll = -buttonScrollCap
end
play_sound(SOUND_MENU_MESSAGE_NEXT_PAGE, cameraToObject)
if currCharRender < 1 then currCharRender = #characterTableRender end
currChar = characterTableRender[currCharRender].ogNum
if characterColorPresets[characterTable[currChar]] ~= nil then
characterColorPresets[characterTable[currChar]].currPalette = 0
end
prevMouseScroll = mouseScroll
end
-- Tab Switcher
if (controller.buttonPressed & L_TRIG) ~= 0 then
local renderEmpty = true
while renderEmpty do
currCategory = currCategory - 1
if currCategory < 1 then currCategory = #characterCategories end
renderEmpty = not update_character_render_table()
end
inputStallTimerDirectional = inputStallToDirectional
play_sound(SOUND_MENU_CAMERA_TURN, cameraToObject)
end
if (controller.buttonPressed & R_TRIG) ~= 0 then
local renderEmpty = true
while renderEmpty do
currCategory = currCategory + 1
if currCategory > #characterCategories then currCategory = 1 end
renderEmpty = not update_character_render_table()
end
inputStallTimerDirectional = inputStallToDirectional
play_sound(SOUND_MENU_CAMERA_TURN, cameraToObject)
end
end
end end
if inputStallTimerButton == 0 then if inputStallTimerButton == 0 then
@ -1611,6 +1737,10 @@ local function before_mario_update(m)
else else
play_sound(SOUND_MENU_CAMERA_BUZZ, cameraToObject) play_sound(SOUND_MENU_CAMERA_BUZZ, cameraToObject)
end end
-- Set bottom right text
bindText = 1
bindTextTimer = 1
end end
if (controller.buttonPressed & B_BUTTON) ~= 0 then if (controller.buttonPressed & B_BUTTON) ~= 0 then
menu = false menu = false
@ -1631,6 +1761,10 @@ local function before_mario_update(m)
play_sound(SOUND_MENU_CAMERA_BUZZ, cameraToObject) play_sound(SOUND_MENU_CAMERA_BUZZ, cameraToObject)
inputStallTimerButton = inputStallToButton inputStallTimerButton = inputStallToButton
end end
-- Set bottom right text
bindText = 2
bindTextTimer = 1
end end
if characterColorPresets[gCSPlayers[0].modelId] ~= nil then if characterColorPresets[gCSPlayers[0].modelId] ~= nil then
if paletteCount < currPaletteTable.currPalette then currPaletteTable.currPalette = 0 end if paletteCount < currPaletteTable.currPalette then currPaletteTable.currPalette = 0 end
@ -1764,7 +1898,9 @@ local function chat_command(msg)
local saveName = string_underscore_to_space(string_lower(characterTable[i].saveName)) local saveName = string_underscore_to_space(string_lower(characterTable[i].saveName))
for a = 1, #characterTable[i] do for a = 1, #characterTable[i] do
if msg == string_lower(characterTable[i][a].name) or msg == saveName then if msg == string_lower(characterTable[i][a].name) or msg == saveName then
currCategory = 1
currChar = i currChar = i
update_character_render_table()
if msg ~= saveName then if msg ~= saveName then
characterTable[i].currAlt = a characterTable[i].currAlt = a
end end

View file

@ -5,7 +5,7 @@
if incompatibleClient then return 0 end if incompatibleClient then return 0 end
-- localize functions to improve performance - n-hud.lua -- localize functions to improve performance - n-hud.lua
local hud_get_value,hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math_ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open = hud_get_value,hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math.ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open local og_hud_get_value,og_hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math_ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open = hud_get_value,hud_set_value,djui_hud_print_text,tostring,hud_set_flash,get_global_timer,hud_get_flash,djui_hud_get_screen_width,math.ceil,obj_get_first_with_behavior_id,get_behavior_from_id,count_objects_with_behavior,djui_hud_render_rect,djui_hud_set_resolution,djui_hud_get_screen_height,djui_hud_set_color,djui_hud_set_font,djui_hud_measure_text,djui_chat_message_create,hud_is_hidden,djui_is_playerlist_open
--[[ --[[
Some functions we need for the hud Some functions we need for the hud
@ -175,33 +175,66 @@ end
-- Real HUD Stuffs -- -- Real HUD Stuffs --
--------------------- ---------------------
local sHudElements = { -- Modified Vanilla Functions --
[HUD_DISPLAY_FLAG_LIVES] = true, --[[
[HUD_DISPLAY_FLAG_STAR_COUNT] = true, These are `_G` on their own to replace vanilla functions
[HUD_DISPLAY_FLAG_CAMERA] = true ]]
}
local sCharSelectHudDisplayFlags -- `local` because we aren't exposing this
-- Here to make sure the flags are at the default state
hook_event(HOOK_UPDATE, function ()
if not sCharSelectHudDisplayFlags or sCharSelectHudDisplayFlags == 0 then
sCharSelectHudDisplayFlags = og_hud_get_value(HUD_DISPLAY_FLAGS) | HUD_DISPLAY_DEFAULT
end
end)
--- @param type HudDisplayValue
--- @return integer
function _G.hud_get_value(type)
if type == HUD_DISPLAY_FLAGS then
return sCharSelectHudDisplayFlags
else
return og_hud_get_value(type)
end
end
--- @param type HudDisplayValue
--- @param value integer
--- Sets a HUD display value
function _G.hud_set_value(type, value)
if type == HUD_DISPLAY_FLAGS then
sCharSelectHudDisplayFlags = value
else
og_hud_set_value(type, value)
end
end
-- Old CS Hud Functions --
---Hides the specified custom hud element ---Hides the specified custom hud element
---@param hudElement HUDDisplayFlag ---@param hudElement HUDDisplayFlag
function hud_hide_element(hudElement) function hud_hide_element(hudElement)
if sHudElements[hudElement] == nil then return false end --log_to_console("The `charSelect.hud_hide_element()` function is deprecated, please use normal vanilla functions as they have been modified to work with Character Select.", CONSOLE_MESSAGE_WARNING)
sHudElements[hudElement] = false hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~hudElement)
return true return true
end end
---Shows the specified custom hud element ---Shows the specified custom hud element
---@param hudElement HUDDisplayFlag ---@param hudElement HUDDisplayFlag
function hud_show_element(hudElement) function hud_show_element(hudElement)
if sHudElements[hudElement] == nil then return false end --log_to_console("The `charSelect.hud_show_element()` function is deprecated, please use normal vanilla functions as they have been modified to work with Character Select.", CONSOLE_MESSAGE_WARNING)
sHudElements[hudElement] = true hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) | hudElement)
return true return true
end end
---Gets the specified custom hud element's state ---Gets the specified custom hud element's state
---@param hudElement HUDDisplayFlag ---@param hudElement HUDDisplayFlag
---@return boolean
function hud_get_element(hudElement) function hud_get_element(hudElement)
if sHudElements[hudElement] == nil then return false end --log_to_console("The `charSelect.hud_get_element()` function is deprecated, please use normal vanilla functions as they have been modified to work with Character Select.", CONSOLE_MESSAGE_WARNING)
return sHudElements[hudElement] djui_chat_message_create(tostring(sCharSelectHudDisplayFlags))
return (hud_get_value(HUD_DISPLAY_FLAGS) & hudElement) ~= 0
end end
local MATH_DIVIDE_16 = 1/16 local MATH_DIVIDE_16 = 1/16
@ -299,6 +332,9 @@ function render_life_icon_from_local_index(localIndex, x, y, scale)
end end
--- @param localIndex integer --- @param localIndex integer
--- @param prevX integer
--- @param prevY integer
--- @param prevScale integer
--- @param x integer --- @param x integer
--- @param y integer --- @param y integer
--- @param scale integer --- @param scale integer
@ -341,6 +377,7 @@ function render_star_icon_from_local_index_interpolated(localIndex, prevX, prevY
djui_hud_render_texture_interpolated(starIcon, prevX, prevY, prevScale / (starIcon.width * MATH_DIVIDE_16), prevScale / (starIcon.height * MATH_DIVIDE_16), x, y, scale / (starIcon.width * MATH_DIVIDE_16), scale / (starIcon.height * MATH_DIVIDE_16)) djui_hud_render_texture_interpolated(starIcon, prevX, prevY, prevScale / (starIcon.width * MATH_DIVIDE_16), prevScale / (starIcon.height * MATH_DIVIDE_16), x, y, scale / (starIcon.width * MATH_DIVIDE_16), scale / (starIcon.height * MATH_DIVIDE_16))
end end
-- Health Meter --
local TEXT_DEFAULT_METER_PREFIX = "char-select-custom-meter-" local TEXT_DEFAULT_METER_PREFIX = "char-select-custom-meter-"
local TEX_DEFAULT_METER_LEFT = get_texture_info(TEXT_DEFAULT_METER_PREFIX.."left") local TEX_DEFAULT_METER_LEFT = get_texture_info(TEXT_DEFAULT_METER_PREFIX.."left")
local TEX_DEFAULT_METER_RIGHT = get_texture_info(TEXT_DEFAULT_METER_PREFIX.."right") local TEX_DEFAULT_METER_RIGHT = get_texture_info(TEXT_DEFAULT_METER_PREFIX.."right")
@ -424,7 +461,7 @@ local pieTextureNames = {
} }
local function render_hud_health() local function render_hud_health()
if currChar == 1 then if currChar == 1 and characterTable[1].currAlt == 1 then
texture_override_reset("texture_power_meter_left_side") texture_override_reset("texture_power_meter_left_side")
texture_override_reset("texture_power_meter_right_side") texture_override_reset("texture_power_meter_right_side")
for i = 1, 8 do for i = 1, 8 do
@ -438,9 +475,9 @@ local function render_hud_health()
texture_override_set("texture_power_meter_left_side", textureTable.label.left) texture_override_set("texture_power_meter_left_side", textureTable.label.left)
texture_override_set("texture_power_meter_right_side", textureTable.label.right) texture_override_set("texture_power_meter_right_side", textureTable.label.right)
end end
for i = 1, 8 do for i = 1, 8 do
texture_override_set("texture_power_meter_" .. pieTextureNames[i], textureTable.pie[i]) texture_override_set("texture_power_meter_" .. pieTextureNames[i], (textureTable.pie and textureTable.pie[i]) and textureTable.pie[i] or defaultMeterInfo.pie[i])
end end
else -- resets the health HUD else -- resets the health HUD
texture_override_set("texture_power_meter_left_side", defaultMeterInfo.label.left) texture_override_set("texture_power_meter_left_side", defaultMeterInfo.label.left)
texture_override_set("texture_power_meter_right_side", defaultMeterInfo.label.right) texture_override_set("texture_power_meter_right_side", defaultMeterInfo.label.right)
@ -469,9 +506,9 @@ local function render_hud_act_select_course()
end end
local function render_hud_mario_lives() local function render_hud_mario_lives()
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_LIVES) og_hud_set_value(HUD_DISPLAY_FLAGS, og_hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_LIVES)
if not hud_get_element(HUD_DISPLAY_FLAG_LIVES) then return end if (hud_get_value(HUD_DISPLAY_FLAGS) & HUD_DISPLAY_FLAG_LIVES) == 0 then return end
local x = 22 local x = 22
local y = 15 -- SCREEN_HEIGHT - 209 - 16 local y = 15 -- SCREEN_HEIGHT - 209 - 16
@ -481,9 +518,9 @@ local function render_hud_mario_lives()
end end
local function render_hud_stars() local function render_hud_stars()
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT) og_hud_set_value(HUD_DISPLAY_FLAGS, og_hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT)
if not hud_get_element(HUD_DISPLAY_FLAG_STAR_COUNT) then return end if (hud_get_value(HUD_DISPLAY_FLAGS) & HUD_DISPLAY_FLAG_STAR_COUNT) == 0 then return end
if hud_get_flash ~= nil then if hud_get_flash ~= nil then
-- prevent star count from flashing outside of castle -- prevent star count from flashing outside of castle
if gNetworkPlayers[0].currCourseNum ~= COURSE_NONE then hud_set_flash(0) end if gNetworkPlayers[0].currCourseNum ~= COURSE_NONE then hud_set_flash(0) end
@ -513,9 +550,9 @@ end
local function render_hud_camera_status() local function render_hud_camera_status()
if not HUD_DISPLAY_CAMERA_STATUS then return end if not HUD_DISPLAY_CAMERA_STATUS then return end
hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_CAMERA) og_hud_set_value(HUD_DISPLAY_FLAGS, og_hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_CAMERA)
if not hud_get_element(HUD_DISPLAY_FLAG_CAMERA) then return end if (hud_get_value(HUD_DISPLAY_FLAGS) & HUD_DISPLAY_FLAG_CAMERA) == 0 then return end
local x = djui_hud_get_screen_width() - 54 local x = djui_hud_get_screen_width() - 54
local y = 205 local y = 205

View file

@ -17,7 +17,9 @@ local table_insert,djui_hud_measure_text,smlua_model_util_get_id,type,tonumber =
local characterVoices = {} local characterVoices = {}
local saveNameTable = {} local saveNameTable = {}
local E_MODEL_ARMATURE = smlua_model_util_get_id("armature_geo") -- Here for functions below api
---@ignore
local function placeholder() end
---@ignore ---@ignore
local function split_text_into_lines(text) local function split_text_into_lines(text)
@ -48,7 +50,15 @@ local TYPE_TABLE = "table"
local TYPE_TEX_INFO = "userdata" local TYPE_TEX_INFO = "userdata"
local TYPE_FUNCTION = "function" local TYPE_FUNCTION = "function"
-------------------------
-- Character Functions --
-------------------------
---@header
---@forcedoc Character_Functions
---@description A function that adds a Character to the Character Table ---@description A function that adds a Character to the Character Table
---@added 1
---@param name string|nil `"Custom Model"` ---@param name string|nil `"Custom Model"`
---@param description table|string|nil `{"string"}` ---@param description table|string|nil `{"string"}`
---@param credit string|nil `"You!"`, Credit the creators ---@param credit string|nil `"You!"`, Credit the creators
@ -69,11 +79,14 @@ local function character_add(name, description, credit, color, modelInfo, forceC
lifeIcon = lifeIcon:sub(1,1) lifeIcon = lifeIcon:sub(1,1)
end end
local addedModel = (modelInfo and modelInfo ~= E_MODEL_ERROR_MODEL) and modelInfo or E_MODEL_ARMATURE local addedModel = (modelInfo and modelInfo ~= E_MODEL_ERROR_MODEL) and modelInfo or E_MODEL_ARMATURE
local charNum = #characterTable + 1
table_insert(characterTable, { table_insert(characterTable, {
saveName = type(name) == TYPE_STRING and string_space_to_underscore(name) or "Untitled", saveName = type(name) == TYPE_STRING and string_space_to_underscore(name) or "Untitled",
currAlt = 1, currAlt = 1,
hasMoveset = false, hasMoveset = false,
locked = false, locked = false,
category = "All",
ogNum = charNum,
[1] = { [1] = {
name = type(name) == TYPE_STRING and name or "Untitled", name = type(name) == TYPE_STRING and name or "Untitled",
description = type(description) == TYPE_TABLE and description or {"No description has been provided"}, description = type(description) == TYPE_TABLE and description or {"No description has been provided"},
@ -88,12 +101,13 @@ local function character_add(name, description, credit, color, modelInfo, forceC
healthTexture = nil, healthTexture = nil,
}, },
}) })
saveNameTable[#characterTable] = characterTable[#characterTable].saveName saveNameTable[charNum] = characterTable[charNum].saveName
characterMovesets[#characterTable] = {} characterMovesets[charNum] = {}
return #characterTable return charNum
end end
---@description A function that adds a Costume to an Existing Character, all inputs mimic character_edit ---@description A function that adds a Costume to an Existing Character, all inputs mimic character_edit
---@added 1.11
---@param charNum integer The number/table position of the Character you want to add a costume to ---@param charNum integer The number/table position of the Character you want to add a costume to
---@param name string|nil `"Custom Model"` ---@param name string|nil `"Custom Model"`
---@param description table|string|nil `{"string"}` ---@param description table|string|nil `{"string"}`
@ -134,6 +148,7 @@ local function character_add_costume(charNum, name, description, credit, color,
end end
---@description A function that Edits an existing Costume ---@description A function that Edits an existing Costume
---@added 1.11
---@param charNum integer The number/table position of the Character you want to edit the costume of ---@param charNum integer The number/table position of the Character you want to edit the costume of
---@param charAlt integer The number/table position of the Costume you want to edit, this can be found by making a variable equal ---@param charAlt integer The number/table position of the Costume you want to edit, this can be found by making a variable equal
---@param name string|nil `"Custom Model"` ---@param name string|nil `"Custom Model"`
@ -171,13 +186,13 @@ local function character_edit_costume(charNum, charAlt, name, description, credi
healthTexture = tableCache.healthTexture, healthTexture = tableCache.healthTexture,
} or nil } or nil
local ccp = characterColorPresets if modelInfo and characterColorPresets[modelInfo] and tableCache.model and characterColorPresets[tableCache.model] and #characterColorPresets[modelInfo] == #characterColorPresets[tableCache.model] then
if modelInfo ~= nil and ccp[modelInfo] ~= nil and ccp[tableCache.model] ~= nil and ccp[modelInfo].currPalette <= ccp[tableCache.model].currPalette then characterColorPresets[modelInfo].currPalette = characterColorPresets[tableCache.model].currPalette
ccp[modelInfo].currPalette = ccp[tableCache.model].currPalette
end end
end end
---@description A function that Edits an Existing Character ---@description A function that Edits an Existing Character
---@added 1
---@param charNum integer The number/table position of the Character you want to edit ---@param charNum integer The number/table position of the Character you want to edit
---@param name string|nil `"Custom Model"` ---@param name string|nil `"Custom Model"`
---@param description table|string|nil `{"string"}` ---@param description table|string|nil `{"string"}`
@ -188,40 +203,44 @@ end
---@param lifeIcon TextureInfo|string|nil Use get_texture_info ---@param lifeIcon TextureInfo|string|nil Use get_texture_info
---@param camScale integer|nil Zooms the camera based on a multiplier (Default `1`) ---@param camScale integer|nil Zooms the camera based on a multiplier (Default `1`)
local function character_edit(charNum, name, description, credit, color, modelInfo, forceChar, lifeIcon, camScale) local function character_edit(charNum, name, description, credit, color, modelInfo, forceChar, lifeIcon, camScale)
character_edit_costume(charNum, 1, name, description, credit, color, modelInfo, forceChar, lifeIcon, camScale) character_edit_costume(charNum, characterTable[charNum] and characterTable[charNum].currAlt or 1, name, description, credit, color, modelInfo, forceChar, lifeIcon, camScale)
end end
---@description A function that adds a voice table to a character ---@description A function that adds a voice table to a character
---@added 1.5
---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id ---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id
---@param clips table A Table with your Character's Sound File Names ---@param clips table A Table with your Character's Sound File Names
---@note In order for sound files to function, please run config_character_sounds in your pack
---@note
---@note Table Example:
---@note ```lua ---@note ```lua
---@note local VOICETABLE_CHAR = { ---@note local VOICETABLE_CHAR = {
---@note [CHAR_SOUND_ATTACKED] = 'NES-Hit.ogg', ---@note [CHAR_SOUND_ATTACKED] = 'NES-Hit.ogg',
---@note [CHAR_SOUND_DOH] = 'NES-Bump.ogg', ---@note [CHAR_SOUND_DOH] = 'NES-Bump.ogg',
---@note [CHAR_SOUND_DROWNING] = 'NES-Die.ogg', ---@note [CHAR_SOUND_DROWNING] = 'NES-Die.ogg',
---@note [CHAR_SOUND_DYING] = 'NES-Die.ogg', ---@note [CHAR_SOUND_DYING] = 'NES-Die.ogg',
---@note [CHAR_SOUND_GROUND_POUND_WAH] = 'NES-Squish.ogg', ---@note [CHAR_SOUND_GROUND_POUND_WAH] = 'NES-Squish.ogg',
---@note [CHAR_SOUND_HAHA] = 'NES-1up.ogg', ---@note [CHAR_SOUND_HAHA] = 'NES-1up.ogg',
---@note [CHAR_SOUND_HAHA_2] = 'NES-1up.ogg', ---@note [CHAR_SOUND_HAHA_2] = 'NES-1up.ogg',
---@note [CHAR_SOUND_HERE_WE_GO] = 'NES-Flagpole.ogg', ---@note [CHAR_SOUND_HERE_WE_GO] = 'NES-Flagpole.ogg',
---@note [CHAR_SOUND_HOOHOO] = 'NES-Jump.ogg', ---@note [CHAR_SOUND_HOOHOO] = 'NES-Jump.ogg',
---@note [CHAR_SOUND_MAMA_MIA] = 'NES-Warp.ogg', ---@note [CHAR_SOUND_MAMA_MIA] = 'NES-Warp.ogg',
---@note [CHAR_SOUND_OKEY_DOKEY] = 'NES-1up.ogg', ---@note [CHAR_SOUND_OKEY_DOKEY] = 'NES-1up.ogg',
---@note [CHAR_SOUND_ON_FIRE] = 'NES-Enemy_Fire.ogg', ---@note [CHAR_SOUND_ON_FIRE] = 'NES-Enemy_Fire.ogg',
---@note [CHAR_SOUND_OOOF] = 'NES-Hit.ogg', ---@note [CHAR_SOUND_OOOF] = 'NES-Hit.ogg',
---@note [CHAR_SOUND_OOOF2] = 'NES-Hit.ogg', ---@note [CHAR_SOUND_OOOF2] = 'NES-Hit.ogg',
---@note [CHAR_SOUND_PUNCH_HOO] = 'NES-Kick.ogg', ---@note [CHAR_SOUND_PUNCH_HOO] = 'NES-Kick.ogg',
---@note [CHAR_SOUND_PUNCH_WAH] = 'NES-Thwomp.ogg', ---@note [CHAR_SOUND_PUNCH_WAH] = 'NES-Thwomp.ogg',
---@note [CHAR_SOUND_PUNCH_YAH] = 'NES-Thwomp.ogg', ---@note [CHAR_SOUND_PUNCH_YAH] = 'NES-Thwomp.ogg',
---@note [CHAR_SOUND_SO_LONGA_BOWSER] = 'NES-Bowser_Die.ogg', ---@note [CHAR_SOUND_SO_LONGA_BOWSER] = 'NES-Bowser_Die.ogg',
---@note [CHAR_SOUND_TWIRL_BOUNCE] = 'NES-Item.ogg', ---@note [CHAR_SOUND_TWIRL_BOUNCE] = 'NES-Item.ogg',
---@note [CHAR_SOUND_WAAAOOOW] = 'NES-Vine.ogg', ---@note [CHAR_SOUND_WAAAOOOW] = 'NES-Vine.ogg',
---@note [CHAR_SOUND_WAH2] = 'NES-Kick.ogg', ---@note [CHAR_SOUND_WAH2] = 'NES-Kick.ogg',
---@note [CHAR_SOUND_WHOA] = 'NES-Item.ogg', ---@note [CHAR_SOUND_WHOA] = 'NES-Item.ogg',
---@note [CHAR_SOUND_YAHOO] = 'NES-Jump.ogg', ---@note [CHAR_SOUND_YAHOO] = 'NES-Jump.ogg',
---@note [CHAR_SOUND_YAHOO_WAHA_YIPPEE] = 'NES-Jump.ogg', ---@note [CHAR_SOUND_YAHOO_WAHA_YIPPEE] = 'NES-Jump.ogg',
---@note [CHAR_SOUND_YAH_WAH_HOO] = 'NES-Big_Jump.ogg', ---@note [CHAR_SOUND_YAH_WAH_HOO] = 'NES-Big_Jump.ogg',
---@note [CHAR_SOUND_YAWNING] = 'NES-Pause.ogg', ---@note [CHAR_SOUND_YAWNING] = 'NES-Pause.ogg',
---@note } ---@note }
---@note ``` ---@note ```
local function character_add_voice(modelInfo, clips) local function character_add_voice(modelInfo, clips)
@ -229,14 +248,15 @@ local function character_add_voice(modelInfo, clips)
end end
---@description A function that adds a caps table to a character ---@description A function that adds a caps table to a character
---@added 1.6
---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id ---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id
---@param caps table Cap ---@param caps table Cap
---@note ```lua ---@note ```lua
---@note local CAPTABLE_CHAR = { ---@note local CAPTABLE_CHAR = {
---@note normal = smlua_model_util_get_id("custom_model_cap_normal_geo"), ---@note normal = smlua_model_util_get_id("custom_model_cap_normal_geo"),
---@note wing = smlua_model_util_get_id("custom_model_cap_wing_geo"), ---@note wing = smlua_model_util_get_id("custom_model_cap_wing_geo"),
---@note metal = smlua_model_util_get_id("custom_model_cap_metal_geo"), ---@note metal = smlua_model_util_get_id("custom_model_cap_metal_geo"),
---@note metalWing = smlua_model_util_get_id("custom_model_cap_wing_geo") ---@note metalWing = smlua_model_util_get_id("custom_model_cap_wing_geo")
---@note } ---@note }
---@note ``` ---@note ```
local function character_add_caps(modelInfo, caps) local function character_add_caps(modelInfo, caps)
@ -244,13 +264,15 @@ local function character_add_caps(modelInfo, caps)
end end
---@description A function that gets a model's cap table ---@description A function that gets a model's cap table
---@added 1.13
---@param modelInfo ModelExtendedId|integer|nil Model Information Received from smlua_model_util_get_id ---@param modelInfo ModelExtendedId|integer|nil Model Information Received from smlua_model_util_get_id
local function character_get_caps(modelInfo) local function character_get_caps(modelInfo)
if modelInfo == nil then modelInfo = characterTable[currChar][characterTable[currChar].currAlt].model end if modelInfo == nil then modelInfo = characterTable[currChar][characterTable[currChar].currAlt].model end
return characterCaps[modelInfo] return characterCaps[modelInfo]
end end
---@description A function that adds health meter textures to a character ---@description A function that adds health meter textures to a costume
---@added 1.12
---@param charNum integer The number/table position of the Character you want to add a meter to ---@param charNum integer The number/table position of the Character you want to add a meter to
---@param charAlt integer The number/table position of the Costume you want to add a meter to ---@param charAlt integer The number/table position of the Costume you want to add a meter to
---@param healthTexture table|nil A Table with your Character's Health Textures (Table Shown in character_add_health_meter) ---@param healthTexture table|nil A Table with your Character's Health Textures (Table Shown in character_add_health_meter)
@ -261,6 +283,7 @@ local function character_add_costume_health_meter(charNum, charAlt, healthTextur
end end
---@description A function that adds health meter textures to a character ---@description A function that adds health meter textures to a character
---@added 1.9
---@param charNum integer The number/table position of the Character you want to add a meter to ---@param charNum integer The number/table position of the Character you want to add a meter to
---@param healthTexture table|nil A Table with your Character's Health Textures (Table Shown Below) ---@param healthTexture table|nil A Table with your Character's Health Textures (Table Shown Below)
---@note ```lua ---@note ```lua
@ -281,29 +304,37 @@ end
---@note } ---@note }
---@note } ---@note }
---@note ``` ---@note ```
---@note This method is restricted to the default meter format, you can refer to the Disassembled sections in the image below for how to format your health meter (Spriters Resource Page)
---@note <p align=center> <img src="https://www.spriters-resource.com/resources/sheets/7/6841.png?updated=1595395218" width="720"> </p>
local function character_add_health_meter(charNum, healthTexture) local function character_add_health_meter(charNum, healthTexture)
character_add_costume_health_meter(charNum, 1, healthTexture) character_add_costume_health_meter(charNum, 1, healthTexture)
end end
---@param charNum integer ---@description A function that adds course textures to a costume in the Star Select
---@param charAlt integer ---@added 1.12
---@param courseTexture table|nil ---@param charNum integer The number/table position of the Character you want to add a course textures to
---@param charAlt integer The number/table position of the Costume you want to add a course textures to
---@param courseTexture table|nil A Table with your Character's Health Textures (Table Shown in character_add_course)
local function character_add_costume_course(charNum, charAlt, courseTexture) local function character_add_costume_course(charNum, charAlt, courseTexture)
if type(charNum) ~= TYPE_INTEGER or charNum == nil then return end if type(charNum) ~= TYPE_INTEGER or charNum == nil then return end
if type(charAlt) ~= TYPE_INTEGER or charAlt == nil then return end if type(charAlt) ~= TYPE_INTEGER or charAlt == nil then return end
characterTable[charNum][charAlt].courseTexture = type(courseTexture) == TYPE_TABLE and courseTexture or nil characterTable[charNum][charAlt].courseTexture = type(courseTexture) == TYPE_TABLE and courseTexture or nil
end end
---@description A function that adds a custom texture to the star select ---@description A function that adds course textures to a character in the Star Select
---@param charNum integer The number/table position of the Character you want to add a course texture to ---@added 1.12
---@param courseTexture table|nil ---@param charNum integer The number/table position of the Character you want to add a course textures to
---@param courseTexture table|nil A Table with your Character's Health Textures (Table Shown Below)
---@note ```lua
---@note local COURSE_CHAR = {
---@note top = get_texture_info("char-course-top"),
---@note bottom = get_texture_info("char-course-bottom"),
---@note }
---@note ```
local function character_add_course(charNum, courseTexture) local function character_add_course(charNum, courseTexture)
character_add_costume_course(charNum, 1, courseTexture) character_add_costume_course(charNum, 1, courseTexture)
end end
---@description A function that adds a celebration star model to a character ---@description A function that adds a celebration star model to a character
---@added 1.7
---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id() ---@param modelInfo ModelExtendedId|integer Model Information Received from smlua_model_util_get_id()
---@param starModel ModelExtendedId|integer Model Information Received from smlua_model_util_get_id() ---@param starModel ModelExtendedId|integer Model Information Received from smlua_model_util_get_id()
---@param starIcon TextureInfo|nil Texture Information Received from get_texture_info() ---@param starIcon TextureInfo|nil Texture Information Received from get_texture_info()
@ -321,8 +352,10 @@ local function character_add_celebration_star(modelInfo, starModel, starIcon)
end end
---@description A function that adds a palette preset to a character ---@description A function that adds a palette preset to a character
---@added 1.8
---@param modelInfo ModelExtendedId|integer ---@param modelInfo ModelExtendedId|integer
---@param paletteTable table ---@param paletteTable table
---@param paletteName string|nil
---@note ```lua ---@note ```lua
---@note local PALETTE_CHAR = { ---@note local PALETTE_CHAR = {
---@note [PANTS] = {r = 0x00, g = 0x00, b = 0xff}, ---@note [PANTS] = {r = 0x00, g = 0x00, b = 0xff},
@ -335,8 +368,10 @@ end
---@note } ---@note }
---@note ``` ---@note ```
---@note Strings can also be used rather than RGB tables, ex. `[PANTS] = "0000ff"` ---@note Strings can also be used rather than RGB tables, ex. `[PANTS] = "0000ff"`
local function character_add_palette_preset(modelInfo, paletteTable) local function character_add_palette_preset(modelInfo, paletteTable, paletteName)
local paletteTableOut = {} local paletteTableOut = {
name = paletteName,
}
local defaultColors = characterColorPresets[E_MODEL_MARIO] local defaultColors = characterColorPresets[E_MODEL_MARIO]
for i = 0, 7 do for i = 0, 7 do
local color = paletteTable[i] local color = paletteTable[i]
@ -360,17 +395,23 @@ local function character_add_palette_preset(modelInfo, paletteTable)
table_insert(characterColorPresets[modelInfo], paletteTableOut) table_insert(characterColorPresets[modelInfo], paletteTableOut)
end end
---@description A function that adds animations to a model
---@added 1.10
---@param modelInfo ModelExtendedId|integer ---@param modelInfo ModelExtendedId|integer
---@param animTable table ---@param animTable table
local function character_add_animations(modelInfo, animTable) local function character_add_animations(modelInfo, animTable)
characterAnims[modelInfo] = type(animTable) == TYPE_TABLE and animTable or nil characterAnims[modelInfo] = type(animTable) == TYPE_TABLE and animTable or nil
end end
---@description A function that gets any animation table from a model
---@added 1.10
---@param modelInfo ModelExtendedId|integer ---@param modelInfo ModelExtendedId|integer
local function character_get_animations(modelInfo) local function character_get_animations(modelInfo)
return characterAnims[modelInfo] return characterAnims[modelInfo]
end end
---@description A function that gets a character's full Character Select Table
---@added 1
---@param tablePos integer|nil ---@param tablePos integer|nil
---@param charAlt integer|nil ---@param charAlt integer|nil
---@return CharacterTable ---@return CharacterTable
@ -380,11 +421,15 @@ local function character_get_current_table(tablePos, charAlt)
return characterTable[tablePos][charAlt] return characterTable[tablePos][charAlt]
end end
---@description A function that gets Character Select's Entire Character Table
---@added 1.11.1
---@return table ---@return table
local function character_get_full_table() local function character_get_full_table()
return characterTable return characterTable
end end
---@description A function that gets the current character's table position in CS
---@added 1
--- @param localIndex integer|nil --- @param localIndex integer|nil
--- @return integer|nil --- @return integer|nil
local function character_get_current_number(localIndex) local function character_get_current_number(localIndex)
@ -400,8 +445,10 @@ local function character_get_current_number(localIndex)
end end
end end
--- @param localIndex integer|nil ---@description A function that gets the current costumes's table position in CS
--- @return integer|nil ---@added 1.12
---@param localIndex integer|nil
---@return integer|nil
local function character_get_current_costume(localIndex) local function character_get_current_costume(localIndex)
if localIndex == nil or localIndex == 0 then if localIndex == nil or localIndex == 0 then
return characterTable[currChar].currAlt return characterTable[currChar].currAlt
@ -415,6 +462,8 @@ local function character_get_current_costume(localIndex)
end end
end end
---@description A function that sets the current character based only table position
---@added 1.9
---@param charNum integer|nil ---@param charNum integer|nil
local function character_set_current_number(charNum) local function character_set_current_number(charNum)
if type(charNum) ~= TYPE_INTEGER or characterTable[charNum] == nil then return end if type(charNum) ~= TYPE_INTEGER or characterTable[charNum] == nil then return end
@ -422,12 +471,16 @@ local function character_set_current_number(charNum)
charBeingSet = true charBeingSet = true
end end
---@description A function that gets the current character's palette data
---@added 1.12
--- @return table|nil --- @return table|nil
local function character_get_current_palette() local function character_get_current_palette()
local model = characterTable[currChar][characterTable[currChar].currAlt].model local model = characterTable[currChar][characterTable[currChar].currAlt].model
return characterColorPresets[model][gCSPlayers[0].presetPalette] return characterColorPresets[model][gCSPlayers[0].presetPalette]
end end
---@description A function that gets the current character's palette number
---@added 1.12
--- @param localIndex integer|nil --- @param localIndex integer|nil
--- @return integer|nil --- @return integer|nil
local function character_get_current_palette_number(localIndex) local function character_get_current_palette_number(localIndex)
@ -435,6 +488,8 @@ local function character_get_current_palette_number(localIndex)
return gCSPlayers[localIndex].presetPalette return gCSPlayers[localIndex].presetPalette
end end
---@description A function that searches for a character's table posision based on name
---@added 1
---@param name string ---@param name string
local function character_get_number_from_string(name) local function character_get_number_from_string(name)
if type(name) ~= TYPE_STRING then return nil end if type(name) ~= TYPE_STRING then return nil end
@ -448,14 +503,88 @@ local function character_get_number_from_string(name)
return nil return nil
end end
---@description A function that gets the current character's voice table
---@added 1.5
---@param m MarioState ---@param m MarioState
function character_get_voice(m) function character_get_voice(m)
return characterVoices[gCSPlayers[m.playerIndex].modelId] return characterVoices[gCSPlayers[m.playerIndex].modelId]
end end
---@param charNum integer|nil -- Located in n-hud.lua
---@param unlockCondition function|boolean|nil
---@param notify boolean|nil ---@description A function that gets a persons life icon texture / string based off of local index
---@added 1.7
---@param localIndex integer
---@return TextureInfo|string
---@note This assumes multiple characters will not have the same model, Icons can only be seen by users who have the character avalible to them. This function can return nil. if this is the case, render `djui_hud_print_text("?", x, y, 1)`
---@forcedoc character_get_life_icon
---@description A function that renders a persons life icon texture / string based off of local index
---@added 1.11
---@param localIndex integer
---@param x integer
---@param y integer
---@param scale integer
---@forcedoc character_render_life_icon
---@description A function that acts as character_render_life_icon with support for interpolation
---@added 1.13
---@param localIndex integer
---@param prevX integer
---@param prevY integer
---@param prevScale integer
---@param x integer
---@param y integer
---@param scale integer
---@forcedoc character_render_life_icon_interpolated
---@description A function that gets a persons star icon texture / string based off of local index
---@added 1.8
---@param localIndex integer
---@return TextureInfo
---@note This assumes multiple characters will not have the same model, Icons can only be seen by users who have the character avalible to them
---@forcedoc character_get_star_icon
---@description A function that renders a persons star icon texture / string based off of local index
---@added 1.11
---@param localIndex integer
---@param x integer
---@param y integer
---@param scale integer
---@forcedoc character_render_star_icon
---@description A function that acts as character_render_star_icon with support for interpolation
---@added 1.13
---@param localIndex integer
---@param prevX integer
---@param prevY integer
---@param prevScale integer
---@param x integer
---@param y integer
---@param scale integer
---@forcedoc character_render_star_icon_interpolated
---@description A function that gets a persons health meter texture table (example of which is at character_add_health_meter)
---@added 1.12
---@param localIndex integer
---@return table
---@note This assumes multiple characters will not have the same model, Meters can only be seen by users who have the character avalible to them
---@forcedoc character_get_health_meter
---@description A function that renders a persons health meter texture table
---@added 1.12
---@param localIndex integer
---@param x integer
---@param y integer
---@param scaleX integer
---@param scaleY integer
---@forcedoc character_render_health_meter
---@description A function that locks a character under an unlock condition
---@added 1.10
---@param charNum integer|nil The number of the Character you want to Lock
---@param unlockCondition function|boolean|nil The condition for if the character stays locked
---@param notify boolean|nil Toggles whether Character Select should notify the user when the character is unlocked
local function character_set_locked(charNum, unlockCondition, notify) local function character_set_locked(charNum, unlockCondition, notify)
if charNum == nil or charNum > #characterTable or charNum < 2 then return end if charNum == nil or charNum > #characterTable or charNum < 2 then return end
if unlockCondition == nil then unlockCondition = false end if unlockCondition == nil then unlockCondition = false end
@ -470,12 +599,51 @@ local function character_set_locked(charNum, unlockCondition, notify)
} }
end end
---@return string ---@description A function that sets a character under a specific category
---@added 1.14
---@param charNum integer|nil The number of the Character you want to Lock
---@param category string The Category Name (Will create a new category if category does not exist)
local function character_set_category(charNum, category)
category = string_underscore_to_space(category)
local foundCategory = false
for i = 1, #characterCategories do
if characterCategories[i] == category then
foundCategory = true
end
end
if not foundCategory then
table_insert(characterCategories, category)
end
characterTable[charNum].category = characterTable[charNum].category .. "_" .. category
end
---@header
---@forcedoc Menu_Functions
---@description A function that sets the big "Character Select" texture in the Character Select Menu
---@added 1.7
---@param texture TextureInfo|nil
---@forcedoc header_set_texture
---@description A function that returns the version string
---@added 1
---@return string --`"v1.2.3"`
local function version_get() local function version_get()
return MOD_VERSION_STRING return MOD_VERSION_STRING
end end
---@description A function that returns the version in table format
---@added 1.11
---@return table ---@return table
---@note Returns the following table (Will differ based on version)
---@note ```lua
---@note {
---@note api = 1,
---@note major = 2,
---@note minor = 3,
---@note indev = true
---@note }
---@note ```
local function version_get_full() local function version_get_full()
return { return {
api = MOD_VERSION_API, api = MOD_VERSION_API,
@ -485,61 +653,63 @@ local function version_get_full()
} }
end end
---@description A function that checks is the Character Select Menu is currently open
---@added 1
---@return boolean ---@return boolean
local function is_menu_open() local function is_menu_open()
return menuAndTransition return menuAndTransition
end end
---@description A function that forces they Character Select Menu state
---@added 1.8
---@param bool boolean|nil Sets if the menu is open ---@param bool boolean|nil Sets if the menu is open
local function set_menu_open(bool) local function set_menu_open(bool)
if bool == nil then bool = true end if bool == nil then bool = true end
menu = bool menu = bool
end end
---@description A function that gets Character Select's current Menu color
---@added 1.8
---@return table ---@return table
local function get_menu_color() local function get_menu_color()
return menuColor return menuColor
end end
---@param func function ---------------------------
local function hook_allow_menu_open(func) -- HUD Element Functions --
if type(func) ~= TYPE_FUNCTION then return end ---------------------------
table_insert(allowMenu, func)
end
---@param func function ---@header
local function hook_render_in_menu(func, underText) ---@forcedoc HUD_Element_Functions
if type(func) ~= TYPE_FUNCTION then return end
if underText then
table_insert(renderInMenuTable.back, func)
else
table_insert(renderInMenuTable.front, func)
end
end
---@param charNum integer|nil ---@description Hides the specified custom hud element
---@param hookEventType LuaHookedEventType|integer ---@added 1.5
---@param func function ---@param hudElement HUDDisplayFlag
local function character_hook_moveset(charNum, hookEventType, func) ---@forcedoc hud_hide_element
if charNum > #characterTable then return end
if type(func) ~= TYPE_FUNCTION then return end
characterMovesets[charNum][hookEventType] = func
characterTable[charNum].hasMoveset = true
end
---@param charNum integer ---@description Shows the specified custom hud element
local function character_get_moveset(charNum) ---@added 1.5
return characterMovesets[charNum] ---@param hudElement HUDDisplayFlag
end ---@forcedoc hud_show_element
---@description Gets the specified custom hud element's state
---@added 1.5
---@param hudElement HUDDisplayFlag
---@return boolean
---@forcedoc hud_get_element
---@description A function that checks if the options menu is open inside of the CS menu
---@added 1
---@return boolean ---@return boolean
local function is_options_open() local function is_options_open()
return options return options
end end
---@param modName string ---@description A function that adds a line of credit to the CS Options' Credit section
---@param creditTo string Who did the thing ---@added 1.10
---@param creditFor string What did they do ---@param modName string The Name of your Character Select Mod
---@param creditTo string The person you want to Credit
---@param creditFor string What the Person helped with
local function credit_add(modName, creditTo, creditFor) local function credit_add(modName, creditTo, creditFor)
if #creditTable > 1 then if #creditTable > 1 then
for i = 2, #creditTable do for i = 2, #creditTable do
@ -556,18 +726,24 @@ local function credit_add(modName, creditTo, creditFor)
table_insert(creditTable[i], {creditTo = creditTo, creditFor = creditFor}) table_insert(creditTable[i], {creditTo = creditTo, creditFor = creditFor})
end end
---@description A function that sets if palettes are restricted (Default `false` unless a mod with the incompatible `gamemode` is on)
---@added 1.8
---@param bool boolean ---@param bool boolean
local function restrict_palettes(bool) local function restrict_palettes(bool)
if bool == nil then bool = true end if bool == nil then bool = true end
stopPalettes = bool stopPalettes = bool
end end
---@description A function that sets if movesets are restricted (Default `false`)
---@added 1.10
---@param bool boolean ---@param bool boolean
local function restrict_movesets(bool) local function restrict_movesets(bool)
if bool == nil then bool = true end if bool == nil then bool = true end
stopMovesets = bool stopMovesets = bool
end end
---@description A table that contains the local mario's controller before Character Select's menu cancels them
---@added 1
local controller = { local controller = {
buttonDown = 0, buttonDown = 0,
buttonPressed = 0, buttonPressed = 0,
@ -580,13 +756,15 @@ local controller = {
stickY = 0 stickY = 0
} }
---@param name string ---@description A function that adds an option to the Character Select Options Menu
---@param toggleDefault number|nil Defaults to 0 ---@added 1.9
---@param toggleMax number|nil Defaults to 1 ---@param name string The Name of the Option
---@param toggleNames table|nil Table of Strings {"Off", "On"} ---@param toggleDefault number|nil The default number that the option toggles to (Defaults to `0`)
---@param description table|nil Table of Strings {"This toggle allows your", "character to feel everything."} ---@param toggleMax number|nil The max number the option can be toggled to (Defaults to `1`)
---@param save boolean|nil Defaults to true ---@param toggleNames table|nil A table of strings, each entry being for a toggle's name `{"Off", "On"}`
---@return number ---@param description table|nil A table of strings, each entry being a new line `{"This toggle allows your", "character to feel everything."}`
---@param save boolean|nil Toggles whether the option retains between sessions (Defaults to `true`)
---@return number --The table position of the option added
local function add_option(name, toggleDefault, toggleMax, toggleNames, description, save) local function add_option(name, toggleDefault, toggleMax, toggleNames, description, save)
if save == nil then save = true end if save == nil then save = true end
local saveName = string_space_to_underscore(name) local saveName = string_space_to_underscore(name)
@ -603,22 +781,28 @@ local function add_option(name, toggleDefault, toggleMax, toggleNames, descripti
return #optionTable return #optionTable
end end
---@param tableNum integer ---@description A function that gets an option's data from the Character Select Options Menu
---@added 1.9
---@param tableNum integer The table position of the option
---@return table|nil ---@return table|nil
local function get_option(tableNum) local function get_option(tableNum)
if type(tableNum) ~= TYPE_INTEGER then return nil end if type(tableNum) ~= TYPE_INTEGER then return nil end
return optionTable[tableNum] return optionTable[tableNum]
end end
---@param tableNum integer ---@description A function that gets an option's status from the Character Select Options Menu
---@added 1.9
---@param tableNum integer The table position of the option
---@return number|nil ---@return number|nil
local function get_options_status(tableNum) local function get_options_status(tableNum)
if type(tableNum) ~= TYPE_INTEGER then return nil end if type(tableNum) ~= TYPE_INTEGER then return nil end
return optionTable[tableNum].toggle return optionTable[tableNum].toggle
end end
---@param tableNum integer ---@description A function that sets an option's status from the Character Select Options Menu
---@param toggle integer ---@added 1.9
---@param tableNum integer The table position of the option
---@param toggle integer What you want to set the option to
local function set_options_status(tableNum, toggle) local function set_options_status(tableNum, toggle)
local currOption = optionTable[tableNum] local currOption = optionTable[tableNum]
if currOption == nil or type(toggle) ~= TYPE_INTEGER or toggle > currOption.toggleMax or toggle < 1 then return end if currOption == nil or type(toggle) ~= TYPE_INTEGER or toggle > currOption.toggleMax or toggle < 1 then return end
@ -626,6 +810,89 @@ local function set_options_status(tableNum, toggle)
optionTable[tableNum].optionBeingSet = true optionTable[tableNum].optionBeingSet = true
end end
---@header
---@forcedoc Misc
---@description A function that sets the name to be replaced in Dialog, Default is `"Mario"`
---@added 1.10
---@param name string
---@note This function does *NOT* change what NPCs will refer to your character as, this function is intended for Rom-Hack ports with alternate protagonists.
---@forcedoc dialog_set_replace_name
---@description A function that sets the preset palette for a network player forcefully
---@added 1.11
---@param np NetworkPlayer
---@forcedoc update_preset_palette
---@header
---@forcedoc Tables & Variables
---@description The "Reference Sheet" or IDs for all of Character Select's Options
---@added 1
---@forcedoc optionTableRef
---@description The info for inputs from `gMarioStates[0]` before Character Select's Menu cancels inputs
---@added 1
---@forcedoc controller
---@description A table containing player info from Character Select's custom networking system
---@added 1.11.1
---@forcedoc gCSPlayers
---@description The ID for Character Select's Menu "Cutscene"
---@added 1
---@forcedoc CUTSCENE_CS_MENU
---@description The ID for Character Select's Menu Animation ID, Used in combination with character_add_animations to display a specific pose in the menu.
---@added 1.14
---@forcedoc CS_ANIM_MENU
---@header
---@forcedoc Character_Select_Hooks
---@description A function that allows you to add a condition for if the CS Menu can be opened
---@added 1
---@param func function
local function hook_allow_menu_open(func)
if type(func) ~= TYPE_FUNCTION then return end
table_insert(allowMenu, func)
end
---@description A function that allows you to render HUD Elements in the menu (Behind transistions such as Option and going in/out of menu)
---@added 1.5
---@param func function
local function hook_render_in_menu(func, underText)
if type(func) ~= TYPE_FUNCTION then return end
if underText then
table_insert(renderInMenuTable.back, func)
else
table_insert(renderInMenuTable.front, func)
end
end
---@description A function that adds the necessary hooks in order for your pack to have function voicelines
---@added 1.12
---@forcedoc config_character_sounds
---@description A function that allows you to hook a function, much like hook_event, to a specific character number
---@added 1.10
---@param charNum integer|nil
---@param hookEventType LuaHookedEventType|integer
---@param func function
local function character_hook_moveset(charNum, hookEventType, func)
if charNum > #characterTable then return end
if type(func) ~= TYPE_FUNCTION then return end
characterMovesets[charNum][hookEventType] = func
characterTable[charNum].hasMoveset = true
end
---@description A function that returns the Character's moveset functions
---@added 1.14
---@param charNum integer
local function character_get_moveset(charNum)
return characterMovesets[charNum]
end
_G.charSelectExists = true _G.charSelectExists = true
_G.charSelect = { _G.charSelect = {
-- Character Functions -- -- Character Functions --
@ -647,8 +914,8 @@ _G.charSelect = {
character_get_current_table = character_get_current_table, character_get_current_table = character_get_current_table,
character_get_full_table = character_get_full_table, character_get_full_table = character_get_full_table,
character_get_current_number = character_get_current_number, character_get_current_number = character_get_current_number,
character_get_current_costume = character_get_current_costume,
character_get_current_model_number = character_get_current_number, -- Outdated function name, Not recommended for use character_get_current_model_number = character_get_current_number, -- Outdated function name, Not recommended for use
character_get_current_costume = character_get_current_costume,
character_set_current_number = character_set_current_number, character_set_current_number = character_set_current_number,
character_get_current_palette = character_get_current_palette, character_get_current_palette = character_get_current_palette,
character_get_current_palette_number = character_get_current_palette_number, character_get_current_palette_number = character_get_current_palette_number,
@ -663,12 +930,13 @@ _G.charSelect = {
character_get_health_meter = health_meter_from_local_index, -- Function located in n-hud.lua character_get_health_meter = health_meter_from_local_index, -- Function located in n-hud.lua
character_render_health_meter = render_health_meter_from_local_index, -- Function located in n-hud.lua character_render_health_meter = render_health_meter_from_local_index, -- Function located in n-hud.lua
character_set_locked = character_set_locked, character_set_locked = character_set_locked,
character_set_category = character_set_category,
character_get_moveset = character_get_moveset, character_get_moveset = character_get_moveset,
-- Hud Element Functions -- -- Hud Element Functions --
hud_hide_element = hud_hide_element, hud_hide_element = hud_hide_element, -- Function located in n-hud.lua
hud_show_element = hud_show_element, hud_show_element = hud_show_element, -- Function located in n-hud.lua
hud_get_element = hud_get_element, hud_get_element = hud_get_element, -- Function located in n-hud.lua
-- Menu Functions -- -- Menu Functions --
header_set_texture = header_set_texture, -- Function located in main.lua header_set_texture = header_set_texture, -- Function located in main.lua
@ -688,15 +956,34 @@ _G.charSelect = {
-- Misc -- -- Misc --
dialog_set_replace_name = dialog_set_replace_name, -- Function located in dialog.lua dialog_set_replace_name = dialog_set_replace_name, -- Function located in dialog.lua
update_preset_palette = placeholder, -- Function located in z-palettes.lua
-- Tables & Variables -- -- Tables & Variables --
optionTableRef = optionTableRef, optionTableRef = optionTableRef,
controller = controller, controller = controller,
gCSPlayers = gCSPlayers, gCSPlayers = gCSPlayers,
CUTSCENE_CS_MENU = CUTSCENE_CS_MENU, CUTSCENE_CS_MENU = CUTSCENE_CS_MENU,
CS_ANIM_MENU = CS_ANIM_MENU,
-- Custom Hooks -- -- Character Select Hooks --
hook_allow_menu_open = hook_allow_menu_open, hook_allow_menu_open = hook_allow_menu_open,
hook_render_in_menu = hook_render_in_menu, hook_render_in_menu = hook_render_in_menu,
config_character_sounds = placeholder, -- Function located in z-voice.lua
character_hook_moveset = character_hook_moveset, character_hook_moveset = character_hook_moveset,
} }
-- Replace base functions
local obj_set_model_extended_original = obj_set_model_extended
-- Replace obj_set_model_extended to error for mario models
---@ignore
local function obj_set_model_extended(obj, modelInfo)
for i = 0, MAX_PLAYERS - 1 do
if gMarioStates[i].marioObj == obj then
log_to_console("Character Select: Mario Object cannot be changed with 'obj_set_model_extended' while Character Select is Active, please use 'character_edit'!!", CONSOLE_MESSAGE_WARNING)
end
end
return obj_set_model_extended_original(obj, modelInfo)
end
_G.obj_set_model_extended = obj_set_model_extended

View file

@ -162,4 +162,13 @@ local function object_render(obj)
if currMoveset == nil or currMoveset[hook] == nil then return end if currMoveset == nil or currMoveset[hook] == nil then return end
return currMoveset[hook](obj) return currMoveset[hook](obj)
end end
hook_event(HOOK_ON_OBJECT_RENDER, object_render) hook_event(HOOK_ON_OBJECT_RENDER, object_render)
local function allow_water_action(m, water)
if stopMovesets or not gCSPlayers[0].movesetToggle then return end
local hook = HOOK_ALLOW_FORCE_WATER_ACTION
local currMoveset = characterMovesets[find_character_number(0)]
if currMoveset == nil or currMoveset[hook] == nil then return end
return currMoveset[hook](m, water)
end
hook_event(HOOK_ALLOW_FORCE_WATER_ACTION, allow_water_action)

View file

@ -74,14 +74,6 @@ characterColorPresets = {
} }
} }
local defaultModels = {
[CT_MARIO] = E_MODEL_MARIO,
[CT_LUIGI] = E_MODEL_LUIGI,
[CT_TOAD] = E_MODEL_TOAD_PLAYER,
[CT_WALUIGI] = E_MODEL_WALUIGI,
[CT_WARIO] = E_MODEL_WARIO
}
local paletteLoop = #characterColorPresets[E_MODEL_MARIO][1] local paletteLoop = #characterColorPresets[E_MODEL_MARIO][1]
local function network_player_set_full_override_palette(networkPlayer, colorTable) local function network_player_set_full_override_palette(networkPlayer, colorTable)

View file

@ -83,7 +83,7 @@ end
--- @param sound CharacterSound --- @param sound CharacterSound
local function custom_character_sound(m, sound) local function custom_character_sound(m, sound)
if m.playerIndex == 0 then if m.playerIndex == 0 then
if stallTimer < stallSayLine - 1 then if stallTimer < stallSayLine then
return NO_SOUND return NO_SOUND
end end
end end
@ -204,7 +204,8 @@ _G.charSelect.voice = {
-- Must be ran on startup -- Must be ran on startup
local function config_character_sounds() local function config_character_sounds()
hook_event(HOOK_CHARACTER_SOUND, custom_character_sound) hook_event(HOOK_CHARACTER_SOUND, custom_character_sound)
hook_event(HOOK_MARIO_UPDATE, custom_character_snore) --hook_event(HOOK_MARIO_UPDATE, custom_character_snore)
cs_hook_mario_update(custom_character_snore)
end end
_G.charSelect.config_character_sounds = config_character_sounds _G.charSelect.config_character_sounds = config_character_sounds
@ -218,4 +219,5 @@ local function mario_update(m)
stallTimer = stallTimer + 1 stallTimer = stallTimer + 1
end end
end end
hook_event(HOOK_MARIO_UPDATE, mario_update) --hook_event(HOOK_MARIO_UPDATE, mario_update)
cs_hook_mario_update(mario_update)