feature/refactor-npc-handling-to-desition-handling #3
@@ -2,13 +2,7 @@ DesitionManager.register({
|
|||||||
id = "go_to_home",
|
id = "go_to_home",
|
||||||
label = "Go to Home",
|
label = "Go to Home",
|
||||||
handle = function()
|
handle = function()
|
||||||
local screen_index = Context.screen_indices_by_id["home"]
|
Util.go_to_screen_by_id("home")
|
||||||
if screen_index then
|
|
||||||
Context.current_screen = screen_index
|
|
||||||
Context.selected_desition_index = 1
|
|
||||||
else
|
|
||||||
PopupWindow.show({"Error: Screen 'home' not found or not indexed!"})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
condition = function() return true end
|
condition = function() return true end
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,13 +2,7 @@ DesitionManager.register({
|
|||||||
id = "go_to_office",
|
id = "go_to_office",
|
||||||
label = "Go to Office",
|
label = "Go to Office",
|
||||||
handle = function()
|
handle = function()
|
||||||
local screen_index = Context.screen_indices_by_id["office"]
|
Util.go_to_screen_by_id("office")
|
||||||
if screen_index then
|
|
||||||
Context.current_screen = screen_index
|
|
||||||
Context.selected_desition_index = 1
|
|
||||||
else
|
|
||||||
PopupWindow.show({"Error: Screen 'office' not found or not indexed!"})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
condition = function() return true end
|
condition = function() return true end
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,13 +2,7 @@ DesitionManager.register({
|
|||||||
id = "go_to_toilet",
|
id = "go_to_toilet",
|
||||||
label = "Go to Toilet",
|
label = "Go to Toilet",
|
||||||
handle = function()
|
handle = function()
|
||||||
local screen_index = Context.screen_indices_by_id["toilet"]
|
Util.go_to_screen_by_id("toilet")
|
||||||
if screen_index then
|
|
||||||
Context.current_screen = screen_index
|
|
||||||
Context.selected_desition_index = 1
|
|
||||||
else
|
|
||||||
PopupWindow.show({"Error: Screen 'toilet' not found or not indexed!"})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
condition = function() return true end
|
condition = function() return true end
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,13 +2,7 @@ DesitionManager.register({
|
|||||||
id = "go_to_walking_to_home",
|
id = "go_to_walking_to_home",
|
||||||
label = "Go to Walking to home",
|
label = "Go to Walking to home",
|
||||||
handle = function()
|
handle = function()
|
||||||
local screen_index = Context.screen_indices_by_id["walking_to_home"]
|
Util.go_to_screen_by_id("walking_to_home")
|
||||||
if screen_index then
|
|
||||||
Context.current_screen = screen_index
|
|
||||||
Context.selected_desition_index = 1
|
|
||||||
else
|
|
||||||
PopupWindow.show({"Error: Screen 'walking_to_home' not found or not indexed!"})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
condition = function() return true end
|
condition = function() return true end
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,13 +2,7 @@ DesitionManager.register({
|
|||||||
id = "go_to_walking_to_office",
|
id = "go_to_walking_to_office",
|
||||||
label = "Go to Walking to office",
|
label = "Go to Walking to office",
|
||||||
handle = function()
|
handle = function()
|
||||||
local screen_index = Context.screen_indices_by_id["walking_to_office"]
|
Util.go_to_screen_by_id("walking_to_office")
|
||||||
if screen_index then
|
|
||||||
Context.current_screen = screen_index
|
|
||||||
Context.selected_desition_index = 1
|
|
||||||
else
|
|
||||||
PopupWindow.show({"Error: Screen 'walking_to_office' not found or not indexed!"})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
condition = function() return true end
|
condition = function() return true end
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,4 +2,14 @@ Util = {}
|
|||||||
|
|
||||||
function Util.safeindex(array, index)
|
function Util.safeindex(array, index)
|
||||||
return ((index - 1 + #array) % #array) + 1
|
return ((index - 1 + #array) % #array) + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function Util.go_to_screen_by_id(screen_id)
|
||||||
|
local screen_index = Context.screen_indices_by_id[screen_id]
|
||||||
|
if screen_index then
|
||||||
|
Context.current_screen = screen_index
|
||||||
|
Context.selected_desition_index = 1 -- Reset selected decision on new screen
|
||||||
|
else
|
||||||
|
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found or not indexed!"})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user