Skip to content

How do I copy the JavaScript

Thomas Weber edited this page Nov 5, 2020 · 26 revisions

Short Answer

It's complicated, and you shouldn't even if you could.

Work on allowing users to package/HTMLify TurboWarp is ongoing: https://garbomuffin.github.io/p3/

For a project that intends to output readable JavaScript, check out Leopard.

Long Answer

The code generated by TurboWarp is not designed to be read or edited by humans. Attempting to do so would be actively harmful to one's learning because of the many unusual things done to improve compatability or performance.

For example, in regular JavaScript accessing a list item is as simple as myList[myIndex], but TurboWarp does (b1.value[(b0.value | 0) - 1] ?? "") or listGet(b0, b1.value) depending on what assumptions it can make. And yes, b0 and b1 are real variable names that TurboWarp will use. Also note that listGet is not a standard JavaScript function, it's part of the TurboWarp runtime. The code also lacks any formatting.

For a project that intends to output readable JavaScript, check out Leopard.

I know what I'm doing

You can view the JavaScript code in your browser console. The scripts are logged there when they are compiled. See here for an overview of some of the compiler's internals: https://github.com/TurboWarp/scratch-vm#compiler-overview

Clone this wiki locally