Log In  

BBS > Community Superblog
All | Following | GIFs | Off-site

If you feel like you don't understand Lua's tables, I hope this post helps. I use tables all the time when I'm programming; they are super useful. Let's study them so you can use them too!

Tables can do several different things, which makes them a bit tricky. We'll start by exploring a common use: using tables to store a list of things, such as:

  • A hand of cards: 2♠, 3♥, Q♦, K♣, J♣
  • A list of monsters: Ogre, goblin, slime mold
  • The positions of all the black checkers: 12, 24, 20, 27

Making lists

This makes an empty list:

items={}

This makes a list with the names of some things found in a forest:

items={'tree', 'rock', 'stream'}

Now items contains 3 things; you can think of it like 3 boxes:

The first box contains 'tree', the second contains 'rock', the third contains 'stream'.

Getting items out of a list

Each box has a number, called its "index". To get the value from the first box, we do items[1] like this:

[ Continue Reading.. ]

7
8 comments


Cart #jumpals-0 | 2023-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7


Little Cherry and the Dandelion Twins are getting ready to jump some rope.

Press the Up key to Jump. You earn points every time you successfully jump.

Made using only 1019 characters

n=rnd
function q()k=255cls()g=cos?"jUMpals"
l={}for i=0,k do add(l,{i=i,c=pget(i%35,i\35)})end
d='Dひ:k2Dnu:k<C3C392C3C392u2u2CGC2CQ9<a<CGC2lFa<l<l<l2v<l2v<:P:2:ZD't=0for i=1,64do b=ord(d,i,i)-40for q=1,b\10do sset(t%16,t\16,b%10)t+=1end end
z=0t=3.25d=8h=0v=0j=0y=0c={}for i=0,32do add(c,{x=n(128),y=n(9)})end
end q()m=circfill::b::flip()cls(12)
for o in all(c) do
if(o.x<-8-o.y)o.x=150o.y=n(9)
o.x-=.7m(o.x,50+o.y*g(o.x/k+.25)*3,8+o.y,7)end
m(64,230,150,3)for i=0,8 do
m(37+i*7,38,18+g((i+t)/d)*2,14)end
for i in all(l) do
if(i.c>0)m(26+i.i%35*3,32+i.i\35*3,2,7)r=btn
end
pal(8,9)spr(0,24,82,1,2)spr(0,97,82,1,2,true)pal(8,8)spr(v,60,82-y,1,2)for i=0,128do
pset(64+32*g(i/k),87+12*sin(i/k)*sin(t/d),5)end
if(g(t/d)<0)spr(v,60,82-y,1,2)
if(r(2)and y<1)z=.15h+=1?"\aedc"
if(r(2)and j<1)y+=2.2v=1
if(y>15)j=1
if(y>0and not r(2))j=1
if(j>0and y>=0)y-=2.2
if(y<1)y=0j=0v=0
if(t>d)t=0d=8-n(h%5)+n(h\25)%5
if(z>0and y<1and t/d>.4 and t/d<.45)h=0q()?"\a"
if(z>0)t=z+t?h,64-#(""..h)*2,108,7
if(z<.1)?"up to jump",44,70,7
goto b
7
3 comments


The Fastest Flinger in the West

Cart #flinger_200-0 | 2023-09-27 | Code ▽ | Embed ▽ | No License
4


I'm making a new thread, since we're now doing a full release!

FROM: The US Office of Sheriffs
TO: OFFICER JEFF, Placeholder City, Texas
---
Congratulations on your new role!

As a new member of the US Sheriff Association, it is your duty to protect the people of whatever city you may decide to live in.

Under normal circumstances, a sheriff would have a revolver, or something of the likes to protect themselves, and to aid in the catching of outlaws. Sadly, due to budget cuts, all we can afford is a piece of string, and some rocks.

We urge you to minimize the amount of rocks you spend, as we cannot afford for you to let them go to waste.

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=134984#p)
4
0 comments


Cart #nawiseseyo-1 | 2023-09-27 | Code ▽ | Embed ▽ | No License


Why is my code not drawing the tiles I want where they should?

Am i not understanding smth with classes?

2 comments


Cart #coin_game-0 | 2023-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

I literally made this in 45 min. Wanna try the 45 minjam yourself. Just put a timer for 45 minutes and do a game.

2
0 comments


Cart #testing001-0 | 2023-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

0 comments


Puzzle Duck

Cart #puzzle_duck-0 | 2023-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
16

A simple Puzzle Bobble / Bust-a-Move - Clone.

from URL Wikipedia:
Puzzle Bobble,[b] internationally known as Bust-A-Move, is a 1994 tile-matching puzzle arcade game developed and published by Taito.

At the start of each round, the rectangular playing arena contains a prearranged pattern of colored "bubbles". At the bottom of the screen, the player controls a device called a "pointer", which aims and fires bubbles up the screen. The color of bubbles fired is randomly generated and chosen from the colors of bubbles still left on the screen.

[ Continue Reading.. ]

16
2 comments


according to the manual:

 A += 2   -- EQUIVALENT TO: A = A + 2

// note that the LHS appears twice, so for TBL[FN()]+=1, FN() will be called twice.

ok, let's test it:

 function fn()
   print("in function")
   return 1
 end

 f={ 10 }
 print("f[1] is "..f[1]) 
 f[fn()]+=1
 print("f[1] is "..f[1])

the function fn is only called once!

1
1 comment


Cart #wizardduel-0 | 2023-09-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8

Duel 9 different wizards in this simple pico-8 game!

Controls

Up/Down to select your spell
X to use your spell
X to move from one screen to another

Rules

