Discuss Scratch

SDFTDusername
Scratcher
42 posts

need help with a mod!

i need help with a few things for a mod and i would appreciate it if you can help with one of the things.

1. can i edit scratch-vm inside the node_modules folder of scratch-gui with only scratch-blocks linked? (scratch-blocks wont build if scratch-vm is also linked)
1. how do i set the position of a variable and list monitor via blocks? (like set variable pos to x: 0 y: 0)
2. how do i set the type of a variable monitor via blocks? (like set type to normal readout, large readout and slider) and how do i set the slider min and max? like (set min: 1 max: 10)
3. how do i set the size of a list monitor via blocks? (like set list size to width: 10 height: 10)
4. when i make a custom extension and use it, it wont load when i try loading the project with that extension in the mod (says cannot be loaded). why?
5. how do i set turbo mode via blocks? (like set turbo mode )
6. how do i put custom variables like camera x and camera y in extensions? (in extensions theres tempo and pen color and it gets saved to project.json)
7. how do i make local variables/lists blocks like this: using (a) (b) © { }
8. how do i make return blocks? (my blocks that returns values without having to make a return variable)
9. how to insert a pre-defined block via a button on the my blocks category?
10. how to i get the number of sounds playing in a sprite? (like (number of sounds playing))
11. how do i make a draw triangle pen block? (like draw triangle -10 0, 0 10, 10 0)

completed:
1. how do i get turbo mode via blocks? (like <is turbo mode on?>)
2. how do i convert a list to json? (like (convert list to json))

thats all i need help with.

Last edited by SDFTDusername (Jan. 16, 2022 20:18:52)


Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
god286
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

8. how do i convert a list to json? (like (convert list to json))
I am not sure but I think lists are stored as JSON in the project.json file
They're exactly the same as arrays

Last edited by god286 (Jan. 6, 2022 09:29:51)


Here are some of my followers!

I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

1. can i edit scratch-vm inside the node_modules folder of scratch-gui with only scratch-blocks linked? (scratch-blocks wont build if scratch-vm is also linked)
Don't change the contents of node_modules – it will be overwritten when running npm install again (for example if new dependencies are added). What exactly is the problem with using npm link for both scratch-vm and scratch-blocks?


This is Maximouse's signature. Learn more about signatures.
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

1. can i edit scratch-vm inside the node_modules folder of scratch-gui with only scratch-blocks linked? (scratch-blocks wont build if scratch-vm is also linked)
Don't change the contents of node_modules – it will be overwritten when running npm install again (for example if new dependencies are added). What exactly is the problem with using npm link for both scratch-vm and scratch-blocks?
when i link scratch-vm and scratch-blocks to scratch-gui, scratch-gui and scratch-vm will build but scratch-blocks wont and doesn't change anything (i did try installing dev scratch-blocks in scratch-blocks and it did give no errors but still appeared as a red hat block)

Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
SDFTDusername
Scratcher
42 posts

need help with a mod!

s

god286 wrote:

SDFTDusername wrote:

8. how do i convert a list to json? (like (convert list to json))
I am not sure but I think lists are stored as JSON in the project.json file
They're exactly the same as arrays
so just JSON.stringify(args.list)?

Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

2. how do i set the position of a variable and list monitor via blocks? (like set variable pos to x: 0 y: 0)
I think you can use
util.runtime.requestUpdateMonitor({ id, x, y });

SDFTDusername wrote:

3. how do i set the type of a variable monitor via blocks? (like set type to normal readout, large readout and slider) and how do i set the slider min and max? like (set min: 1 max: 10)
util.runtime.requestUpdateMonitor({ id, mode: "default" });
util.runtime.requestUpdateMonitor({ id, mode: "large" });
util.runtime.requestUpdateMonitor({ id, mode: "slider" });

SDFTDusername wrote:

4. how do i set the size of a list monitor via blocks? (like set list size to width: 10 height: 10)
util.runtime.requestUpdateMonitor({ id, width, height });


This is Maximouse's signature. Learn more about signatures.
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

2. how do i set the position of a variable and list monitor via blocks? (like set variable pos to x: 0 y: 0)
I think you can use
util.runtime.requestUpdateMonitor({ id, x, y });

SDFTDusername wrote:

3. how do i set the type of a variable monitor via blocks? (like set type to normal readout, large readout and slider) and how do i set the slider min and max? like (set min: 1 max: 10)
util.runtime.requestUpdateMonitor({ id, mode: "default" });
util.runtime.requestUpdateMonitor({ id, mode: "large" });
util.runtime.requestUpdateMonitor({ id, mode: "slider" });

SDFTDusername wrote:

4. how do i set the size of a list monitor via blocks? (like set list size to width: 10 height: 10)
util.runtime.requestUpdateMonitor({ id, width, height });
will updating pos with list also work?

Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

will updating pos with list also work?
Positions of list and variable monitors work the same way.

Last edited by Maximouse (Jan. 6, 2022 12:57:43)



This is Maximouse's signature. Learn more about signatures.
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

when i link scratch-vm and scratch-blocks to scratch-gui, scratch-gui and scratch-vm will build but scratch-blocks wont and doesn't change anything (i did try installing dev scratch-blocks in scratch-blocks and it did give no errors but still appeared as a red hat block)
You need to manually run npm run prepublish and npm run translate (you might need to run the second command twice to prevent red hat blocks) after making changes to scratch-blocks.

SDFTDusername wrote:

god286 wrote:

SDFTDusername wrote:

8. how do i convert a list to json? (like (convert list to json))
I am not sure but I think lists are stored as JSON in the project.json file
They're exactly the same as arrays
so just JSON.stringify(args.list)?
The implementation of the list reporter (scratch-vm/src/blocks/scratch3_data.js, line 93) uses
const list = util.target.lookupOrCreateList(args.LIST.id, args.LIST.name);
and then reads list.value to get the actual array.


This is Maximouse's signature. Learn more about signatures.
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

when i link scratch-vm and scratch-blocks to scratch-gui, scratch-gui and scratch-vm will build but scratch-blocks wont and doesn't change anything (i did try installing dev scratch-blocks in scratch-blocks and it did give no errors but still appeared as a red hat block)
You need to manually run npm run prepublish and npm run translate (you might need to run the second command twice to prevent red hat blocks) after making changes to scratch-blocks..
i tried doing that but didnt work, i also tried doing sudo npm install and using WSL

Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

2. how do i set the position of a variable and list monitor via blocks? (like set variable pos to x: 0 y: 0)
I think you can use
util.runtime.requestUpdateMonitor({ id, x, y });
got this error and dont know what to do

ERROR in ./node_modules/scratch-vm/src/blocks/scratch3_data.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /mnt/c/Users/Gebruiker/Downloads/scratch-mods/mod/scratch-gui/node_modules/scratch-vm/src/blocks/scratch3_data.js: Unexpected token, expected “,” (98:41)

96 |
97 | setVariablePositionTo (args) {
> 98 | util.runtime.requestUpdateMonitor({args.VARIABLE.id, args.X, args.Y });
| ^
99 | }

Last edited by SDFTDusername (Jan. 6, 2022 13:16:56)


Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

Maximouse wrote:

SDFTDusername wrote:

2. how do i set the position of a variable and list monitor via blocks? (like set variable pos to x: 0 y: 0)
I think you can use
util.runtime.requestUpdateMonitor({ id, x, y });
got this error and dont know what to do

ERROR in ./node_modules/scratch-vm/src/blocks/scratch3_data.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /mnt/c/Users/Gebruiker/Downloads/scratch-mods/mod/scratch-gui/node_modules/scratch-vm/src/blocks/scratch3_data.js: Unexpected token, expected “,” (98:41)

96 |
97 | setVariablePositionTo (args) {
> 98 | util.runtime.requestUpdateMonitor({args.VARIABLE.id, args.X, args.Y });
| ^
99 | }
{id: args.VARIABLE.id, x: args.X, y: args.Y }
is the right syntax for the object in this case.


This is Maximouse's signature. Learn more about signatures.
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

Maximouse wrote:

SDFTDusername wrote:

2. how do i set the position of a variable and list monitor via blocks? (like set variable pos to x: 0 y: 0)
I think you can use
util.runtime.requestUpdateMonitor({ id, x, y });
got this error and dont know what to do

ERROR in ./node_modules/scratch-vm/src/blocks/scratch3_data.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /mnt/c/Users/Gebruiker/Downloads/scratch-mods/mod/scratch-gui/node_modules/scratch-vm/src/blocks/scratch3_data.js: Unexpected token, expected “,” (98:41)

96 |
97 | setVariablePositionTo (args) {
> 98 | util.runtime.requestUpdateMonitor({args.VARIABLE.id, args.X, args.Y });
| ^
99 | }
{id: args.VARIABLE.id, x: args.X, y: args.Y }
is the right syntax for the object in this case.
it doesn't seem to do any errors on build but when i test the block this error happens:
Uncaught TypeError: monitor.get is not a function
at Runtime.requestUpdateMonitor (lib.min.js:304234:24)
at Scratch3DataBlocks.setVariablePositionTo (lib.min.js:295190:20)
at execute (lib.min.js:301331:34)
at Sequencer.stepThread (lib.min.js:305297:11)
at Sequencer.stepThreads (lib.min.js:305203:18)
at Runtime._step (lib.min.js:303919:40)
at lib.min.js:304573:16

Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

Maximouse wrote:

{id: args.VARIABLE.id, x: args.X, y: args.Y }
is the right syntax for the object in this case.
it doesn't seem to do any errors on build but when i test the block this error happens:
Uncaught TypeError: monitor.get is not a function
at Runtime.requestUpdateMonitor (lib.min.js:304234:24)
at Scratch3DataBlocks.setVariablePositionTo (lib.min.js:295190:20)
at execute (lib.min.js:301331:34)
at Sequencer.stepThread (lib.min.js:305297:11)
at Sequencer.stepThreads (lib.min.js:305203:18)
at Runtime._step (lib.min.js:303919:40)
at lib.min.js:304573:16
Looks like the function excepts a Map.
new Map({id: args.VARIABLE.id, x: args.X, y: args.Y })


This is Maximouse's signature. Learn more about signatures.
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

Maximouse wrote:

{id: args.VARIABLE.id, x: args.X, y: args.Y }
is the right syntax for the object in this case.
it doesn't seem to do any errors on build but when i test the block this error happens:
Uncaught TypeError: monitor.get is not a function
at Runtime.requestUpdateMonitor (lib.min.js:304234:24)
at Scratch3DataBlocks.setVariablePositionTo (lib.min.js:295190:20)
at execute (lib.min.js:301331:34)
at Sequencer.stepThread (lib.min.js:305297:11)
at Sequencer.stepThreads (lib.min.js:305203:18)
at Runtime._step (lib.min.js:303919:40)
at lib.min.js:304573:16
Looks like the function excepts a Map.
new Map({id: args.VARIABLE.id, x: args.X, y: args.Y })
i tried this code
this.runtime.requestUpdateMonitor(new Map({id: args.VARIABLE.id, x: args.X, y: args.Y }));
but it returns
Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
at new Map (<anonymous>)
at Scratch3DataBlocks.setVariablePositionTo (lib.min.js:295190:41)
at execute (lib.min.js:301331:34)
at Sequencer.stepThread (lib.min.js:305297:11)
at Sequencer.stepThreads (lib.min.js:305203:18)
at Runtime._step (lib.min.js:303919:40)
at lib.min.js:304573:16

Last edited by SDFTDusername (Jan. 6, 2022 14:35:11)


Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

i tried this code
this.runtime.requestUpdateMonitor(new Map({id: args.VARIABLE.id, x: args.X, y: args.Y }));
but it returns
Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
at new Map (<anonymous>)
at Scratch3DataBlocks.setVariablePositionTo (lib.min.js:295190:41)
at execute (lib.min.js:301331:34)
at Sequencer.stepThread (lib.min.js:305297:11)
at Sequencer.stepThreads (lib.min.js:305203:18)
at Runtime._step (lib.min.js:303919:40)
at lib.min.js:304573:16
I think Map needs to be imported from the “immutable” library first.


This is Maximouse's signature. Learn more about signatures.
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

i tried this code
this.runtime.requestUpdateMonitor(new Map({id: args.VARIABLE.id, x: args.X, y: args.Y }));
but it returns
Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
at new Map (<anonymous>)
at Scratch3DataBlocks.setVariablePositionTo (lib.min.js:295190:41)
at execute (lib.min.js:301331:34)
at Sequencer.stepThread (lib.min.js:305297:11)
at Sequencer.stepThreads (lib.min.js:305203:18)
at Runtime._step (lib.min.js:303919:40)
at lib.min.js:304573:16
I think Map needs to be imported from the “immutable” library first.
not sure what you mean, how do i import the library?

Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)
Maximouse
Scratcher
1000+ posts

need help with a mod!

SDFTDusername wrote:

not sure what you mean, how do i import the library?
Something like
const {Map} = require("immutable");
at the top of the file, then use it like this:
this.runtime.requestUpdateMonitor(Map({id: args.VARIABLE.id, x: args.X, y: args.Y }));


This is Maximouse's signature. Learn more about signatures.
kccuber
Scratcher
1000+ posts

need help with a mod!

maximouse, they are editing the scratch vm in node_modules which may be the issue


Made using Nord Theme & Inkscape
SDFTDusername
Scratcher
42 posts

need help with a mod!

Maximouse wrote:

SDFTDusername wrote:

not sure what you mean, how do i import the library?
Something like
const {Map} = require("immutable");
at the top of the file, then use it like this:
this.runtime.requestUpdateMonitor(Map({id: args.VARIABLE.id, x: args.X, y: args.Y }));
it does seem to work and do no errors but when testing block it still doesn't do anything, no errors on runtime and build
i have put
const {Map} = require("immutable");
after
const Cast = require('../util/cast');
(const map is on line 2)

Last edited by SDFTDusername (Jan. 7, 2022 09:07:14)


Scratch mod
https://scratchmod.netlify.app/ - the Scratch mod with many blocks and stuff
soon it will change into a TurboWarp mod with even more blocks and stuff

scroll down for more info!

plans:
189 new blocks
6 new features
4 useful changes
3 new extensions
50 new extension blocks

development:
0/2 ready up the mod: setup and test (0%)
0/189 new blocks done (0%)
0/6 new features done (0%)
0/4 useful changes done (0%)
0/3 new extensions done (0%)
0/50 new extension blocks done (0%)

total: 0/250 (0%)

Powered by DjangoBB