Questions tagged [pico-8]

Pico-8 is a virtual machine and fantasy console for making, sharing and playing tiny games. Users create "cartridges" through a Lua-based environment.

Here is the Pico-8 homepage: https://www.lexaloffle.com/pico-8.php

27 questions
3
votes
1 answer

Pico-8 coroutines are occasionally dead

I was trying to replace a for-loop with coroutines to move the stars: --fine function _update() for c in all(boids) do move_boid(c) end end --broken function _update() for c in all(boids) do coresume(cocreate(move_boid),c) end end Notice…
knh190
  • 2,744
  • 1
  • 16
  • 30
3
votes
1 answer

Deserialization of simple Lua table stored as string

I'm transfering a lua table literal in a string from a web application in to PICO-8 that I'm trying to deserialize back in to a lua table in PICO-8. The string is in the form '{"top", {"one", {"one a", "one b"}}, {"two", {"two a", "two b"}}}' To try…
K Groll
  • 518
  • 2
  • 8
  • 18
2
votes
1 answer

Getting error "Attempted to index global 'table' (A nil value)" Lua

When I run this code snippet in Lua (using PICO-8 if it helps) a = {} table.insert(a,1,'foo') I get the error Attempted to index global "table" (a nil value) According to the Lua website, this should work (https://www.lua.org/pil/19.2.html). What…
2
votes
0 answers

Buildroot for pico-8 on raspberry pi0w keyboard input issue

I have been tinkering around with buildroot to try to put together an image with wifi and ssh support and is able to run Pico-8. I'm really close and have everything running successfully, but Pico-8 is not accepting keyboard inputs. I'm sure it's…
itsonlym3
  • 21
  • 2
2
votes
1 answer

Lua)) how to loop table of table and get a specific property?

I am really newbie in lua. I have this lua code local gun_info = { g_sword={rate=0.5;spd=0;dmg=1;ammo=1;}; g_pistol={rate=0.5;spd=5;dmg=1;ammo=40;}; g_knife={rate=0.8;spd=5;dmg=1;ammo=1;}; g_shuriken={rate=0.3;spd=5;dmg=1;ammo=40;}; …
javaprogrammer
  • 105
  • 1
  • 2
  • 11
2
votes
1 answer

Modifying a Linked List With a Function in Lua

My question is regarding the below code snippet: function add_node(list, v) list={next=list, val=v} end function print_linked_list(list) local l=list while l do print(l.val) l=l.next end end root=nil root={next=root, val=0} add_node(root,…
Colin
  • 23
  • 4
2
votes
1 answer

IF ELSE IF END gives Unclosed Function error

I am looking at PICO-8 for the first time. This simple IF statement give me the error "UNCLOSED FUNCTION AT LINE 1". function MYTEST() local x = 1 if x==1 then print("x==1") else if x==0 then print("x==0") end end I admit the…
Rob O'Doherty
  • 549
  • 3
  • 14
1
vote
2 answers

pico8 lua: unexpeted change of size of an array

I am seeing some unexpected behaviour when using a table as an array in pico8 lua when compared to regular PUC-Rio lua If I run the following code using PUC-Rio lua5.4.4 (ubuntu) local t={} for i=1,10 do t[i] = i*10…
Oliver Schönrock
  • 1,038
  • 6
  • 11
1
vote
1 answer

How can I fix this lua runtime error in pico-8?

I'm following your roguelike tutorial and have encountered a problem I do not know how to solve. This is my first-time coding with Lua If r.nospawn then return 0 --Attempt to index local "R" (a nil value) I asked the PICO-8 discord server, they…
user16475220
1
vote
1 answer

How to make score count go up by 1, everytime pset and sprite collide

So i'm new to programming and is currently trying out coding in pico-8. I made the start to a game where the sprite is supposed to fall down from the top, and when colliding with my pset (point), i would like my score count to go up by 1. As of now…
Trylle
  • 13
  • 2
1
vote
1 answer

Fields and methods of metatable are not visible on table right after setmetatable

This is Pico-8 lua. I have the following function, which fails at the marked assert. I do not understand how this can happen. I have used setmetatable on two other occasions and it is working there. I have no clue here. function particle:new(o) …
ziggystar
  • 28,410
  • 9
  • 72
  • 124
1
vote
1 answer

PICO8 - strange way to record HEX number

I am trying to understand how specific script (fade function) works in PICO8: function fade() fadep=split("0xffff.8,0xfffe.8,0xffec.8,0xfec8.8,0xec80.8,0xc800.8,0x8000.8,0x0.8") for i=0,64 do fillp(fadep[flr(i/(32/#fadep))+1]) …
wotesi
  • 319
  • 1
  • 3
  • 15
1
vote
1 answer

Wrong variable update in PICO-8

I was building a simple snake game from scratch as practice for PICO-8 and Lua. I'm attempting to have the body follow the head by creating a copy of the old body locations and update along the length. I created a t_old variable to store the…
1
vote
1 answer

PICO-8 Export Command in a GitHub CI/CD Pipeline

I'm working a small PICO-8 game that I am embedding into my website. There's an export command I use to create the game files for the web player, but I can only run this command locally in the PICO-8 application. Is there any support to run this…
greg
  • 1,118
  • 1
  • 20
  • 40
1
vote
1 answer

PICO-8 making a button press show an output of text only once?

I'm a complete newbie to both Lua, PICO-8, and coding in general. I'm having trouble with a function I want to put in my first program. The text is all placeholder, I will change it once I get the code right and comprehend it. Basically, before the…
B. Hoyt
  • 15
  • 6
1
2