-
Notifications
You must be signed in to change notification settings - Fork 1
/
dialog.lua
35 lines (27 loc) · 1.13 KB
/
dialog.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- Made by EliteMasterEric along with CoopDX PR #321 to replace dialog depending on character --
-- https://github.com/coop-deluxe/sm64coopdx/pull/321 --
if not smlua_text_utils_dialog_get then return end
-- localize functions to improve performance - dialog.lua
local smlua_text_utils_dialog_replace,smlua_text_utils_dialog_get = smlua_text_utils_dialog_replace,smlua_text_utils_dialog_get
local DIALOG_NAME = "Mario"
---@param name string
function dialog_set_replace_name(name)
DIALOG_NAME = name
end
local prevChar = currChar
local function dialog_swap()
for i = DIALOG_000, DIALOG_COUNT - 1 do
local dialog = smlua_text_utils_dialog_get(i)
local name = characterTable[currChar][characterTable[currChar].currAlt].name
local replaced_dialog = dialog.str:gsub(DIALOG_NAME, currChar)
smlua_text_utils_dialog_replace(DIALOG_034, dialog.unused, dialog.linesPerBox, dialog.leftOffset, dialog.width, replaced_dialog)
end
end
local function update()
-- Query Character Swapped
if prevChar ~= currChar then
dialog_swap()
prevChar = currChar
end
end
hook_event(HOOK_UPDATE, update)