Log In  

I wanted to commit to a git repo without leaving pico 8 so wrote bash script and about 30 tokens to add to the p8 file. Both are here (or at the bottom of the post):


Start pico8 by running the bash script. Then to use. First load your p8 file.

> load your_file.p8
> run all text after will be in the commit message no quotes needed
commit message set

Game runs.
Exit the game.

> save

All p8 files are auto added to repo. This command runs in the terminal

$ git commit -am "commit message set at run"  # Runs when a file is saved

Put in p8 file

-- > run breadcrumb text
-- write stat(6) to file to use
-- as git commit message
-- call in _init()
function add_commit_message()
  -- this saves 1 token
  local msg = stat(6)
  -- check if message entered
  if msg ~= "~~~" 
      and msg ~= "" then
    -- write message to file
    printh(msg, "msg", true)
    -- report success (opt)
    ?"commit message set"
    -- sleep for 30 frames (opt)
    for i=1, 30 do flip() end
    -- reset breadcrumb

Bash script

#! /bin/bash

# Run script to call pico8
~/pico-8/pico8 &
while true; do
    inotifywait -qq -e CLOSE_WRITE ~/.lexaloffle/pico-8/carts/*.p8
    cd ~/.lexaloffle/pico-8/carts
    git add *.p8
    if test -f msg.p8l; then
        git commit -a -F msg.p8l
        rm msg.p8l
        git commit -am "autocommit"
P#105049 2022-01-14 02:12 ( Edited 2022-01-14 02:21)

:: merwok

Interesting idea!

You could even use the -o option or stdout to communicate from pico8 instead of a file (see serial in official docs).

P#105053 2022-01-14 02:49

I didn't even know about serial(). Looks neat!

P#105055 2022-01-14 03:10

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-08-08 06:56:04 | 0.016s | Q:9