Log In  


Hello.

Two things, really. First off there is this wonderful program written by @pahammond that compresses source-code.

https://pahammond.itch.io/gem-minify

For long variable names it does a great job, changing: apple=25 to _a=25 which I feel could be even smaller with a=25

However it does not seem to compress variables that have 2-letters in them, for instance: te=25 compresses to te=25.

Yep. No compression at all.

So - either I'm not using the program correctly - or do you know of a Pico-8 minifier that will exhaust the single-character letters a-z for variables before going to 2-characters ?

If you must know I'm working on a useful function for everyone (no file access, no worries) :) yet I want it really compact so it's easy to slip in your own code.

What can I do in this respect ?

1


2

thisismypassword's shrinko8 is an excellent PICO-8 minifier with some cool options. https://github.com/thisismypassport/shrinko8

My own picotool has similar features. shrinko8 outpaces picotool in a few ways that were on my to-do list but I haven't gotten to yet. :) https://github.com/dansanderson/picotool

I imagine you're looking for a web-based app similar to GEM. It'd be easy to set up shrinko8 or picotool as a web-based tool. I'll... add it to my to-do list. ;)


Hi @dddaaannn. Yep, you hit it right there.

I can't run Python on my computer. I wish I could. Lotsa good Python code out there.

So I can't use your program unless it's online or saved as a single offline HTML as @pahammond did.

I sposers I could write one myself. Would be tedious to code in Blitz or even Pico.

I'd rather not since there are already 2-versions out.

Any chance, dddaaannn, of you getting yours saved off as an .HTML or .BAT soon ?

You too, @thisismypassword. If you can get it to run for simple folk like me who can't seem to run Python, would be awesome and help out those people who also can't run Python.


I wrote it to handle my own coding style so, to avoid variable name conflicts, I always prefix with underscore and intentionally ignore already short variable names. It was really just hacked together so I could for bubble bobble in a single cart.

Feel free to take the code and enhance it for what works for you.


I will say that shrinko8 was worth the hassle of installing Python. It's a really nice tool. Yeah, I wish it were web based too.


1

OK guys, I just went HERE:

https://www.python.org/downloads/

Clicked "Download Python 3.11.0"

Installed it with Run As Administrator

Got this final screen:

Let's see if THIS version works, and yeah that version I had earlier I think was 3 something.

Seems to work. Maybe I had a bad version ? All of them ? Hmm ...

Yet I'm running into another problem, I'm getting back two error messages from this code:

-- fireball minus opening
cls()
x=64 y=64 c={1,2,8,9,10} s=8
for i=1,5 do
  pal(i,c[i],1)
end

repeat
  for i=1,2100 do
    a=rnd(128) b=rnd(128)
    p=pget(a,b)
    pset(a-1+rnd(2),b-2+rnd(3),p)
    if (p>0) pset(a,b,p-1)
  end
  circfill(x,y,s,5)
  if (btn(0)) x-=2
  if (btn(1)) x+=2
  if (btn(2)) y-=2
  if (btn(3)) y+=2
  if (btn(4) and s<16) s+=1
  if (btn(5) and s>1) s-=1
  flip()
until forever

Here is a copy from CMD.EXE.

C:\David\Pico-8\!pico-8_win32\shrinko8-main\try>python ..\shrinko8.py fireball.p8 fire2.p8 --lint --count --minify
tokens: 164 2%
Lint errors:
fireball.p8(37:7) - Local 'i' isn't used
fireball.p8(51:7) - Identifier 'forever' not found

C:\David\Pico-8\!pico-8_win32\shrinko8-main\try>

Does seem to work otherwise ! I need i for my FOR/END loop and forever is just a quick way of saying to loop forever.

. . . ? ? ?

Ah ! There is something called LINT ! I turned it off and it did a nice job ! Wow that is really compact. :)

cls()o=64i=64n={1,2,8,9,10}e=8for e=1,5do pal(e,n[e],1)end repeat for e=1,2100do a=rnd(128)l=rnd(128)t=pget(a,l)pset(a-1+rnd(2),l-2+rnd(3),t)
if(t>0)pset(a,l,t-1)
end circfill(o,i,e,5)
if(btn(0))o-=2
if(btn(1))o+=2
if(btn(2))i-=2
if(btn(3))i+=2
if(btn(4)and e<16)e+=1
if(btn(5)and e>1)e-=1
flip()until f

For those of you who may not understand the interface. first off, download Shrinko8 to a new directory. Find the download for it HERE as @dddaaannn stated earlier:

https://github.com/thisismypassport/shrinko8

Once there, click on the GREEN button that says, "Codeβ–Ό"

From there scroll all the way down till you see, "Download ZIP" click on that. Go to download that ZIP in a new directory.

Now if you don't have 7zip installed yet (and you really should), go HERE to get that:

https://www.7-zip.org/download.html

Go to install that. And then you can RIGHT CLICK with your mouse in Explorer and unzip the ZIP you got from @thisismypassword.

Click the far-bottom-left icon for Windows, select RUN, the type in cmd.exe you will be in command mode.

Use "cd" to change to the directory where you have downloaded and unzipped shrinko8.

Copy over some choice Pico-8 programs with the extension p8

Then while still in command mode cmd.exe type out:

python.exe shrinko8.py original.py new.py --count --minify

Where original.p8 is the original name of your Pico-8 cart before it is saved and compressed as new new.p8

If you want a batch file I named this, "shr.bat"

python.exe "..\shrinko8.py" "%1.p8" "%1"2.p8 --count --minify"

Of course change it to match the directory you have your shrinko8.py in.

And there you have it. Check out the new.p8 and you will see it is shrink-wrapped just as thisismypassword wrote it to be. Great work and interesting stuff !

Now it does not seem to work on some of my advanced code so maybe that's showing me I need to recode it to a simpler format.

I have checked and see some of the other Python scripts I've downloaded for batch work still do not work properly, yet THIS program, Shrinko8 DOES. So that's good enough for me for now.

Because this tool exists it means I will start to add more notes to my coding and use longer names for variables. I will only be using this tool to distribute functions that I expect other people to put in their code to help them - however I will also include the decompressed version chock full of notes.

In fact since this tool exists and works for me, it means I can go crazy with long variables and lotsa remarks. Which - bring up another request. Different thread. :)

. . .

Thanks for all the information, guys ! I'm continuing my project. I will let you know when it's all done with a new post. Useful utility to help in coding, does not use cmd.exe at all.


minor comment: on Windows, I'd suggest using the Windows Store version of Python, will ensure you are on the latest version for a given Python branch (3.8,3.9..).


Thanks, @freds72. Wait ... Windows store ? Is it for sale ?
URL ?

. . .

Wait, I found it.

https://apps.microsoft.com/store/detail/python-310/9PJPW5LDXLZ5

Hmm ... Clicking on the, "Get in Store App" shows a blue screen with a shopping bag and then returns back. Just as well I'm seeing now ! Their version is #10 and then one I got from the main website is #11. I cannot find a microsoft website offering version 11.

So ... unless I am mistaken the main Python website has the newest and latest version.


3.11 has been released a couple of weeks ago - it takes a bit of time to get something out on Store.
Again, not mandatory, just easier to manage overall.



[Please log in to post a comment]