Log In  
[back to top]


This code:

x+=x<0 and -100 or 100

doesn't work the way I'd expect; it sets x to either -100 or 100


I assume this happens because that line gets preprocessed to this:

x=x+x<0 and -100 or 100

which gets interpreted like this:

x=(x+x<0) and -100 or 100

but I wish it would be preprocessed to this instead:

x=x+(x<0 and -100 or 100)

Here's a test cart; it currently (0.2.2c) fails the tests:

Cart #zemazebosi-0 | 2021-04-19 | Code ▽ | Embed ▽ | No License
2

2
7 comments



I often see questions in the pico-8 discord's #help channel, questions that boil down to "my code isn't doing what I want, and I don't know what to do. help?" If you feel completely lost when your code doesn't work, this tutorial is for you! Or anyone really -- I personally use PRINTH/PQ constantly and it makes programming about a hundred times easier.

PRINTH ("print to host console") is the single most helpful tool I know for pico-8 debugging. When programming, your head can get out of sync with the computer, and you won't understand what it's doing. The best way I know to bring them back in sync is to slap down some PRINTHs all over the place! Print out some info to see what your code is actually doing, and figure out exactly where the code starts to stray from what you intended.

setup

Here's a video showing how to launch pico-8 with an attached console on Windows. You'll need to do this somehow, because PRINTH messages are only visible in the attached console.

[ Continue Reading.. ]

28
8 comments



There's a strange issue happening when i try to edit the bottom two visible rows of the map using the new "fullscreen" map editor mode (shift+tab). Basically, the bottom two rows are uneditable; I assume pico8 is mistakenly trying to prevent me from editing the area underneath the red chrome that shows up in nonfullscreen mode

It seems to fix itself if you pan around in the normal map editor?

1
0 comments



Cart #fitahinigu-3 | 2021-02-23 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

There's something weird going on here; using ..= along with a single-line if-then-end statement causes a syntax error that makes no sense:

syntax error line 16 (tab 0)
if x<2 then bad..="1" end
')' expected near 'end'

I've included 4 similar test cases that don't trigger this bug

My pico-8 version is 0.2.2 (stat(5)==30)

2 comments



Cart #remains-0 | 2021-02-19 | Code ▽ | Embed ▽ | No License
3

a short little game with a big heart

controls:

  • arrow keys: move
3
3 comments



Cart #typefight-1 | 2021-02-19 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

a standard normal typing game

controls:

  • a: a
  • arrow keys: move/menu select/etc
  • b: b
  • backspace
  • c: c
  • d: d
  • dash: -
  • e: e
  • enter: confirm/begin/etc
  • f: f
  • g: g
  • h: h
  • i: i
  • j: j
  • k: k
  • l: l
  • m: m
  • n: n
  • o: o
  • p: p
  • q: q
  • r: r
  • s: s
  • space:
  • t: t
  • u: u
  • v: v
  • w: w
  • x: x
  • y: y
  • z: z
3
9 comments



A question came up yesterday in the pico-8 discord: are there any nice ways of doing default arguments? For example,

function foo(a,b,c)
  a=a or default_for_a
  b=b or default_for_b
  c=c or default_for_c
  -- do stuff
end

That's five tokens spent per argument; can we do better?

yes

My first thought was doing something like this:

function new_actor(fields)
 return merge(parse"x=64,y=64,w=8,h=8",fields)
end

This is a common pattern I use in my games; merge(A,B) is a custom thing I have that merges tables A and B together by creating a new table, copying all of A's contents into it, and then copying all of B's contents into it. Note that if A and B share any keys, the value from table B will be used for the result, which makes this handy for setting defaults in a table. (and parse is another custom thing that does what you'd expect, turning a string into a table)

However, this wasn't quite what the questioner was asking for; I can set default values for table members with this method, but I can't set local variables. This method wouldn't work to save tokens if you had to say locals.myvar throughout your function instead of just myvar!

[ Continue Reading.. ]

2
1 comment



Who's the biggest fish?

Cart #fishy-0 | 2020-11-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

Controls:

  • arrow keys: move
  • x: restart

This was my entry to TweetTweetJam 5; check it out on the jam page here if you like. Also, I wrote a short blog post about it here!

And clearly, a tweetcart needs to be tweeted: here it is

3
0 comments



you've received a mysterious invitation to a party. but it's not just any party...

it's the 💀monster mash💀

better find somebody to go with!

Cart #monstermash-1 | 2020-10-30 | Code ▽ | Embed ▽ | No License
17

Controls:

  • arrow keys to move
  • x to interact
  • z to jump

(made by @princryss and me! she did the design + art + sound, I did the programming)

17
7 comments



Cart #escalatorworld-0 | 2020-08-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

Welcome to Escalator World! You can only go up from here!

Controls:

  • up/down/X to menu. (the rest is explained in the tutorial)

A tribute to one of my favorite games from the old yoyogames forums.

non-keyboard users: press up 10 times to skip the name entry screen. (when it says "use the keyboard" just keep pressing up; you're halfway done)

7
4 comments



Cart #woruyudutu-0 | 2020-08-28 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

I think I've found a bug with how music and sfx channels are used; I've attached a cartridge that shows off the issue. Basically, if you call sfx() and then call music() afterward, the music won't be heard until the sfx() finishes, even though there are 3 available unused sound channels for the music to play on.

Am I misunderstanding how this is supposed to work? it seems like the music() command should figure out that it has 3 free channel slots to play in... I do see the channelmask parameter (https://pico-8.fandom.com/wiki/Music) but calling music(4,0,0b1111) instead of music(4) doesn't fix the issue. Even if it did, sometimes you want to start playing music after sound is already playing, so how are you supposed to set up in advance which channels the music has priority to play on?

[ Continue Reading.. ]

2 comments



When I press shift+9 in the music editor (but not the sound editor) on any pattern EXCEPT for pattern 0, pico8 crashes.

My OS is windows 7, and my pico8 version is 29, as shown by print(stat(5))


edit: this bug still exists in pico8 0.2.4

3
4 comments



I wish I knew exactly how to reproduce this; it doesn't happen all the time. But decently often (~4 times in the last ~40 hours of runtime? idk just a ballpark guess) when I open a new tab in the code editor and press ctrl+v to paste in code, pico8.exe immediately exits.

The last 3 or 4 times this has happened, I've relaunched pico8.exe and tried to do exactly the same keypresses etc (ctrl+a to copy all text from one tab, ctrl+t out of muscle memory to create a new tab (does not work in pico8), mouse click to create a new tab for real, ctrl+v to paste code), and it works the second time without crashing. Maybe it only happens when the console has been on for long enough? (>4 hours, generally). Maybe I'm not reproducing my steps exactly? idk

My pico8 version is 29, as shown by print(stat(5))

My OS is windows 7

(Is there some sort of crash logs folder or anything like that that I should attach to this post?)

3
4 comments



This cartridge fails the assertion, which normally I would write off as a floating point bug, but pico-8 uses fixed point representation so this seems like an actual bug in pico-8 to me?

function _init()
 local x=0.6
 local y=0.3
 local sum=x+y
 assert_equal(sum,0.9)
end

function assert_equal(a,b)
 local s=a.." ("..tostr(a,true)..") does not equal "..b.." ("..tostr(b,true)..")"
 printh(s,"@clip")
 assert(a==b,s)
end

function _draw()
 cls(3)
end

The assertion fails, saying:
0.9 (0x0000.e665) does not equal 0.9 (0x0000.e666)

This is just one example, but this happens to me more often than not when trying to compare decimal numbers :(

2 comments



I'm having problems with the del function; its behavior doesn't seem to match what the documentation says it should do. From the docs: (pico-8.txt)

del  t [v]

    Delete the first instance of value v in table t
    [...]
    When v is not given, the last element in the table is removed.
    del returns the deleted item, or returns no value when nothing was deleted.

So, calling del(arr) should be equivalent to calling deli(arr,#arr), right? Both should pop the last element off of arr as far as I understand. But when you run the cartridge attached to this post, the O button works but the X button doesn't

3
9 comments