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:

36


Awesome thanks!


3

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


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


1

Equivalent of sget from Pico-8:

get_spr(sprite):get(x,y)

Still looking for an mget equivalent though O.o


1

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


@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.


12

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


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()

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.


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)


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


1

(And also massive thanks @pancelor ) :D


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

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)


5

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


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.


@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... 🤓


2

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


5

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



[Please log in to post a comment]