so today i made this
use it as you want guys
also maybe it's not token-efficient but
i'll leave it up to you
function randprob_from(l) --the function expects an --array of tables like these: --{p=0.5,v='item name'} --a "p" value between 0 and 1 --and a "v" value. --"p" is propability of the --"v" value being returned local lim=1 local value=rnd() for pos in all(l) do highlimit=lim lim-=pos.p lowlimit=lim if value<highlimit and value>=lowlimit then return pos.v end end end |
Demake of Rogue Legacy 1, work in progress.
Posted here to show my friends.
Yep. That's it.
Hello! I've made a cart on my console and it runs there. But when I upload it onto BBS, it gives a syntax error.
Error:
syntax error line 5 (tab 1)
-return fget(mget(x/8,y/8),f)
<eof> expected near 'end'
Function:
function gfap(x,y,f)
-return fget(mget(x/8,y/8),f)
end
i've marked indent spaces as '-'
Pico-8 version i made the game at: 0.2.5c
This tool allows you to map lines on a plane and export them into any of your carts.
Each line is represented as a table with values x1,y1,x2,y2.
This is useful for raycast projects or whatever you need to map lines for.
Buttons (left-up corner of the screen, top to bottom):
Temp save: temporarily saves all line data to adresses 0x4300-0x5dff in console memory.
Load: loads data at adresses 0x4300-0x5dff. Can be used as reserve copy.
Toggle ruler: Each line displays it's length to the right of it's 2nd point.
Export: allows you to type in your desired cart's name and export line data to it's addresses 0x4300-0x5dff. This overwrites your cartridge file so make sure you don't have anything valuable in there (sprites, map, sounds and, obviously, code are safe).
Modes: (down side of the screen, left to right):
Click: right-click to select the line and distplay it's info, left-click to deselect.
Pan: left-click drag across the plane to view different parts of it.
Draw: left-click and drag to create a new line at your pointer position.
Delete: left-click near the line to delete it. Lines that will be affected are highlighted red.
Memory:
Each line takes 8 bytes of space (2 bytes per 16-bit variable, 4 variables).
All memory in the aforementioed range is cleared before writing line data.
How to read line data back:
In your original cartridge, you can do something like this:
lines={} for i=0x4300,0x5dff,8 do local x1=peek2(i) local y1=peek2(i+2) local x2=peek2(i+4) local y2=peek2(i+6) local line={x1=x1,y1=y1,x2=x2,y2=y2} add(lines,line) end |
How do you deal with range overflow? The numbers beyond 32767 warp to -32766 in pico8's 16 bit signed system when calculating. This is sometimes enough, but not always. For example,
function distance(x1,y1,x2,y2) return sqrt((x2-x1)^2+(y2-y1)^2) end |
will sometimes (very often actually) return 0 as a result of taking sqrt of the negative wrapped number. This is occasionally crutial. Is there a workaround to compute this as if this was an unsigned system?
So i watched lazy devs' youtube shorts about how he makes his shmup levels. In there he mentioned that he has different pico8 cartridges that work as tools for editing stuff like sprites, bullet patterns and level scenery. I coded a 2d space line editor that can be used for raycasting. How can i transfer all lines data to an another cartridge for use? There is a big "lines" table that containes tables with individual line data. I know that you can't transfer actual code or tables between carts so lazy devs should have used something different.
as a minesweeper i can confirm that this is, indeed, minesweeper.
Hello everyone. Is there a way to write and read values to specific bits in a byte?
For example:
I have a variable 0x0000 .
I want to write a 1 to the 3rd bit so it'll be
0x0100 . How can i do that?
I want to later read that variable. How do I
check the value of the 3st bit? I haven't operated
with bits & bytes before.