Log In  

I extracted all the public names of functions and tables that are visible to Picotron, it might be useful to explore everything that is available
printh doesn't seems to work like in Pico 8 so I couldn't easily make it into a text format, so here is just a screenshot of all the globals functions (in white), tables (in dark blue) and others (in red):

And I also got the functions inside all the tables:

P#143148 2024-03-15 16:40 ( Edited 2024-03-15 16:41)

Awesome thanks!

P#143155 2024-03-15 16:53
1

Nice, thank you! Is there an official (or unofficial) Picotron reference doc yet?

P#143157 2024-03-15 16:55
2

I don't think there is a user manual yet, which is a shame because I can't figure out how to display all the layers of a map...
You can find some info in the links inside the faq
most notably the gfx pipeline

P#143162 2024-03-15 17:18
1

Equivalent of sget from Pico-8:

get_spr(sprite):get(x,y)

Still looking for an mget equivalent though O.o

P#143191 2024-03-15 19:48 ( Edited 2024-03-15 19:49)
1

is it possible to find out what args each API function accepts?

P#143192 2024-03-15 19:53

@NuSan There is readme.txt on the Picotron desktop, but that's more of a quick start guide than an actual manual. Still, it's as close as you're gonna get for now, and is pretty handy for getting to know the new UI.

@beepyeah As far as I can tell: no, sadly. Some of the global functions are described in the .lua files within the /system/ directory, but most others aren't. For most of them, you can get by on prior PICO-8 knowledge, the aforementioned readme.txt, some of the demos or other pre-installed programs, the html docs released in the days leading up to the launch of Picotron, and even just some simple intuition/trial-and-error. But, even with all that, there are still some mysteries, like clear_key, peektext, and wrangle_working_file to name a few.

P#143195 2024-03-15 20:50
11

I also made an api explorer; the sorting isn't as nice but it will always be up to date: https://gist.github.com/pancelor/0489fc0671cc566db24ee737af4f94c3

P#143203 2024-03-15 21:44 ( Edited 2024-03-15 22:34)
2

RE: Nusans and my own concerns regarding missing map functionality

Polyfill for:

  • Missing mget - implemented as mget(x,y,map_layer)
  • Replace flag based map layer drawing with Picotron map layers
  • Add support to map() for (hidden) tile_w and tile_h properties for maps with tiles that aren't 16x16

The replacement for map() is quite slow as I'm not sure how to read the camera x,y. So remove it if you don't need the functionality described above.

