i've been toying around blocking characters in character select mod plus, and was able to put character locked based on number of stars. Checking online it says that we can also have parameters for whend bowser is defeated and specific star missions, but for days i have been trying the specific star thing and i am unable to make it work. Could someone see the script that works on star count i put in the main.lua and show me how to change it to a specific star. Also, i've changed the name of DK to Donkey Kong JR.
local function on_character_select_load()
for i, char in pairs(extraCharacters) do
local _ENV = setmetatable(char, { __index = _G })
tablePos = character_add(name, description, credits, color, model, forceChar, lifeIcon, camScale, offset, meter, graffiti)
if name == "Donkey Kong JR." then
donkeyKongJrSlot = tablePos
end
if caps then character_add_caps(model, caps) end
if voices then character_add_voice(model, voices) end
if palettes then
for i = 1, #palettes do
character_add_palette_preset(model, palettes, palettes.name)
end
end
character_set_category(tablePos, "CoopDX")
if anims then character_add_animations(model, anims, eyes, hands) end
if meter then character_add_health_meter(tablePos, meter) end
if graffiti then character_add_graffiti(tablePos, graffiti) end
end
for i = 1, #ultraBrosCredits do
for c = 1, #ultraBrosCredits do
local creditSplit = string.split(ultraBrosCredits[c], ",")
charSelect.credit_add(ultraBrosCredits.name, creditSplit, creditSplit)
end
end
end
local function safe_lock_handler(m)
-- Passa o estado correto 'm' para a função do diálogo
check_dialog_trigger(m)
if not lockApplied and donkeyKongJrSlot then
character_set_locked(donkeyKongJrSlot, function()
-- Corrigido para indexar gMarioStates[0] corretamente de forma global
if gMarioStates and gMarioStates[0] and gMarioStates[0].numStars then
return gMarioStates[0].numStars >= 3
end
return false
end, true)
lockApplied = true
end
end
smlua_text_utils_dialog_replace(DIALOG_033, 1, 8, 30, 200, [[
Thanks for feeing me,
mister! That mean plumber
locked me up real tight!
I'll get those hard to
reach shinies you're after!
-Donkey Kong JR.]])
-- Keep both hooks active
hook_event(HOOK_ON_MODS_LOADED, on_character_select_load)
hook_event(HOOK_MARIO_UPDATE, safe_lock_handler)
Also this is what normally comes the script whend i try to lock the character based on specific stat. The character is locked, but it remains locked even whend i get the star.
local TARGET_COURSE = COURSE_BOB
local TARGET_STAR_FLAG = 1
local donkeyKongJrSlot = nil
local lockApplied = false
local dkJrDialogPlayed = false
local function check_dialog_trigger(m)
if m.playerIndex ~= 0 then return end
if gCurrSaveFileNum == nil then return end
local fileIndex = gCurrSaveFileNum - 1
local starFlags = save_file_get_course_star_flags(fileIndex, TARGET_COURSE)
if (starFlags & TARGET_STAR_FLAG) ~= 0 and not dkJrDialogPlayed then
local safeActions = { [ACT_IDLE] = true, [ACT_WALKING] = true, [ACT_DECELERATING] = true }
if safeActions[m.action] then
dkJrDialogPlayed = true
create_dialog_box(DIALOG_033)
set_mario_action(m, ACT_READING_NPC_DIALOG, 0)
end
end
end
local function on_character_select_load()
for i, char in pairs(extraCharacters) do
local _ENV = setmetatable(char, { __index = _G })
tablePos = character_add(name, description, credits, color, model, forceChar, lifeIcon, camScale, offset, meter, graffiti)
if name == "Donkey Kong JR." then
donkeyKongJrSlot = tablePos
end
if caps then character_add_caps(model, caps) end
if voices then character_add_voice(model, voices) end
if palettes then
for i = 1, #palettes do
character_add_palette_preset(model, palettes, palettes.name)
end
end
character_set_category(tablePos, "CoopDX")
if anims then character_add_animations(model, anims, eyes, hands) end
if meter then character_add_health_meter(tablePos, meter) end
if graffiti then character_add_graffiti(tablePos, graffiti) end
end
for i = 1, #ultraBrosCredits do
for c = 1, #ultraBrosCredits do
local creditSplit = string.split(ultraBrosCredits[c], ",")
charSelect.credit_add(ultraBrosCredits.name, creditSplit, creditSplit)
end
end
end
local function safe_lock_handler(m)
check_dialog_trigger(m)
if not lockApplied and donkeyKongJrSlot then
character_set_locked(donkeyKongJrSlot, function()
-- Verificação de segurança dentro do menu do Character Select
if gCurrSaveFileNum == nil then return false end
local fileIndex = gCurrSaveFileNum - 1
local starFlags = save_file_get_course_star_flags(fileIndex, TARGET_COURSE)
if (starFlags & TARGET_STAR_FLAG) ~= 0 then
return true
end
return false
end, true)
lockApplied = true
end
end
smlua_text_utils_dialog_replace(DIALOG_033, 1, 8, 30, 200, [[
Thanks for freeing me,
mister! That mean plumber
locked me up real tight!
I'll get those hard to
reach shinies you're after!
-Donkey Kong JR.]])
hook_event(HOOK_ON_MODS_LOADED, on_character_select_load)
hook_event(HOOK_MARIO_UPDATE, safe_lock_handler)
local function on_character_select_load()
for i, char in pairs(extraCharacters) do
local _ENV = setmetatable(char, { __index = _G })
tablePos = character_add(name, description, credits, color, model, forceChar, lifeIcon, camScale, offset, meter, graffiti)
if name == "Donkey Kong JR." then
donkeyKongJrSlot = tablePos
end
if caps then character_add_caps(model, caps) end
if voices then character_add_voice(model, voices) end
if palettes then
for i = 1, #palettes do
character_add_palette_preset(model, palettes, palettes.name)
end
end
character_set_category(tablePos, "CoopDX")
if anims then character_add_animations(model, anims, eyes, hands) end
if meter then character_add_health_meter(tablePos, meter) end
if graffiti then character_add_graffiti(tablePos, graffiti) end
end
for i = 1, #ultraBrosCredits do
for c = 1, #ultraBrosCredits do
local creditSplit = string.split(ultraBrosCredits[c], ",")
charSelect.credit_add(ultraBrosCredits.name, creditSplit, creditSplit)
end
end
end
local function safe_lock_handler(m)
-- Passa o estado correto 'm' para a função do diálogo
check_dialog_trigger(m)
if not lockApplied and donkeyKongJrSlot then
character_set_locked(donkeyKongJrSlot, function()
-- Corrigido para indexar gMarioStates[0] corretamente de forma global
if gMarioStates and gMarioStates[0] and gMarioStates[0].numStars then
return gMarioStates[0].numStars >= 3
end
return false
end, true)
lockApplied = true
end
end
smlua_text_utils_dialog_replace(DIALOG_033, 1, 8, 30, 200, [[
Thanks for feeing me,
mister! That mean plumber
locked me up real tight!
I'll get those hard to
reach shinies you're after!
-Donkey Kong JR.]])
-- Keep both hooks active
hook_event(HOOK_ON_MODS_LOADED, on_character_select_load)
hook_event(HOOK_MARIO_UPDATE, safe_lock_handler)
Don't double post! Use that edit button! Post automatically merged:
Also this is what normally comes the script whend i try to lock the character based on specific stat. The character is locked, but it remains locked even whend i get the star.
local TARGET_COURSE = COURSE_BOB
local TARGET_STAR_FLAG = 1
local donkeyKongJrSlot = nil
local lockApplied = false
local dkJrDialogPlayed = false
local function check_dialog_trigger(m)
if m.playerIndex ~= 0 then return end
if gCurrSaveFileNum == nil then return end
local fileIndex = gCurrSaveFileNum - 1
local starFlags = save_file_get_course_star_flags(fileIndex, TARGET_COURSE)
if (starFlags & TARGET_STAR_FLAG) ~= 0 and not dkJrDialogPlayed then
local safeActions = { [ACT_IDLE] = true, [ACT_WALKING] = true, [ACT_DECELERATING] = true }
if safeActions[m.action] then
dkJrDialogPlayed = true
create_dialog_box(DIALOG_033)
set_mario_action(m, ACT_READING_NPC_DIALOG, 0)
end
end
end
local function on_character_select_load()
for i, char in pairs(extraCharacters) do
local _ENV = setmetatable(char, { __index = _G })
tablePos = character_add(name, description, credits, color, model, forceChar, lifeIcon, camScale, offset, meter, graffiti)
if name == "Donkey Kong JR." then
donkeyKongJrSlot = tablePos
end
if caps then character_add_caps(model, caps) end
if voices then character_add_voice(model, voices) end
if palettes then
for i = 1, #palettes do
character_add_palette_preset(model, palettes, palettes.name)
end
end
character_set_category(tablePos, "CoopDX")
if anims then character_add_animations(model, anims, eyes, hands) end
if meter then character_add_health_meter(tablePos, meter) end
if graffiti then character_add_graffiti(tablePos, graffiti) end
end
for i = 1, #ultraBrosCredits do
for c = 1, #ultraBrosCredits do
local creditSplit = string.split(ultraBrosCredits[c], ",")
charSelect.credit_add(ultraBrosCredits.name, creditSplit, creditSplit)
end
end
end
local function safe_lock_handler(m)
check_dialog_trigger(m)
if not lockApplied and donkeyKongJrSlot then
character_set_locked(donkeyKongJrSlot, function()
-- Verificação de segurança dentro do menu do Character Select
if gCurrSaveFileNum == nil then return false end
local fileIndex = gCurrSaveFileNum - 1
local starFlags = save_file_get_course_star_flags(fileIndex, TARGET_COURSE)
if (starFlags & TARGET_STAR_FLAG) ~= 0 then
return true
end
return false
end, true)
lockApplied = true
end
end
smlua_text_utils_dialog_replace(DIALOG_033, 1, 8, 30, 200, [[
Thanks for freeing me,
mister! That mean plumber
locked me up real tight!
I'll get those hard to
reach shinies you're after!
-Donkey Kong JR.]])
hook_event(HOOK_ON_MODS_LOADED, on_character_select_load)
hook_event(HOOK_MARIO_UPDATE, safe_lock_handler)
Last edited: