Log In  

Hello
I am making a pico-8 game
I am a student who is learning web development but I got a game developing project.
My friend's brother has some pico-8 games which are playable in web browser so my friend got some stuffs.
Now I am trying to edit and add some pico8 codes but they just don't work.
I mean my web browser just won't apply my updates.

For example, let's say there were these codes in the original pico-8 file.

level_text = "lvl: "..level;
print_text(level_text, 120 - #level_text*4, 122, 12, 7);

if I change "lvl" to "SomeText" and save it, browser continues showing LVL instead of SomeText. I even tried to remove .p8 file but even after completely refreshing(CTRL+F5) the page, web browser is keeping to display the game like .p8 file isn't removed. (I don't understand how web browser can display pico-8 game without .p8 file)

I don't know why.

I am using Visual Studio Code and already have installed pico8-vscode extension.

I can javascript but when I opened the js file, after unminifying it, I saw 90000+ code lines... Module cartridge blah blah blah..

What should I do so my changes could work in web browser?

P#50661 2018-03-21 09:43 ( Edited 2018-03-22 09:05)

Hello oehqoehfo, welcome to pico-8.
It sounds like you might be editing the cart file (.p8 or .p8.png) -- to apply those changes to the html export, you have to export the file to html using pico-8.
This is done with the command "export filename.html" inside of the pico-8 editor (or call export("filename.html") inside your code and then run the cart).

Typically, you want to run/edit/test stuff with the desktop version of pico-8 as your test platform; if you prefer to edit in another IDE, you can setup a script to run the cart:
> pico8 -run {filename}

Or if you want to use the browser as your test platform, you'd want to make a cart that exports your changes to html, then loads that page I guess.. I haven't tested it, but this should work:
> pico8 -run html_export_cart_filename -p your_game_filename

With this as the code in the html_export_cart:

filename=stat(6)
?"exporting "..filename.."..."
--remove the .p8 or .p8.png extension..
formatted_name=""
s=1
while s<=#filename and char!='.' do
  char=sub(filename,s,s)
  formatted_name=formatted_name..char
  s+=1
end

export(formatted_name..'.html',filename)
P#50662 2018-03-21 10:11 ( Edited 2018-03-21 14:24)

Hello enargy, thank you for you answer.
I am editing .p8 file. Hope I am doing right.
Could you explain to me little bit what do you mean "export the file to html using pico-8"? is pico-8 = .p8 file?

in HTML, to go to the parent path, ".." should be used. Is it same with pico-8 or .p8 file?
my HTML file's path is ninjaGame/web/ninja.html
and .p8 file's path is ninjaGame/games/ninja.p8

Should I add your codes in my .p8 file? where should I write that?
Sorry for my poor english and so many questions.

P#50663 2018-03-21 10:23 ( Edited 2018-03-21 14:27)

It's cool.. I just updated my post; there was an error in the original version where it would have done and html export of the >html export cart< and not the cart that was passed...

I'll upload a directory with an example file.

P#50664 2018-03-21 10:25 ( Edited 2018-03-21 14:25)

Hmmm, so this doesn't work the way I was thinking it did.. Here's from the notes on the latest update:

Commandline Scripts
The new -x parameter to PICO-8 can be used to run carts as part of commandline tool chains. For example, if you have a long-winded process for copying data around and generating large multicarts, you could automate the process by creating a single cart that does the job:

-- BUILD.P8
CD("MYPROJ")
LOAD("TITLE.P8")
EXPORT("MYGAME.BIN -I 1 LEVEL1.P8 LEVEL2.P8 LEVEL3.P8")
And then run PICO-8 from commandline:

$ pico8 -x build.p8
EXPORT /home/zep/pico8/carts/myproj/mygame.bin -i 1 level1.p8 level2.p8 level3.p8
This will execute each line of build.p8 as if it had been typed in from a fresh boot of PICO-8, but without ever opening a window. It isn't truely headless yet because it still requires SDL2 (along with the video/audio driver) -- e.g. you can still play sound from it. I'll look at improving this in the future for people who want to make twitter bots and whatnot.

edit: I haven't been able to get this to work for an html export at all... Or a binary export. Maybe the feature is just broken? Or I could be doing it wrong.

OP, for now you may just have to:

  • open pico-8
  • load the file (or use "pico-8.exe filename" from the commandline, that works)
  • run the command "export filename.html"
P#50665 2018-03-21 10:38 ( Edited 2018-03-21 15:00)

