Log In  

How do I communicate between 2 or more PICO-8 instances on the desktop? Maybe you could make virtual GPIO pins that communicate with other PICO-8 instances on the host OS? What do you think, @zep?

P#63259 2019-04-05 12:50 ( Edited 2019-04-05 12:56)

At the same time?

P#63392 2019-04-10 19:17

Yes. Maybe some functions that transmit data between PICO-8's.

My idea is when the 1st PICO-8 instance is opened, it's given a temporary number, 1, and registered to a global table shared between all PICO-8's on the desktop. When you open another PICO-8, it's given 2, and registered to the same table that 1 was registered to. When you close PICO-8 instance 1, it would remove 1 from the table.

Here are some mock-up API functions that would allow this linking:

INSTANCE([n])
If n is omitted:
Returns the current PICO-8's instance number on the desktop (1, 2, 3, etc.)
If n is a number:
Returns the instance n's status: exists,cart,link
exists is true if the nth instance exists on the desktop, false otherwise.
cart is the cartridge file (or BBS ID) currently running by the nth instance.
link is the link that the nth instance is connected to.

INSTTABLE()
Returns a table containing all instance numbers running on the desktop. For example, if instances 1, 3, and 4 are running, then the table contains 1, 3, and 4. As such:
INSTTABLE()={[1]=1;[2]=3;[3]=4;}

CONNECT(name)
name is the link name, as a string. If no name link exists on the desktop, the link is created automatically. If it already exists, then the current PICO-8 will connect to the link.
A link consists of a counter that represents how many PICO-8's are connected to it, and its Lua variable data. When a new PICO-8 connects to the link, it's incremented by 1. When a cartridge that connected to the link is reset or stopped, it's decremented by 1. When all PICO-8's have disconnected (the counter is 0), the link is deleted.

DISCONNECT([name])
If name is omitted:
The current PICO-8 will disconnect from all connected links.
If name is a string:
The current PICO-8 will disconnect from name.
DISCONNECT() is automatically called without arguments when the cartridge is reset or stopped. This prevents excessive RAM usage on the host computer.

LINK()
Returns the link the current PICO-8 is connected to.

LGET(var)
Returns the value of the current link's variable var.

LSET(var,val)
Sets the current link's variable var to the value of val.

LCLEAR()
Clears all variables in the current link, but doesn't affect the counter.

Please feel free to add more suggestions!

P#63393 2019-04-10 22:38

Maybe something like that could work. I haven't thought about it much. I think the exported HTML games for PICO-8 have the GPIO pins in a Javascript array, so in theory it should be possible, but I haven't really played around with the GPIO pins.

P#63688 2019-04-19 14:26

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-10-15 01:02 | 0.010s | 2097k | Q:16