named desition handler functions
This commit is contained in:
@@ -47,82 +47,87 @@ local function get_initial_data()
|
|||||||
game_in_progress = false, -- New flag
|
game_in_progress = false, -- New flag
|
||||||
screens = clone_table({
|
screens = clone_table({
|
||||||
{
|
{
|
||||||
|
id = "home",
|
||||||
name = "Home",
|
name = "Home",
|
||||||
decisions = {
|
decisions = {
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_toilet",
|
"go_to_toilet",
|
||||||
"Go to Toilet",
|
"Go to Toilet",
|
||||||
function() Context.current_screen = 2; Context.selected_desition_index = 1 end
|
Desitions.go_to_toilet
|
||||||
),
|
),
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_walking_to_office",
|
"go_to_walking_to_office",
|
||||||
"Go to Walking to office",
|
"Go to Walking to office",
|
||||||
function() Context.current_screen = 3; Context.selected_desition_index = 1 end
|
Desitions.go_to_walking_to_office
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id = "toilet",
|
||||||
name = "Toilet",
|
name = "Toilet",
|
||||||
decisions = {
|
decisions = {
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_home",
|
"go_to_home",
|
||||||
"Go to Home",
|
"Go to Home",
|
||||||
function() Context.current_screen = 1; Context.selected_desition_index = 1 end
|
Desitions.go_to_home
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id = "walking_to_office",
|
||||||
name = "Walking to office",
|
name = "Walking to office",
|
||||||
decisions = {
|
decisions = {
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_home",
|
"go_to_home",
|
||||||
"Go to Home",
|
"Go to Home",
|
||||||
function() Context.current_screen = 1; Context.selected_desition_index = 1 end
|
Desitions.go_to_home
|
||||||
),
|
),
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_office",
|
"go_to_office",
|
||||||
"Go to Office",
|
"Go to Office",
|
||||||
function() Context.current_screen = 4; Context.selected_desition_index = 1 end
|
Desitions.go_to_office
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id = "office",
|
||||||
name = "Office",
|
name = "Office",
|
||||||
decisions = {
|
decisions = {
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"play_button_mash",
|
"play_button_mash",
|
||||||
"Play Button Mash",
|
"Play Button Mash",
|
||||||
function() Desitions.start_minigame_mash() end
|
Desitions.start_minigame_mash
|
||||||
),
|
),
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"play_rhythm",
|
"play_rhythm",
|
||||||
"Play Rhythm Game",
|
"Play Rhythm Game",
|
||||||
function() Desitions.start_minigame_rhythm() end
|
Desitions.start_minigame_rhythm
|
||||||
),
|
),
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"play_ddr",
|
"play_ddr",
|
||||||
"Play DDR (Random)",
|
"Play DDR (Random)",
|
||||||
function() Desitions.start_minigame_ddr(nil) end
|
Desitions.start_minigame_ddr
|
||||||
),
|
),
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_walking_to_home",
|
"go_to_walking_to_home",
|
||||||
"Go to Walking to home",
|
"Go to Walking to home",
|
||||||
function() Context.current_screen = 5; Context.selected_desition_index = 1 end
|
Desitions.go_to_walking_to_home
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id = "walking_to_home",
|
||||||
name = "Walking to home",
|
name = "Walking to home",
|
||||||
decisions = {
|
decisions = {
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_home",
|
"go_to_home",
|
||||||
"Go to Home",
|
"Go to Home",
|
||||||
function() Context.current_screen = 1; Context.selected_desition_index = 1 end
|
Desitions.go_to_home
|
||||||
),
|
),
|
||||||
Util.create_decision(
|
Util.create_decision(
|
||||||
"go_to_office",
|
"go_to_office",
|
||||||
"Go to Office",
|
"Go to Office",
|
||||||
function() Context.current_screen = 4; Context.selected_desition_index = 1 end
|
Desitions.go_to_office
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
Desitions = {}
|
||||||
|
|
||||||
|
function Desitions.go_to_screen(screen_id)
|
||||||
|
for i, screen_data in ipairs(Context.screens) do
|
||||||
|
if screen_data.id == screen_id then
|
||||||
|
Context.current_screen = i
|
||||||
|
Context.selected_desition_index = 1 -- Reset selected decision on new screen
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Handle error: screen_id not found, perhaps show a debug message or a popup
|
||||||
|
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found!"})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Specific navigation helpers
|
||||||
|
function Desitions.go_to_home() Desitions.go_to_screen("home") end
|
||||||
|
function Desitions.go_to_toilet() Desitions.go_to_screen("toilet") end
|
||||||
|
function Desitions.go_to_walking_to_office() Desitions.go_to_screen("walking_to_office") end
|
||||||
|
function Desitions.go_to_office() Desitions.go_to_screen("office") end
|
||||||
|
function Desitions.go_to_walking_to_home() Desitions.go_to_screen("walking_to_home") end
|
||||||
|
|
||||||
|
-- Minigame functions
|
||||||
function Desitions.start_minigame_mash()
|
function Desitions.start_minigame_mash()
|
||||||
MinigameButtonMashWindow.start(WINDOW_GAME)
|
MinigameButtonMashWindow.start(WINDOW_GAME)
|
||||||
end
|
end
|
||||||
@@ -8,4 +30,4 @@ end
|
|||||||
|
|
||||||
function Desitions.start_minigame_ddr(song_key)
|
function Desitions.start_minigame_ddr(song_key)
|
||||||
MinigameDDRWindow.start(WINDOW_GAME, song_key)
|
MinigameDDRWindow.start(WINDOW_GAME, song_key)
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user