Discuss Scratch

B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

Introducing…

Katnip

Official website Katnip.org
Here is the GitHub Link.
Here is the Wiki Link for anyone interested.
All blocks are functional, working on rewriting compiler atm

Most of the instructions are on GitHub, but the main points for setup are as follows: copy all files out of the repo.
  • Open the ‘SECRETS.txt’ file, and modify the file path for ‘Program=’ to be the file path to either the turbowarp or scratch offline editor (either works). The project ID is for downloading the JSON of a file (you can run it through project_download.py).
  • Edit a file.scrtxt or file.knp for your main code
  • Finally, run ‘run.py’ to run your code, with the file path adjusted to your code file. Your sb3 file should be generated as ‘program.sb3’ in the “generated projects” folder, and it should open using the offline editor in the path specified.

I would appreciate any feedback (or help! ) from anyone.

Last edited by B1j2754 (Feb. 4, 2025 20:09:35)

SCRATCH---PIXEL
Scratcher
57 posts

Katnip - Text-based coding language for Scratch

Absolutely impressive work. (By the way there exists something similar to this. https://scratch-mit-edu.ezproxyberklee.flo.org/discuss/topic/747370/)
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

SCRATCH---PIXEL wrote:

Absolutely impressive work. (By the way there exists something similar to this. https://scratch-mit-edu.ezproxyberklee.flo.org/discuss/topic/747370/)
Thank you so much! And I don't know how I missed that , thank you for the link
CodeMaster126775
Scratcher
13 posts

Katnip - Text-based coding language for Scratch

there is also tosh.blob.codes
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

CodeMaster126775 wrote:

there is also tosh.blob.codes
True, but that works with scratch 2.0, and exports as .sb2 files. This project has a final goal of probably somewhat resembling tosh (a little bit), but exports and makes sb3 functions (already implemented)
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

Update 2.0 coming very soon! I wrote a longer message but the forums kept erroring me out
Bigger post (more in depth and detail) later this week! (Posted along with the release of 2.0)

Here's a lil sneak peek of whats to come:
(Full block support btw, so its actually viable to use )

Last edited by B1j2754 (Dec. 9, 2024 04:49:01)

ababoin07
Scratcher
500+ posts

Katnip - Text-based coding language for Scratch

You are a really good programmer, but a question is : can I use recursive functions with mocal variables (i think, no) and are the return compatibles with scratch website AND turbowarp?
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

I am not totally sure what you mean
Recursive functions (e.g. functions that call themselves) are not possible yet, since I have not yet implemented custom blocks.
Once I do, that should be totally within the scope of my application.

And yes, the sb3 projects generated are compatible with turbowarp and scratch.
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

V.2: https://github.com/B1j2754/v2.ScratchText
V.2 vscode extension: https://github.com/B1j2754/syntax-scratchtext
Wiki: https://github.com/B1j2754/v2.ScratchText/wiki

Edit: Docs/wiki released on Github!

I don't have much time, but I will release docs and documentation and such tomorrow (or sometime this weekend).
I will go ahead and publish both the vscode extension and the source code for ScratchText v.2 tonight
(Drag and drop syntax-scratchtext into c: /users/urname/.vscode/extensions/ and reload vscode to use the extension)

To run anything, run “src/run.py” and change the filepath to your code accordingly.
Similar to v.1, it is crucial to change “references/secrets.txt” file path for “program” to be the path to your turbowarp.exe offline editor.
I have left mine in, incase it helps anyone else find it.

There also is a handful of projects written in the project (see “/scripts/”) and you can look through how the code works!

See y'all this weekend with a bigger update!



any guesses for what this does?

Last edited by B1j2754 (Dec. 15, 2024 02:26:21)

B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

Wiki docs created! https://github.com/B1j2754/v2.ScratchText/wiki
I also updated the first post according to v.2.
README.md should be fully updated too!
Let me know what I should add next! (Besides custom function blocks - I am in the works as we speak)

Last edited by B1j2754 (Dec. 14, 2024 22:59:53)

i_eat_coffee
Scratcher
1000+ posts

Katnip - Text-based coding language for Scratch

Making a website for this would be a bit more complicated since you need to actually rewrite the interpreter client-side if you want to host a static website.
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

Ah okay I see.
Would this mean writing it in a different language or some other stuff?
Excuse my very basic knowledge here - I do not have much experience working front-end
Maximouse
Scratcher
1000+ posts

Katnip - Text-based coding language for Scratch

i_eat_coffee wrote:

Making a website for this would be a bit more complicated since you need to actually rewrite the interpreter client-side if you want to host a static website.
It could probably run in a browser using Brython.
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

I'll have to check this out! Thank you!
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

i_eat_coffee wrote:

Making a website for this would be a bit more complicated since you need to actually rewrite the interpreter client-side if you want to host a static website.
Would Brython be an option? And could you help me do it?
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

i_eat_coffee wrote:

Making a website for this would be a bit more complicated since you need to actually rewrite the interpreter client-side if you want to host a static website.

Website progress!

Decided to go with flask for the backend, and not make it a static website. I think I'll just use Render for server hosting

Last edited by B1j2754 (Dec. 26, 2024 19:08:57)

KKGamer1610
Scratcher
32 posts

Katnip - Text-based coding language for Scratch

Check out https://github.com/aspizu/goboscript, it's a similar project with a little more traction.
Radijz
Scratcher
1 post

Katnip - Text-based coding language for Scratch

How do you compile to an SB3 file? Just the basics of the compiler
B1j2754
Scratcher
76 posts

Katnip - Text-based coding language for Scratch

Radijz wrote:

How do you compile to an SB3 file? Just the basics of the compiler
Uhh here's the general structure if you're interested:
  • Get user input for custom language (ScratchText in my case)
  • Create metadata and define general structure of the internal json file
  • Transfer/Create any assets (think sprite costumes and sounds)
  • Create a generalized “template” of sorts for each sprite you want to have
  • For each sprite, fill out the template, and parse its corresponding blocks:
  • - For each block, parse its inputs (and its internal block inputs if they are blocks)
  • - Parse the block's data, so opcode and such, filling out another template
  • - Make sure the block template's “next” and “parent” are set correctly
  • After finishing block processing for the sprite, process any variables, lists, or broadcasts that you might've used in the scripts

Lmk if this helped
M1dnightGMR
Scratcher
5 posts

Katnip - Text-based coding language for Scratch

This is actually really cool. Unfortunatley, I'm on a chroembook instead of my PC so I can't access github, but does how exactly does ti work. Do you write the code, then export the .sb3 and run it on turbowarp? does it have turbowarp extensions support? can you test games live?

This project is very impressive tho!

Powered by DjangoBB