Select from the following spell's and cast it against your enemy
Fireball - 2 damage, blocked by shield
AcidBall - 1 damage, penetrates shield
Lightning - 3 damage, reflected by shield
Shield - Blocks and reflects damage
Heal - Restores 2 health

Defeat your enemy by doing 6 damage before they do!
Most enemies follow patterns! Learn them to defeat them!

Behind the Scenes

[ Continue Reading.. ]

8
4 comments


Currently, there are two ways to access pico8 memory: peek/poke[2/4] and @/%/$

The @/%/$ operators look a bit weird but are faster and better overall.
However, I think their main drawback is that they don't replace the need for poke, causing code that uses them to necessarily be quite inconsistent, imbalanced and weird whenever it needs to combine peeks with pokes.

I wanted to check how hard it would be to add the ability to poke into @/%/$, so I created the following fork of z8lua that implements it:
https://github.com/thisismypassport/z8lua

Here's how it works:


-- simple poke
@0x1000 = 0x1

?@0x1000 -- outputs 1

-- use of $ as both peek and poke (copying 4 bytes of memory)
$0x8000 = $0

-- multiple assignment
@1,%2,$4 = 1,2,4

?@1 -- outputs 1
?%2 -- outputs 2
?$4 -- outputs 4

-- compound assignment - worked automatically
@1 += 0x80

?@1 -- outputs 129 (since previously was 1)

-- poke metatables
meta = setmetatable({}, {

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=134944#p)
4
1 comment


Press / hold Z or X to pop bubbles. Use arrow keys to configure speed/multipop.

Cart #zatejomotu-2 | 2023-09-28 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

Changelog:
9/28/23 - added speed/multipop configurations

7
1 comment




Cart #pizza_panda-1 | 2023-10-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
153

Straight out of the Bamboo Forest!

Meet PIZZA PANDA, a fluffy little fast-driving bear, as he beeps, bounces, and barrels his way through 20+ levels in search of the lost pizza slices. He'll have to zigzag through city streets to beat the clock, delivering the freshly reconstructed pizzas straight into the mouths of hungry citizens.

But that's not all! Puzzling hats, helpless rats, and meddlesome cats also await PIZZA PANDA and his trusty red automobile. It's non-stop action all the way to the top of the winner's podium!

Controls

  • Jump: 🅾️
  • Honk/Start Level: ❎
  • Move Left/Right: ⬅️/➡️

(open the pause menu to restart a level or return to the overworld)

[ Continue Reading.. ]

153
33 comments


Cart #hoverbikes-11 | 2023-09-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
28

Level 3: Hoverbikes

This endless runner (endless driver?, endless hoverer?) game is my tribute to the infamous turbo tunnel level in the classic game Battletoads. I actually made a very similar game about a decade ago, but a friend of mine showed me the PICO-8 engine and challenged me to recreate the game in it, so here it is!

Controls

  • Hold UP or DOWN to move to the top or bottom lanes, and release these buttons to return to the center lane.
  • Press X / [x] to jump. (Also to select items in the menu)
  • Press O /[z] to return to the menu when prompted, or to advance through the How To Play tutorial.

Credits

Level 3: Hoverbikes

Inspired by battletoads by Rare

[ Continue Reading.. ]

28
5 comments


Cart #flappy_1k-0 | 2023-09-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

1k Jam Entry 2023

Flappy bird 1K

This Game was made for the 1K Jam 2023, it was really fun to to compress and write the code.

You probably dont need any explanation on how to play flappy bird but here they are:

  • jump with X
  • toggle menu with C
  • you wont die when falling out, instead you will just fall from the top

post you highscore in the comments :)

9
5 comments


So, I recently built myself a physical PICO-8 console that hangs on the wall. It switches to a screensaver mode when it's not in use, and switches to splore to play games when someone connects a joystick:
(ignore the flickering, that's just the refresh rate)

I had the idea to periodically display a weather dashboard in between the different screensaver carts it cycles through when it's not being used. So, I went searching the BBS for options, only to find none exist. When I began exploring why, I quickly learned that interacting with APIs is impossible directly, and that I would need to feed PICO-8 the weather data at runtime. For my purposes, that's actually not a problem at all, since I can set up a cron job to refresh the data in a text file, and then just feed the updated file into the cart each time it runs.

The problem really is, I'm not a lua dev. I know this about myself. I'm not good at it, and I'm not patient enough to become good at it. The moment I encounter the need for an array, my brain fuzzes over and I move on. So, I'd love to collaborate! I have the basic building blocks of what I have in mind ready to go. I have example code to work from to get data from text file into the cart. I have the weather data API and sample calls I can make. I also have an example of the dashboard visuals I'm aiming for: https://github.com/lmarzen/esp32-weather-epd

[ Continue Reading.. ]

2
11 comments


Cart #rpsbattle-0 | 2023-09-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

A rather astonishing simulation...

9
3 comments


I bought a floppy disk reader on a marketplace to make my own pico-8 console, I wanted to know how I can start making the console along with the step-by-step guide on how to do it? Does anyone have an idea

2 comments


Cart #bajetosuba-0 | 2023-09-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

0 comments


Hello,
I adapted the famous Commodore 64 BASIC one-liner "10 PRINT CHR$(205.5+RND(1)); : GOTO 10" to the PICO-8 as a first learning experience. There are code snippets as comment available that you can copy to the prompt in interactive mode or run the program as you would normally and change the pattern in the pause menu. There is also a short blog entry available at my website, where I provide a link to the website hosting a free PDF version of an interesting book published by Nick Montfort et al. about this originally single line of code.
Have fun!
Michael

Cart #pico8_10print-0 | 2023-09-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

3
4 comments




Top    Load More Posts ->