goboscript icon indicating copy to clipboard operation
goboscript copied to clipboard

Can it transform single file into blocks copied to clipboard

Open hacktronics opened this issue 7 months ago • 9 comments
trafficstars

I want to write some text based program in goboscript and then using some tool, just convert that code or algo into scratch blocks, that can be easily pasted to scratch. I don't want to create config, etc, and not wanted to generate any file. Can it just take the data from the text file and convert it to blocks that can be copied to Scratch or other mods. so the goal is not to write config, etc. just a single text file which contains code. Also it should not generate sb3, etc. just generate the blocks and can copy the same to clipboard.

hacktronics avatar Apr 14 '25 19:04 hacktronics

I don't think scratch stores your ctrl-c of blocks as text in the clipboard, so you could only implement this as a browser extension. Also this isn't really what you're meant to use goboscript for

faretek1 avatar Apr 14 '25 20:04 faretek1

Scratch does not use the system clipboard to store blocks, so its not possible to paste blocks into the editor without some sort of browser extension or userscript.

The goboscript.toml configuration file is completely optional.

The only ways to load code into the editor are -- via a .sb3 project file, or a .sprite3 sprite file. goboscript currently only supports emitting a .sb3 file. Emitting .sprite3 files is a potential feature, but I'm not sure how useful that would be.

What I understand is that your problem is that there is no way to use goboscript code in an existing Scratch project, without having to port the entire project to goboscript. Moving blocks using the backpack is one solution. goboscript could potentially have a feature which injects blocks into existing projects, but keeping track of injected blocks is not possible (It's possible in vanilla scratch editor, but if the project is edited using TurboWarp, tracking information (block IDs) is lost).

P.S. I will need to re-investigate if TurboWarp still modifies block IDs. if it does not, then I'll dust off SPM (scratch package manager) which allows you to add blocks from many projects into one project.

aspizu avatar Apr 15 '25 13:04 aspizu

its possible to use the scratch api to send it into your backpack

faretek1 avatar Apr 16 '25 13:04 faretek1

The question is not how Scratch will do it, the question is how I can use goboscript to do that. Send a simple text file and get a XML response of the blocks. Disclosure: I am the creator of https://CodeSkool.cc, and looking to integrate goboscript with CodeSkool Sometimes writing long if statements are a pain, I believe writing it in plain text to getting it generated using AI and converted to scratch blocks will be a great feature. Willing to work on this, if you can give some pointers. Not good at RUST, mostly I have Golang and JS React programming expertise.

hacktronics avatar Apr 22 '25 20:04 hacktronics

What I meant is converting this:

onflag {
    say "Hello, World!";
}

into:

"blocks": {
        "0": {
          "opcode": "event_whenflagclicked",
          "next": "1",
          "parent": null,
          "topLevel": true,
          "shadow": false
        },
        "1": {
          "opcode": "looks_say",
          "next": null,
          "parent": "0",
          "topLevel": false,
          "shadow": false,
          "inputs": {
            "MESSAGE": [
              1,
              [
                10,
                "Hello, World!"
              ]
            ]
          }
        }
     }

hacktronics avatar Apr 22 '25 20:04 hacktronics

that is possible by compiling a goboscript project and extracting the blocks from the .sb3's project.json

aspizu avatar Apr 22 '25 21:04 aspizu

yes, that is very much possible, but then its mostly not usable. One of the biggest design decision for CodeSkool is zero server, and 99% of the mods don't use servers, just static hosting. I was hoping, there could be an easier way using WASM to do the same. Instead of running goboscript extracting blocks, and then creating API, sending response. I know that is not goboscript goal, but IMHO, this is what the market is. Having native integration with Scratch or any mod, will make its usecase hundreds of times bigger. My understanding is Rust can be easily converted in wasm also rather than exe. Again as I said before, my understanding of RUST is limited.

hacktronics avatar Apr 23 '25 03:04 hacktronics

goboscript will have wasm support, its possible, you can use jszip to extract zip files on the client.

aspizu avatar Apr 23 '25 04:04 aspizu

So, any rough idea about the timeline for the wasm support

hacktronics avatar Apr 23 '25 06:04 hacktronics

So, any rough idea about the timeline for the wasm support

its in

aspizu avatar Jun 19 '25 04:06 aspizu