Blockly(JS library) help needed

144 views
Skip to first unread message

Aliyu

unread,
Oct 24, 2022, 1:13:26 AM10/24/22
to Blockly
I am working on Blockly as part of my final year project .
How can i Use JavaScript to assign values to the block of codes then use JavaScript popups(like the prompt() script) to insert the value into a textbox and return it as a blockly block on the blockly interface instead of drag and drop.
Thank you

Neil Fraser

unread,
Oct 24, 2022, 11:16:48 AM10/24/22
to blo...@googlegroups.com
It would probably help to follow the "Getting started with Blockly" code lab here:
That will get you up to speed on the basics, then we can discuss the more challenging issues in greater detail.

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/1280eb3f-c703-4dcc-a2d7-6bff54f3acb5n%40googlegroups.com.


--

Aliyu

unread,
Oct 24, 2022, 6:09:55 PM10/24/22
to Blockly
Thank you so much Nail Fraser,i will do as instructed and reach back to you 

Aliyu

unread,
Oct 27, 2022, 7:02:16 AM10/27/22
to Blockly
Hello Mr Neil Fraser
I have gone through the https://blocklycodelabs.dev
And also your youtube channel https://youtube.com/channel/UCqUJIvLpseLNdNAzMfJ2XZg
as well as your website https://neil.fraser.name
One of the idea similar to what i want is the link below but a little advance
https://neil.fraser.name/software/Blockly-History/2012-03-13/blockFactory.html
What i want is to create is a value block generator for every single built-in block type
Example:if i have IF block with a value of 1,and a Boolean block with a value of 2,
If i then insert the values '12' together into the input box of the value block generator it will automatically stark or freeze them together on my workspace.

Aliyu

unread,
Oct 31, 2022, 11:20:13 AM10/31/22
to Blockly
Hello Mr Neil Fraser waiting for your response please 

Beka Westberg

unread,
Oct 31, 2022, 12:28:27 PM10/31/22
to blo...@googlegroups.com
Hello,

Could you clarify your idea a bit more? It sounds like you want to have a text input where you type in some numbers, and blocks appear in the workspace, is that correct?

Best wishes,
--Beka

Aliyu

unread,
Oct 31, 2022, 12:57:42 PM10/31/22
to Blockly
Thank you so much for the reply Beka.
Yes this is absolutely what i want,each block will have a default number,so any time i typed in the default numbers in the text input, the blocks should appear stark or freeze together on the workspace based on the order of which number comes first in the text input 

Beka Westberg

unread,
Oct 31, 2022, 6:50:28 PM10/31/22
to blo...@googlegroups.com
Hello!

That would definitely be possible using APIs like Blockly.serialization.blocks.append! But you're probably going to run into some more complex behavioral edge cases that will require some tricky design decisions. E.g. how do you handle blocks that have multiple inputs? So instead I might recommend sticking with Blockly's built-in drag-and-drop UI (even though I know that wasn't the intention of your project).

I hope that gives you some place to start! If you have any further questions please reply =)
--Beka

Aliyu

unread,
Oct 31, 2022, 7:25:14 PM10/31/22
to Blockly
Thanks a million Beka
I will look into the APIs and i will love your help also on listing out all the blocks with multiple inputs so that i will try to see the possibility of  working on the tricky design decisions

Beka Westberg

unread,
Nov 1, 2022, 11:23:47 AM11/1/22
to blo...@googlegroups.com
Hello again =)

You can view all of the built-in blocks by going to the hosted playground. I think ~50% of the blocks have multiple inputs? But you could also design your own block such that they only have one input each. Granted, this would make binary operators (like +, -, *, /, etc) difficult to implement.

Best of luck with your project!
--Beka

Tahir Investment NIG. LTD

unread,
Nov 1, 2022, 11:59:50 AM11/1/22
to blo...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages