Discuss Scratch

SuperDoom
Scratcher
1000+ posts

How to hack your own magic custom blocks

You got the BBCode wrong. It should be:
define Fill [list] with [a],(n) times
repeat (n)
add (a) to (list)
end

Last edited by SuperDoom (Dec. 22, 2014 00:40:25)


WARNING: Anything I post is either stupid, sarcastic, or ironic. I am not to be taken seriously. Feel free to make fun of me for anything I say.
“Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety.”
essentiallibertyisfreedomofspeech~Benjamin Franklin (This is my motto for replying to suggestions.)
As of 83G1NN1NG/0F/71M3, I use color #322F31 for my posts. If it's a link, I use #1AA0D8.
CLICK THIS LINK TO INSTANTLY CRASH THE SERVERS
Alexa, play Space Invaders.
300035004000
As of November 7th, 2019, I have my computer back.
I'm awake from 11:00 AM to 11:30 PM CST (12:00 PM to 12:30 AM EST). Please be more active during that time.
I've moved to -THENEXT_LEVEL-.
Dylan5797
Scratcher
1000+ posts

How to hack your own magic custom blocks

Tropic
Scratcher
1000+ posts

How to hack your own magic custom blocks

mosby123 wrote:

whenever i do what it says and hit upload the project says “the project has failed to load” how can i make it work?
That probably means you have done something wrong when editing the code.



My browser / operating system: Windows NT 10.0, Firefox 40.0.2, Flash 20.0 (release 0)
Last eaten by Evil Kumquat (Today 19:30:11)
when I receive [flash_player_version] :: motion
say [Windows 7, Flash 15.0 (release 0)] :: sensing
stop script :: custom
Tropical Productions
amyleexrule
Scratcher
8 posts

How to hack your own magic custom blocks

when crazy flag clicked
emeralddog
Scratcher
100+ posts

How to hack your own magic custom blocks

By the way, do you think you could do an example project with a custom block which creates a cloud variable

I hate people who ask for followers - follow if you agree!
Tropic
Scratcher
1000+ posts

How to hack your own magic custom blocks

amyleexrule wrote:

when crazy flag clicked :: events hat
Looks a bit better now



My browser / operating system: Windows NT 10.0, Firefox 40.0.2, Flash 20.0 (release 0)
Last eaten by Evil Kumquat (Today 19:30:11)
when I receive [flash_player_version] :: motion
say [Windows 7, Flash 15.0 (release 0)] :: sensing
stop script :: custom
Tropical Productions
Tropic
Scratcher
1000+ posts

How to hack your own magic custom blocks

emeralddog wrote:

By the way, do you think you could do an example project with a custom block which creates a cloud variable
Creating a cloud variable with a block might be hard, but I have already succeeded with making a custom block that creates a local variable and it can also create a normal variable, but not a cloud variable.



My browser / operating system: Windows NT 10.0, Firefox 40.0.2, Flash 20.0 (release 0)
Last eaten by Evil Kumquat (Today 19:30:11)
when I receive [flash_player_version] :: motion
say [Windows 7, Flash 15.0 (release 0)] :: sensing
stop script :: custom
Tropical Productions
xsnail
Scratcher
90 posts

How to hack your own magic custom blocks

wizzwizz4 wrote:

( [#0F0] )
Wouldn't these be cool blocks, especially if
<(Blend [#0F0] and [#00F]) = ( [#0FF] )
returned true?

Oh, and by the way, does anybody know how to get
the [#F23] thing
with % notation?
%c

NuclearBlaster
Scratcher
10 posts

How to hack your own magic custom blocks

Nathanator1416J wrote:

Hardmath123 wrote:

Nathanator1416J wrote:

It was easy enough to make “corrupt” scratch programs that ran on the scratch system in 1.4
No, it was much harder. Messing with the binary was practically impossible until Kurt, and simple hacks with shift-click-r (moving variable) didn't normally work with the Java player anyway.
Thats hard??? I don't personally think that was hard with Textpad..

I kinda agree with that, if you use textpad it's simple

Never trust a barrel. It might blow up in your face

Cloud data!
Cloud survey! | Submit a question!
rocketclock123
Scratcher
100+ posts

How to hack your own magic custom blocks

I'm to lazy to try

My Signature doesn't taste good
PLATFORMER click here
Dragon_Slayer1500
Scratcher
31 posts

How to hack your own magic custom blocks

yugi1024 wrote:

wait , no sorry. a rectangle
I know that.
Dragon_Slayer1500
Scratcher
31 posts

How to hack your own magic custom blocks

emeralddog wrote:

By the way, do you think you could do an example project with a custom block which creates a cloud variable
There is a block that does that.
minishark123
New to Scratch
4 posts

How to hack your own magic custom blocks

point towards noware 
switch costume to cunvuzed cat thats weird
Tropic
Scratcher
1000+ posts

How to hack your own magic custom blocks

minishark123 wrote:

point towards nowhere :: motion
switch costume to cunvuzed cat thats weird :: looks
I fixed the colours



My browser / operating system: Windows NT 10.0, Firefox 40.0.2, Flash 20.0 (release 0)
Last eaten by Evil Kumquat (Today 19:30:11)
when I receive [flash_player_version] :: motion
say [Windows 7, Flash 15.0 (release 0)] :: sensing
stop script :: custom
Tropical Productions
Theassasin36
Scratcher
15 posts

How to hack your own magic custom blocks

thirdlion
Scratcher
20 posts

How to hack your own magic custom blocks

Tbtemplex97 wrote:

It worked!, this seems fun anything else you can do?
wait….wait do you know how you do the first step i did not get that one
minishark123
New to Scratch
4 posts

How to hack your own magic custom blocks

(distance to my house =30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 lght years
endermanjd
Scratcher
37 posts

How to hack your own magic custom blocks

Hardmath123 wrote:

Hacking your own custom blocks
A tutorial

Basically, in this tutorial I'm going to demonstrate how to mess with blocks offline so that you can manually insert reporters in forbidden spaces, and even create custom blocks.

Step 1: Setup
Open up a new Scratch 2.0 project and make a new custom block. For this tutorial, I'm going to make a block that automates a boring thing: adding a value many times to a list. You will be able to, with one block, add an arbitrary value to a list, an arbitrary number of times.

Make a new Scratch project, and add a new custom block:
define [Fill [list] with [a],(n) times]
repeat (n)
|add [a] to [list v]
Pretty straightforward. Remember to make a list to get the list blocks!

Step 2: Downloading a project
Now select File>>Export to local drive to save it to your local disk. In the popup, rename it to “Hack.zip”. Note the “.zip”, not “.sb2”. Pick any place to save it. Now, unarchive the zip.

On Mac or Windows, just double-click the zip file. On Mac and Linux, you can also use the “unzip” command-line utility.
$ cd ~/path/to/zip's/folder
$ unzip Hack.zip
You should get a whole bunch of goodies:
  • project.json!
  • 0.png: this is the image which contains pen trails/stamps
  • 1,2,3.svg: costumes and backgrounds
  • 0.wav: sounds
The second two items are the defaults loaded into a project.
(At this point, you can safely delete the zip file.)

Step 3: Modifying the code!
Now, open up project.json in your favorite text editor/code editor. Here's what you should see:
{
	"objName": "Stage",
	"lists": [{
			"listName": "dummy",
			"contents": [],
			"isPersistent": false,
			"target": "Stage",
			"x": 5,
			"y": 5,
			"width": 102,
			"height": 202,
			"visible": true
		}],
	"sounds": [{
			"soundName": "pop",
			"soundID": 0,
			"md5": "83a9787d4cb6f3b7632b4ddfebf74367.wav",
			"sampleCount": 258,
			"rate": 11025,
			"format": ""
		}],
	"costumes": [{
			"costumeName": "backdrop1",
			"baseLayerID": 3,
			"baseLayerMD5": "790f7842ea100f71b34e5b9a5bfbcaa1.svg",
			"rotationCenterX": 240,
			"rotationCenterY": 180
		}],
	"currentCostumeIndex": 0,
	"penLayerMD5": "279467d0d49e152706ed66539b577c00.png",
	"tempoBPM": 60,
	"children": [{
			"objName": "Scratch Cat",
			"scripts": [[53,
					47.8,
					[["procDef", "Fill %s with %s , %n times", ["list", "a", "n"], ["", "", 1], true],
						["doRepeat", ["getParam", "n"], [["append:toList:", ["getParam", "a"], "dummy"]]]]]],
			"sounds": [{
					"soundName": "pop",
					"soundID": 0,
					"md5": "83a9787d4cb6f3b7632b4ddfebf74367.wav",
					"sampleCount": 258,
					"rate": 11025,
					"format": ""
				}],
			"costumes": [{
					"costumeName": "costume1",
					"baseLayerID": 1,
					"baseLayerMD5": "f9a1c175dbe2e5dee472858dd30d16bb.svg",
					"rotationCenterX": 47,
					"rotationCenterY": 55
				},
				{
					"costumeName": "costume2",
					"baseLayerID": 2,
					"baseLayerMD5": "6e8bd9ae68fdb02b7e1e3df656a75635.svg",
					"rotationCenterX": 47,
					"rotationCenterY": 55
				}],
			"currentCostumeIndex": 0,
			"scratchX": 0,
			"scratchY": 0,
			"scale": 1,
			"direction": 90,
			"rotationStyle": "normal",
			"isDraggable": false,
			"indexInLibrary": 1,
			"visible": true,
			"spriteInfo": {
			}
		}],
	"info": {
		"scriptCount": 1,
		"spriteCount": 1
	}
}

Don't panic! I'll walk you through it.

The format you see with all the colons and brackets is called JSON (JavaScript Object Notation). It's a simple notation to describe data structures. Read more here, but for now I'll explain the basics as we go.

If you have a search utility in your text editor (try ctrl-F), look for “Scratch Cat” (the name of the sprite in which we added the custom block).
These lines are what we will be messing with. “objName” means the sprite's name, and “scripts” is a list of scripts.

Replace that bit, up to but not including the line “sounds” with:
			"objName": "Scratch Cat",
			"scripts": [[28,
					101.9,
					[["procDef", "Fill %m.list with %s , %n times", ["list", "a", "n"], ["", "something", 10], true],
						["doRepeat", ["getParam", "n"],
						 [["append:toList:", ["getParam", "a"], ["getParam", "list"]]]
						]]]],

All I did was replace a text input with a list drop down. A complete list of %-things can be found here, courtesy nXIII. I also changed the input to the append function. Finally, I changed the default values in the first line for a professional look.

Step 4: Reuploading
Now save the json file and quit. You need to re-zip these files.

On Windows, right-click the folder in which you saved the original zip, and choose “Send to”>>“Compressed (Zipped) folder”. On Mac, rihgt-click the folder and select “Compress…”. On Mac and Linux you can also use the “zip” utility basically the same way we did above. Rename the new file to “Hack.sb2”.

Open up the Scratch project and select File>>Import from local drive. If it gives you any warnings, select “Ok”. Enjoy!

the part when you look in the zip to get the goodies i can't open it can you help me? i have a mac.

endermanjd :: operators
is awesome! :: sound
Alexcamostyle
Scratcher
81 posts

How to hack your own magic custom blocks

I have a problem. I'm on a Mac and I can't revert the project back to an .sb2 file. It keeps on reverting to “.sb2.zip”.
Alexcamostyle
Scratcher
81 posts

How to hack your own magic custom blocks

Also, is there a way to get a list of variables in a hacked custom block?

Powered by DjangoBB