Log In  

What is the reload() function or how do I load a .P8 file into a game. Or can I not do that?

P#146508 2024-04-13 01:04

1

I found the wiki page to be pretty clear :
https://pico-8.fandom.com/wiki/Reload
but it assumes a lot of previous knowledge.

Let's start with .p8 files
P8 files contains LUA code and data (the game label, the sprite sheet, the map, the sounds and music...)

When you run the .p8 game, the code runs in its big memory box, and all the rest in a tiny separate memory box (the pico-8 RAM)
reload() writes a chunk of memory from a the data part of a cart into the pico-8 ram.
This only affects the ram, you can't import the LUA part of another cartridge into the currently loaded game.
The function is called reload because without parameters, the cartridge it take it's data from is the current one, and the data segment is all the data from the cartridge, so in effect you are reloading all the data (map, sprites, sounds) to their original values.
For example, in a game where you take objects or open doors by changing the map with mset(x,y,val), calling reload() after a game over allows for a simple return to a clean starting state for the next game.
You can specify a different cart source for the reload, this way you can have extra sprites or maps stored in other "data" carts. In that case it's really a data load, not really a reload any more.

If what you are after is LUA code in different files (think libraries for example),
you write
#include my_lib.lua

wheremy_lib.lua is a simple text file who's text will be incorporated in your cart (and count in the total token count of course)

I can give more precision or examples if you explain what you are trying to do.

P#146524 2024-04-13 08:11 ( Edited 2024-04-13 08:13)
1

> how do I load a .P8 file into a game

can you rephrase this? I can see multiple interpretations

a P8 file is a cart, it is a game (if there’s gameplay in it! otherwise it’s a demo or a tool etc)
P8 carts and PNG carts are equivalent, they contain the same code and can be converted between each other

if you were asking: how to have one cart jump into another card, then you want the load function: https://www.lexaloffle.com/dl/docs/pico-8_manual.html#LOAD

P#146566 2024-04-13 19:56 ( Edited 2024-04-13 19:56)

I mean in some games there is a little cart logo at the top left that flips and when I check it after the animation game changes to something different.

like in https://www.lexaloffle.com/bbs/?pid=142641#p after the boot up screen and you get into the game and if so how do I do a data load

P#146589 2024-04-14 02:30 ( Edited 2024-04-14 13:14)

Ok, thanks it works. :)

P#146612 2024-04-14 13:18

that’s the load function! it is used to do launcher carts (like the arcade compilation), or different modes for a game that don’t fit inside one cart (for example funky title screen, exploration mode, battle mode – three carts that load each other and exchange some data)

P#146638 2024-04-14 20:09

[Please log in to post a comment]