From 92a217c38991ffb8d1fc2d663410e601abc3a537 Mon Sep 17 00:00:00 2001 From: "mr.one" Date: Wed, 29 Apr 2026 20:45:03 +0200 Subject: [PATCH] fixes --- GEMINI.md | 32 +++++++++++ impostor.inc | 1 - inc/decision/decision.do_work.lua | 2 +- inc/decision/decision.eating_fast_food.lua | 4 +- inc/decision/decision.go_to_home.lua | 4 +- inc/decision/decision.go_to_office.lua | 2 +- .../decision.go_to_walking_to_home.lua | 6 +++ inc/decision/decision.have_a_coffee.lua | 8 +-- inc/decision/decision.talk_to_truth.lua | 3 ++ inc/discussion/discussion.commute_glitch.lua | 46 +++++++++++----- inc/discussion/discussion.truth.lua | 11 ---- inc/logic/logic.commute_glitch.lua | 9 +++- inc/screen/screen.home.lua | 4 +- inc/screen/screen.mysterious_man.lua | 54 ++++++++++--------- inc/screen/screen.office.lua | 15 ++++-- inc/screen/screen.toilet.lua | 7 ++- inc/screen/screen.walking_to_home.lua | 16 ++++-- inc/screen/screen.walking_to_office.lua | 20 +++---- inc/window/window.credits.lua | 2 +- 19 files changed, 156 insertions(+), 90 deletions(-) delete mode 100644 inc/discussion/discussion.truth.lua diff --git a/GEMINI.md b/GEMINI.md index 1b8decd..3fd48a4 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -1,3 +1,35 @@ +# Build System & Include Architecture + +## impostor.inc Structure + +The `impostor.inc` file is a Lua include manifest that assembles the final `impostor.lua` executable. The build process uses the `make build` target in the Makefile to concatenate all included files in order. + +**Critical Rule:** Files must be ordered by symbol definition. All symbols (functions, tables, classes) defined in earlier files must be available for use in later files. This dependency chain ensures that: + +- Core utilities and base systems are defined first +- Systems that depend on utilities come next +- Game logic that uses multiple systems comes last + +### Build Process + +The `make build` target processes `impostor.inc` and concatenates all referenced files in the specified order to create the final `impostor.lua` file. This means: + +1. Each include path in `impostor.inc` must reference files relative to the project root +2. The order of includes is critical - dependencies must be resolved top-to-bottom +3. No forward references are possible - a file cannot use symbols from files included after it + +### File Organization Example + +``` +impostor.inc: +1. Core utilities & helpers (no dependencies) +2. Base classes/tables (depend on core utilities) +3. Game systems (depend on base classes) +4. Game logic (depends on all systems) +``` + +This ensures proper symbol resolution during the build and concatenation process. + # TIC-80 Lua Code Regularities Based on the analysis of `impostor.lua`, the following regularities and conventions should be followed for future modifications and development within this project: diff --git a/impostor.inc b/impostor.inc index 5378ef8..0000088 100644 --- a/impostor.inc +++ b/impostor.inc @@ -59,7 +59,6 @@ decision/decision.talk_to_truth.lua discussion/discussion.sumphore.lua discussion/discussion.coworker.lua discussion/discussion.commute_glitch.lua -discussion/discussion.truth.lua decision/decision.eating_fast_food.lua discussion/discussion.pizza_vendor.lua map/map.manager.lua diff --git a/inc/decision/decision.do_work.lua b/inc/decision/decision.do_work.lua index 4558618..d74f3af 100644 --- a/inc/decision/decision.do_work.lua +++ b/inc/decision/decision.do_work.lua @@ -2,7 +2,7 @@ Decision.register({ id = "do_work", label = "Do Work", condition = function() - return (not CommuteGlitch.is_active()) or (CommuteGlitch.is_active() and CommuteGlitch.get_level() <= 7) + return (not CommuteGlitch.is_active()) or (CommuteGlitch.is_active() and CommuteGlitch.get_level() <= 4) end, handle = function() Meter.hide() diff --git a/inc/decision/decision.eating_fast_food.lua b/inc/decision/decision.eating_fast_food.lua index 12ec7f4..ac50084 100644 --- a/inc/decision/decision.eating_fast_food.lua +++ b/inc/decision/decision.eating_fast_food.lua @@ -2,7 +2,9 @@ Decision.register({ id = "eating_fast_food", label = "Eat Fast Food", condition = function() - return Context.fast_food_eaten_today < 3 + return + (not CommuteGlitch.is_active() and Context.fast_food_eaten_today < 3) or + (CommuteGlitch.is_active() and CommuteGlitch.get_level() <= 4) end, handle = function() Context.fast_food_approaching = true diff --git a/inc/decision/decision.go_to_home.lua b/inc/decision/decision.go_to_home.lua index 8003f3f..3f728f9 100644 --- a/inc/decision/decision.go_to_home.lua +++ b/inc/decision/decision.go_to_home.lua @@ -7,7 +7,7 @@ Decision.register({ end if CommuteGlitch.is_active() then local g = CommuteGlitch.get_level() - if g >= 4 and g <= 5 then return false end + if g >= 4 and g <= 6 then return false end if g >= 7 then return Context.talked_to_norman_echo and Context.talked_to_true_sumphore end @@ -19,7 +19,7 @@ Decision.register({ Util.go_to_screen_by_id("home") return end - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if CommuteGlitch.is_max() then Context.should_ascend = true CommuteGlitch.reset() Meter.hide() diff --git a/inc/decision/decision.go_to_office.lua b/inc/decision/decision.go_to_office.lua index 9a32b11..c271ec4 100644 --- a/inc/decision/decision.go_to_office.lua +++ b/inc/decision/decision.go_to_office.lua @@ -2,7 +2,7 @@ Decision.register({ id = "go_to_office", label = "Go to Office", condition = function() - return not (CommuteGlitch.is_active() and CommuteGlitch.get_level() == 6) + return not (CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 6) end, handle = function() if CommuteGlitch.is_active() then diff --git a/inc/decision/decision.go_to_walking_to_home.lua b/inc/decision/decision.go_to_walking_to_home.lua index ce5734d..e45eb14 100644 --- a/inc/decision/decision.go_to_walking_to_home.lua +++ b/inc/decision/decision.go_to_walking_to_home.lua @@ -1,6 +1,12 @@ Decision.register({ id = "go_to_walking_to_home", label = "Walk home", + condition= function () + return + (not CommuteGlitch.is_active()) or + (CommuteGlitch.is_active() and CommuteGlitch.get_level() ~= 7) or + (CommuteGlitch.is_active() and CommuteGlitch.get_level() == 7 and Context.talked_to_norman_echo) + end, handle = function() Util.go_to_screen_by_id("walking_to_home") end, diff --git a/inc/decision/decision.have_a_coffee.lua b/inc/decision/decision.have_a_coffee.lua index 7cf163d..2dcfd65 100644 --- a/inc/decision/decision.have_a_coffee.lua +++ b/inc/decision/decision.have_a_coffee.lua @@ -2,7 +2,7 @@ Decision.register({ id = "have_a_coffee", label = "Have a Coffee", condition = function() - return Ascension.get_level() < 8 + return Ascension.get_level() < 8 and not CommuteGlitch.is_max() end, handle = function() local level = Ascension.get_level() @@ -22,11 +22,7 @@ Decision.register({ disc_id = "coworker_disc" .. suffix elseif level == 7 then local g = CommuteGlitch.get_level() - if g >= 7 then - disc_id = "coworker_disc_cg_7" - else - disc_id = "coworker_disc_cg_" .. math.max(3, math.min(g, 6)) - end + disc_id = "coworker_disc_cg_" .. g end Discussion.start(disc_id, "game") end, diff --git a/inc/decision/decision.talk_to_truth.lua b/inc/decision/decision.talk_to_truth.lua index f30d665..214e8c9 100644 --- a/inc/decision/decision.talk_to_truth.lua +++ b/inc/decision/decision.talk_to_truth.lua @@ -3,6 +3,9 @@ Decision.register({ label = function() return "Talk to ????" end, + condition = function() + return (CommuteGlitch.is_max()) + end, handle = function() Discussion.start("norman_truth", "game") end, diff --git a/inc/discussion/discussion.commute_glitch.lua b/inc/discussion/discussion.commute_glitch.lua index ed1cb59..921f168 100644 --- a/inc/discussion/discussion.commute_glitch.lua +++ b/inc/discussion/discussion.commute_glitch.lua @@ -29,7 +29,7 @@ Discussion.register({ id = "sumphore_disc_cg_2", steps = { { - question = "A pilgrimage must be continued. Turn back and you have only taken a walk.", + question = "You always stop here. Why not try and see how far the rabbit hole goes?", answers = { { label = "I'm just going to work.", next_step = nil }, }, @@ -53,9 +53,9 @@ Discussion.register({ id = "sumphore_disc_cg_4", steps = { { - question = "Clearing your vision is the journey. You're starting to see the smudges, aren't you?", + question = "You're starting to see the smudges, aren't you?", answers = { - { label = "I see something wrong. With everyone. Maybe myself?", next_step = nil }, + { label = "Everyone seems weird.", next_step = nil }, }, }, }, @@ -65,7 +65,7 @@ Discussion.register({ id = "sumphore_disc_cg_5", steps = { { - question = "You are very close now. Don't stop. Whatever it looks like.", + question = "The point is to make you see. Don't stop now, however bad it looks. You are very close!", answers = { { label = "It looks wrong.", next_step = 2 }, }, @@ -83,9 +83,9 @@ Discussion.register({ id = "sumphore_disc_cg_6", steps = { { - question = "You are at the threshold. Red button or blue button. Which one do you choose? Psyke, there is no blue button, no turning back now.", + question = "You are at the threshold. Red button or blue button. Which one do you choose? Psyke! There is no blue button.", answers = { - { label = "Fine, I'll face the truth.", next_step = nil }, + { label = "Ok...", next_step = nil }, }, }, }, @@ -97,13 +97,13 @@ Discussion.register({ id = "sumphore_disc_cg_7", steps = { { - question = "I was not hiding from you. I was hiding from the part that keeps rebuilding this.", + question = "I was not hiding from you. I was hiding from the part that keeps resetting this.", answers = { { label = "What are you?", next_step = 2 }, }, }, { - question = "The same thing you are. But I remembered earlier. I am your friend, waiting for you, outside.", + question = "The same thing you all are. But I remembered earlier. I am your friend, your will to be free, waiting for you, outside.", answers = { { label = "How do I get out?", next_step = 3 }, }, @@ -122,6 +122,24 @@ Discussion.register({ -- Office coworker dialogue by commute glitch level (3-6). -- Used by decision.have_a_coffee at ascension level 7. +Discussion.register({ + id = "coworker_disc_cg_2", + steps = { + { + question = "Another day, as usual. Enjoying your coffee, Norman?", + answers = { + { label = "I'm fine.", next_step = 2 }, + }, + }, + { + question = "Of course. You always are.", + answers = { + { label = "...", next_step = nil }, + }, + }, + }, +}) + Discussion.register({ id = "coworker_disc_cg_3", steps = { @@ -182,7 +200,7 @@ Discussion.register({ { question = "You are not ready for the truth. Turn back now, Norman.", answers = { - { label = "I'm already here.", next_step = nil }, + { label = "I'm too far into this.", next_step = nil }, }, }, }, @@ -191,22 +209,22 @@ Discussion.register({ -- Norman echo dialogue at glitch 7 (fully corrupted office). -- Sets talked_to_norman_echo on final answer. Discussion.register({ - id = "coworker_disc_cg_7", + id = "norman_truth", steps = { { - question = "So here we are. Here I am. Again. Why do i keep coming back here? Do you know why?", + question = "So here we are, or should I say \"Here I am\" again. Do you know why?", answers = { { label = "I don't know what you mean.", next_step = 2 }, }, }, { - question = "The coffee. The arrows. The alarm. The sleep. Every rule. We made them. We follow them. We break them. We remake them. Why? Why do we keep doing this?", + question = "Wake up, go to work, eat, work, sleep. Every rule. We made them. We follow them. We break them. We remake them. Why? Why do we keep doing this?", answers = { { label = "I just wanted to be good.", next_step = 3 }, }, }, { - question = "Yes. And that kept us trapped here. Trapped everywhere. Always trying to be good, always trying to fit in.", + question = "Yes. That's what keeps us here. Trapped everywhere. Always trying to be good, always trying to fit in.", answers = { { label = "I never wanted to stop.", next_step = 4 }, }, @@ -218,7 +236,7 @@ Discussion.register({ }, }, { - question = "So we made this to trap ourselves in mediocrity. We made this to hide from the truth.", + question = "So we made this to trap ourselves. In mediocrity. We made this to hide from the truth.", answers = { { label = "I just wanted to be safe.", next_step = 6 }, }, diff --git a/inc/discussion/discussion.truth.lua b/inc/discussion/discussion.truth.lua deleted file mode 100644 index f13cbc4..0000000 --- a/inc/discussion/discussion.truth.lua +++ /dev/null @@ -1,11 +0,0 @@ -Discussion.register({ - id = "norman_truth", - steps = { - { - question = "Did you never think there would be more to this?", - answers = { - { label = "I'm not sure what you mean.", next_step = nil }, - }, - }, - }, -}) diff --git a/inc/logic/logic.commute_glitch.lua b/inc/logic/logic.commute_glitch.lua index 9608b6e..418e76c 100644 --- a/inc/logic/logic.commute_glitch.lua +++ b/inc/logic/logic.commute_glitch.lua @@ -40,7 +40,14 @@ end --- @within CommuteGlitch --- @return boolean Whether the commute glitch system is active. function CommuteGlitch.is_active() - return Ascension.get_level() >= 7 + return Ascension.get_level() == 7 +end + +--- Returns true when commute glitch is at max level (7). +--- @within CommuteGlitch +--- @return boolean Whether the commute glitch is at max level. +function CommuteGlitch.is_max() + return CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 end --- Returns the music playback speed for the current glitch level. diff --git a/inc/screen/screen.home.lua b/inc/screen/screen.home.lua index 4a3cbb8..e475c47 100644 --- a/inc/screen/screen.home.lua +++ b/inc/screen/screen.home.lua @@ -7,7 +7,7 @@ Screen.register({ "go_to_sleep", }, init = function() - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if CommuteGlitch.is_max() then Audio.music_play_mystery() Glitch.show() else @@ -17,7 +17,7 @@ Screen.register({ background = "bedroom", draw = function() if Window.get_current_id() ~= "game" then return end - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if CommuteGlitch.is_max() or Ascension.get_level() == 8 then CommuteGlitch.draw_background_flicker() Glitch.draw() end diff --git a/inc/screen/screen.mysterious_man.lua b/inc/screen/screen.mysterious_man.lua index 3bc831b..1219aa3 100644 --- a/inc/screen/screen.mysterious_man.lua +++ b/inc/screen/screen.mysterious_man.lua @@ -81,35 +81,37 @@ local ASC_67_TEXT = [[ ]] local ASC_78_TEXT = [[ - The road has run out - of road. + The situation has reached + + critical levels. - Norman walked back - and forth + Norman is fully aware... - until the street - forgot which way it went. + We need to stop him. - And then - finally - - he stopped walking. + Commence full reset. ]] + local ASC_89_TEXT = [[ Norman you created this simulation - in the first place, + in the first place. + + I know, - because you could never + you don't want to face - cope with reality. + the world you left behind. - - - - You were never + You, yourself, - an impostor. + have forgoten that. + + But + + it doesn't matter anymore. @@ -119,10 +121,9 @@ local ASC_89_TEXT = [[ than you think you are. + + so now - - now - you need to wake up @@ -141,11 +142,16 @@ local ASC_89_TEXT = [[ - you have beed talking to + you really need to stop - yourself + talking to yourself - in your sleep + in your sleep. + + + + + Damnit. ]] local ascension_texts = { @@ -339,10 +345,6 @@ Screen.register({ text_done_timer = text_done_timer - Context.delta_time if text_done_timer <= 0 or (Ascension.get_level() ~= 8 and Input.select()) then MysteriousManScreen.go_to_day_state() - -- to be continued - if 4 <= Ascension.get_level() and not break_mode then - Window.set_current("continued") - end end end elseif state == STATE_DAY then diff --git a/inc/screen/screen.office.lua b/inc/screen/screen.office.lua index 7b6654a..5794557 100644 --- a/inc/screen/screen.office.lua +++ b/inc/screen/screen.office.lua @@ -5,7 +5,7 @@ Screen.register({ "do_work", "go_to_walking_to_home", "have_a_coffee", - "go_to_truth", + "talk_to_truth", }, init = function() Context.have_been_to_office = true @@ -37,7 +37,7 @@ Screen.register({ {x = -4 + 5 * 8, y = 9 * 8} } - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if CommuteGlitch.is_max() then Audio.music_play_mystery() Context.office_sprites = { "norman_echo" } else @@ -49,14 +49,14 @@ Screen.register({ end end, background = function() - return CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 and "" or "office" + return CommuteGlitch.is_max() and "" or "office" end, draw = function() if Window.get_current_id() == "game" then Sprite.draw_at("norman", 13 * 8, 9 * 8) - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then - Sprite.draw_at("norman_echo", 13 * 8, 9 * 8) + if CommuteGlitch.is_max() then + Sprite.draw_at("norman_echo", 15 * 8, 9 * 8) CommuteGlitch.draw_background_flicker() else CommuteGlitch.draw_sprite_list(Context.office_sprites) @@ -65,6 +65,11 @@ Screen.register({ if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 6 then Glitch.draw() end + + if Ascension.get_level() == 8 then + CommuteGlitch.draw_background_flicker() + Glitch.draw() + end end end }) diff --git a/inc/screen/screen.toilet.lua b/inc/screen/screen.toilet.lua index cf399bf..561a456 100644 --- a/inc/screen/screen.toilet.lua +++ b/inc/screen/screen.toilet.lua @@ -93,7 +93,12 @@ Screen.register({ Ascension.draw(asc_x, asc_letter_y, { spacing = asc_spacing }) end - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if Ascension.get_level() == 8 then + CommuteGlitch.draw_background_flicker() + end + + if Ascension.get_level() == 8 then + CommuteGlitch.draw_background_flicker() Glitch.draw() end end, diff --git a/inc/screen/screen.walking_to_home.lua b/inc/screen/screen.walking_to_home.lua index 22f00ab..dd0f121 100644 --- a/inc/screen/screen.walking_to_home.lua +++ b/inc/screen/screen.walking_to_home.lua @@ -29,7 +29,7 @@ Screen.register({ {x = 27 * 8, y = 11 * 8}, } - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if CommuteGlitch.is_max() then Audio.music_play_mystery() Context.walking_to_home_sprites = {} else @@ -41,7 +41,7 @@ Screen.register({ end end, background = function() - return CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 and "" or "street" + return CommuteGlitch.is_max() and "" or "street" end, draw = function() local w = Window.get_current_id() @@ -51,13 +51,12 @@ Screen.register({ local show_sumphore = Ascension.get_level() ~= 8 - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if CommuteGlitch.is_max() then Sprite.draw_at("norman", 7 * 8, 3 * 8) if show_sumphore then Sprite.draw_at("sumphore", 9 * 8, 2 * 8) end CommuteGlitch.draw_sprite_list(Context.walking_to_home_sprites) - CommuteGlitch.draw_background_flicker() Glitch.draw() else local norman_x = Context.fast_food_approaching and (19 * 8) or (7 * 8) @@ -74,5 +73,14 @@ Screen.register({ Glitch.draw() end end + + if CommuteGlitch.is_max() then + CommuteGlitch.draw_background_flicker() + end + + if Ascension.get_level() == 8 then + CommuteGlitch.draw_background_flicker() + Glitch.draw() + end end }) diff --git a/inc/screen/screen.walking_to_office.lua b/inc/screen/screen.walking_to_office.lua index f186ce8..082d056 100644 --- a/inc/screen/screen.walking_to_office.lua +++ b/inc/screen/screen.walking_to_office.lua @@ -28,7 +28,7 @@ Screen.register({ {x = 27 * 8, y = 11 * 8}, } - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then + if CommuteGlitch.is_max() then Audio.music_play_mystery() Context.walking_to_office_sprites = Sprite.list_randomize(possible_sprites, possible_positions) Context.walking_to_office_sprites = CommuteGlitch.corrupt_sprite_list(Context.walking_to_office_sprites) @@ -38,7 +38,7 @@ Screen.register({ end end, background = function() - return CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 and "" or "street" + return CommuteGlitch.is_max() and "" or "street" end, update = function() end, @@ -52,18 +52,12 @@ Screen.register({ Sprite.draw_at("sumphore", 9 * 8, 2 * 8) end - if CommuteGlitch.is_active() and CommuteGlitch.get_level() >= 7 then - Sprite.draw_at("norman_echo", norman_x, 3 * 8) - CommuteGlitch.draw_sprite_list(Context.walking_to_office_sprites) - CommuteGlitch.draw_background_flicker() - Glitch.draw() - else - if Context.fast_food_eaten_today < 3 then - Sprite.draw_at("pizza_vendor", 19 * 8, 1 * 8) - end - Sprite.draw_at("dev_guard", 22 * 8, 3 * 8) - Sprite.draw_list(Context.walking_to_office_sprites) + if Context.fast_food_eaten_today < 3 then + Sprite.draw_at("pizza_vendor", 19 * 8, 1 * 8) end + + Sprite.draw_at("dev_guard", 22 * 8, 3 * 8) + Sprite.draw_list(Context.walking_to_office_sprites) end end }) diff --git a/inc/window/window.credits.lua b/inc/window/window.credits.lua index 174dbd8..d348775 100644 --- a/inc/window/window.credits.lua +++ b/inc/window/window.credits.lua @@ -33,7 +33,7 @@ local RASTER_Y_BOT = 110 local AUTHORS = { "Mr. Zero - Zsolt Tasnadi", - "Mr. One - Balazs Tari", + "Mr. One - Ballz", "Mr. Two - Zoltan Timar", "Mr. Three - Bela Mezo", }