function polyfill_map()
    --A super nasty and slow polyfill to add missing map functionality

    local map_data=fetch("map/0.map")

    --This map function removes the flag-based layer drawing, and allows 
    --you to draw the chosen layer instead. Additionally this function
    --respects the tile_w and tile_h from the map data.
    map=function(cel_x, cel_y, sx, sy, cel_w, cel_h, layer)
        layer=layer or 0
        flags=flags or 0

        assert(layer<#map_data,"Map layer does not exist")
        local map_layer=map_data[layer+1]
        local tile_w=map_layer.tile_w
        local tile_h=map_layer.tile_h

        --This could do with a check if its in frame, 
        --but we need the camera x,y for that and I'm not
        --sure where it is in memory.
        local min_y=0
        local min_x=0
        local max_y=cel_w-1
        local max_x=cel_h-1

        for y=min_y,max_y do
            for x=min_x,max_x do
                local dx = sx + x * tile_w
                local dy = sx + y * tile_h
                local val=get(map_layer.bmp,x,y)
                local sprite=get_spr(val)
                spr(sprite,dx, dy)
            end
        end    
    end

    --Same as Pico-8, but lets you specify the layer.
    mget=function(x,y,layer)
        layer=layer or 0
        assert(layer<#map_data,"Map layer does not exist")
        local map_layer=map_data[layer+1]
        return map_layer.bmp:get(x,y)
    end
end

polyfill_map()
P#143207 2024-03-15 22:06 ( Edited 2024-03-15 22:22)

Thanks, this is a huge help!

So it looks like there's no equivalent to mset() yet? That puts a damper on porting my roguelike project over.

P#143230 2024-03-16 00:49
1

I added mset to @Oli414 's code:

-- https://www.lexaloffle.com/bbs/?pid=143207#p
-- by Oli414, pancelor
function polyfill_map(src)
    --polyfill to add missing map functionality.
    --there's likely a better way to think about picotron maps,
    --  but we don't have docs yet so this makes map/mset/mget
    --  behave in a familiar way, similar to pico8

    local map_data=fetch(src)

    --This acts like pico8's map(), but it ignores flag-based layer drawing.
    --It draws all layers; for single layers, call map_layer() directly
    --Additionally, this function respects the map data's tile_w and tile_h
    map=function(...)
        for i=1,#map_data do
            map_layer(i,...)
        end
    end

    --Draw a single map layer (1-indexed)
    map_layer=function(layer, cel_x,cel_y, sx,sy, cel_w,cel_h)
        cel_x = cel_x or 0
        cel_y = cel_y or 0
        sx=sx or 0
        sy=sy or 0
        cel_w = cel_w or 16
        cel_h = cel_h or 16

        local map_layer=map_data[layer]
        assert(map_layer,"Map layer does not exist: "..layer)
        local tile_w=map_layer.tile_w
        local tile_h=map_layer.tile_h
        local bmp=map_layer.bmp

        --This could do with a check if its in frame, 
        --but we need the camera x,y for that and I'm not
        --sure where it is in memory.
        local cx0=cel_x
        local cy0=cel_y
        local cx1=cx0+cel_w-1
        local cy1=cy0+cel_h-1
        for cy=cy0,cy1 do
            for cx=cx0,cx1 do
                        local val=bmp:get(cx,cy)
                local sprite=get_spr(val)
                spr(sprite, sx + cx*tile_w, sx + cy*tile_h)
            end
        end
    end

    --Same as Pico-8, but you can optionally specify the layer.
    mget=function(x,y, layer)
        layer=layer or 1
        local map_layer=map_data[layer]
        assert(map_layer,"Map layer does not exist: "..layer)
        return map_layer.bmp:get(x,y)
    end
    mset=function(x,y,val, layer)
        layer=layer or 1
        local map_layer=map_data[layer]
        assert(map_layer,"Map layer does not exist: "..layer)
        return map_layer.bmp:set(x,y,val)
    end
end

polyfill_map("map/0.map")

(It's actually a bit faster than map! I wish we had docs so we knew how/what map was doing. maybe it's handling flipped tiles or something. there's some code in /system/lib/head.lua:894 but it doesn't do much besides calling out to a C(?) function)

P#143245 2024-03-16 04:03 ( Edited 2024-03-16 04:07)
3

I can only imagine how weird this must be for zep, seeing us frantically scrabble together docs when he's probably like, "I have them nearly done, okay, just give me a few days" :D

P#143248 2024-03-16 04:29
1

(And also massive thanks @pancelor ) :D

P#143249 2024-03-16 04:29

nice @pancelor it's cool to have a cart to browse all the functions!
I managed to get map working with tline3d for some rotations
but I'm running into crashes and my files ends up corrupted, and I can't load them into picotron anymore, the only solution I found is to use a text editor to manually copy the code/gfx/map part into a new cartridge

function rot(x,y,a)
    x,y=x-offx,y-offy
    local ca=cos(a)
    local sa=sin(a)
    return ca*x+sa*y+offx,-sa*x+ca*y+offy
end

m1 = fetch("/ram/cart/map/0.map")

function _draw()
    cls(1)

    offx,offy=480/32,270/32
    local a=time()*.01
    for i=1,#m1 do
        --map(m1[i].bmp,0,0,0,32,32)
        for y=0,270 do
            local px1,py1=rot(0,y/16,a)
            local px2,py2=rot(480/16,y/16,a)
            tline3d(m1[i].bmp,0,y,480,y,px1,py1,px2,py2)
        end
    end
end
P#143270 2024-03-16 07:24
3

Great work @NuSan 👍

@kozm0naut Not seen an official manual (yet), but guess Zep will get to that (+changelog) when he gets time.

Either way, think I'll get started on a Picotron Cheat Sheet soon 😅
(would rather the official manual/reference to be available beforehand - if possible)

P#143272 2024-03-16 08:25
5

@Liquidream It'd be awesome to have a cheat sheet in the draggable tooltray

P#143417 2024-03-17 00:58

A command line tool for searching these would be great. I might try to do it, although adding individual manuals (like the program "tldr") would take some time.

P#143420 2024-03-17 01:08

@Zeflyn: Was thinking the same thing ("great minds" and all that!) 😁

Depends whether I can make it work well at Picotron's native resolution. @NuSan's API list above is a great example of what's possible. Will see how it goes... 🤓

P#143457 2024-03-17 07:43
2

it's all begining in #picotron. I got feeling someone will make a cheat sheet for #picotron soon.

P#143527 2024-03-17 15:49 ( Edited 2024-03-17 15:51)
3

Really looking forward to a Picotron cheat sheet. That pico-8 one was a godsend.

P#143969 2024-03-20 19:02

[Please log in to post a comment]