well I see it's pretty complicated but I will try to understand it.

commandline perhaps you mean cmd?

P#50667 2018-03-21 11:14 ( Edited 2018-03-21 15:14)

Yeah, you would want to type it into cmd.

The most straightforward way would be:

  • open pico-8
  • type "load filename"
  • press enter
  • type "export filename.html"
  • press enter

Doing it in cmd (or calling a .bat file) is just to help automate things / assign it to a button in your IDE so it's convenient with your current workflow. Having to jump between different programs can be a hassle.

FWIW, I do all my pico8 dev on the built-in editor. But I know that's not a good fit for everyone or for every game :p

P#50668 2018-03-21 12:07 ( Edited 2018-03-21 16:07)

Can I download pico-8 here? I see buy now! button(https://www.lexaloffle.com/pico-8.php) and filename in "load filename" is the game .p8 file which I want to edit and play. Did I understand right?

Sorry I am newbie in pico-8

P#50671 2018-03-21 13:03 ( Edited 2018-03-21 17:03)

Ah okay, gotcha. Yeah, if you don't have a copy of it yet you'd have to buy it there. That's where you would type in some of those commands, in the built-in pico-8 terminal.

Pico-8 ALSO has a feature where you can run some of those commands as command line arguments, so you would potentially be able to run a command using cmd that would accomplish the same thing.

If you got the Humble Voxatron bundle a while back (er.. several years ago at this point), then you should already have a pico-8 license you can redeem through details on Humble (iirc, you register the Voxatron purchase here, and then it comes with pico-8).

And yes, you would use the name of the file in the place where it says "filename".

P#50674 2018-03-21 13:54 ( Edited 2018-03-21 17:54)

enargy// Thank you for your kind answers but my computer created another issue. I bought PICO-8 and downloaded it in
C:xampp/htdocs/gameProject/pico-8-projects-master\pico-8-projects-master\PICO-8

and started pico8.exe and typed load games/ninja.p8 but always shows could not load.

games folder is just in the PICO-8 folder so.. path is
same as the upper URL and just add /games/ninja.p8

I tried load games/ninja.p8 but not working

should I do something before to complete this task?

P#50678 2018-03-21 16:50 ( Edited 2018-03-21 21:24)

So the pico-8 program is stored in your program files directory (on Windows at least) but the cart files aren't.

The easiest way to find your carts is to type the command "FOLDER" into the pico-8 terminal. That will open up a browser to that location. Then you can drop your game into there.

P#50679 2018-03-21 17:24 ( Edited 2018-03-21 21:24)

enargy// Ok thank you now pico-8 loaded ninja.p8 and export .html file is also finished.
I see two pink texts below
ninja.html
ninja.js

so if html file includes ninja.js file, any changes done in ninja.p8 with Visual Studio Code will be applied forever and I don't have to do all these things again?

Really sorry for so many questions

P#50681 2018-03-21 17:32 ( Edited 2018-03-21 21:38)

enargy// Well now I see unfinished string near b'"../web/ninja.html'

but I think it's better than nothing :)

P#50682 2018-03-21 17:43 ( Edited 2018-03-21 21:43)

enargy// Oh really thank you! I added drawLife function .p8 file some days ago and now I see browser shows runtime error 516 blah blah function drawLife blah blah

I see your tips are working!! Thank you very much! But now I recognized I should repeat all these load export steps everytime to see the result. Is there any way to load .p8 and export .html just once and then load and export these .p8 and .html files automatically after code change?

P#50683 2018-03-21 18:04 ( Edited 2018-03-21 22:04)

I tried making a way to do that, but I couldn't get it to work correctly.

What I recommend doing is to edit the p8 file and then just play the game in pico8. If you point visual studio to the p8 file that you put where pico8 can see, and then do "pico8 -run filename.p8" in cmd, it should load the file up with the changes you made and start running it so you can test it.

Do that while you are testing and developing. Then when you're ready to actually publish it online, do the export html part.

P#50684 2018-03-21 20:26 ( Edited 2018-03-22 00:27)

If you load a .p8 file in Pico 8 then edit that same file in visual studio (or any external code editor) you can also load external changes and run the file in Pico 8 with the ctrl+R keyboard shortcut.

P#50688 2018-03-22 03:32 ( Edited 2018-03-22 07:32)

Thank you everybody!

P#50690 2018-03-22 05:05 ( Edited 2018-03-22 09:05)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 10:07:36 | 0.011s | Q:28