Last active
December 10, 2025 08:51
-
-
Save shanecelis/536d8a4cc6ebbad15105659898f80dfd to your computer and use it in GitHub Desktop.
Run an Ink story from Nano-9, a Pico-8 compatibility layer for Bevy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| story = ink_load("hello.ink.json") | |
| -- Are we waiting for a choice? | |
| waiting = false | |
| -- Here are the y positions of the choice? | |
| choices_y = {} | |
| -- Here is our current choice. | |
| choice_index = 1 | |
| function _update() | |
| if not waiting then | |
| while story:can_continue() do | |
| local line = story:cont() | |
| print(line) | |
| end | |
| local choices = story:get_current_choices() | |
| if #choices == 0 then | |
| -- The story is done. | |
| print("fin") | |
| -- Remove the _update function. Game will stop. | |
| _update = nil | |
| return | |
| end | |
| choices_y = {} | |
| choice_index = 1 | |
| for choice in all(choices) do | |
| add(choices_y, peek(0x5f27)) -- Record the y position of the line we're on. | |
| print(" "..choice) | |
| end | |
| -- Create a cursor that we can move around. | |
| choice_spr = spr(0, 0, choices_y[choice_index]) | |
| waiting = true | |
| else | |
| if btnp(2) then | |
| choice_index = choice_index + 1 | |
| end | |
| if btnp(3) then | |
| choice_index = choice_index - 1 | |
| end | |
| if choice_index <= 0 then | |
| choice_index = #choices_y | |
| end | |
| if choice_index > #choices_y then | |
| choice_index = 1 | |
| end | |
| choice_spr:pos(0, choices_y[choice_index]) | |
| if btnp(4) or btnp(5) then | |
| story:choose_choice_index(choice_index - 1) | |
| waiting = false; | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment