This is amazing! Great job @t1_hopscotch
I’m going to try this out later. This looks sweet. Good job @t1_hopscotch!
Wow thanks BuildASnowman You are one of the people I would like to thank! — I learnt from peeking around on the forum seeing what you’ve talked about regarding Hopscotch project JSONs
Hehe, I actually did have more plans that I didn’t mention — I was hoping/dreaming (dreaming, more like) to make something so that you could view the code blocks more easily from a non iOS device (for example, if you’re on a computer, when someone links a project, you might just want to see the blocks which would be enough to help with a problem/question or just see how an aspect works for example, but you can’t do that at the moment).
I actually didn’t think much about an editor (I thought it might be beyond me just at this point ) — I saw @Rawrbear and @K1ish were working on one using GameMaker, but now I think about it, that would be pretty… fun… I’d need to be more familiar with how the blocks/code is arranged in the JSON file, but I think I can sort of see how to try edit the data using Python…
(I recently got to be part of working on a website that uses Python for a server, so having it hosted as a website is a potential possibility… but like I just said, these are just little dreams at the moment but would be very, very fun to try and do )
Ooh thank you Sweetlina; I thought it would be pretty messy and confusing I will still try to clear it up though I think And also, I think it’s lovely that you’re giving encouragement that’s awesome, no matter how old anyone is (also I don’t think ive really mentioned much about my age anyway actually )
Ooh I can go update the instructions (I shouldn’t wait for a good reason, but this is a great one!) And also thanks to you too, @MR.GAM3R — I learnt from seeing you talking about project JSONs around the forum too
I would like to add that like 90% of the code there was searched up basically; really! — it is awesome seeing that you can indeed learn as you go!
That’s really cool X3
That’s very clever. Great work.
I will just jot down a few things here
You can edit this too, you know!
can save project to a file
document more on Hopscotch project JSONs so more Hops can see
possibly, see how going in another language might go
- render blocks in JSON files for viewing??
- edit JSON files??
- Discourse plugin??? so we can view directly on forum (very big dream)
- Does the order of keys in dictionaries matter for Hopscotch reading a JSON file? (In Python, the key order for dictionaries is different every time you start it)
- What does the JSON for code look like if I put more blocks in a project? (e.g. have Ifs and Repeats inside each other, and Draw Trail and so on)
- general idea of structure of JSON file
(this doesn’t really have a purpose — main is just for fun )
- Just for fun!
- So Hops can see more with project JSONs
- Viewing code for projects more conveniently —
e.g. if someone has a question about why some code isn’t working as expected, or if you just want to See Code for a project while viewing in a browser and you don’t have an iOS device with you
- @Rawrbear has ideas for a Hopscotch IDE (integrated development environment) where you can make and edit Hopscotch projects
Organising all these posts I’ve made
(e.g. group together similar/related things, having a list where everything is, updating todo lists maybe — these are not what you have to do; I enjoy doing these too and I can do these myself, it is just if you like doing that sort of thing as well, then go for it )
Styling for the blocks (when it comes to displaying the actual blocks, e.g. making the text for all the Movement blocks red etc. Will probably involve HTML & CSS, you can learn about those!
And of course if you want to try some of the programming, you are most welcome to do so!
And anything that you can dream of. This itself is a dream
Jotting down a few other things… This is more informational.
Again, please feel very free to edit.
A general text description:
get the html from a project url look for <div> tag that has a `data` attribute get the value of that `data` attribute (as a string) convert to an object (or anything that you can manipulate) save the object to a JSON file
Go to project link and right click over the player:
Inspect Element(how to peek behind the scenes of any website, or, in other words, ‘how 2 become L33T H4x0r/a mad hacker’ like in this PyCon (Python conference) talk)
I’m using Safari, but this functionality is common to pretty much most browsers at least. In Safari, I navigated to Elements to see the HTML (hypertext markup language — is code used to make websites and uses
<tags>to wrap around different things)
You’ll find the JSON in the
data=part of a
<div>somewhere, and you’ll see it in a reaally long line:
You can copy and paste that somewhere and try to separate it manually, or the project files that are saved using the program I put above will have that automatically done too. I think some people have text editors that can also collapse things automatically for them, which is very handy (but I don’t have one that does. I have one that colours text so I can see things a little clearer though, it is called Atom.)
I am still exploring this too Some things you might see:
‘Hey, I can see some block names!’ Yep there are the names of the blocks, this is the data for storing the blocks in projects I believe Let’s take a look at some (or one or two).
[I may have to leave this til later, but you can see this is an example for `Grow by 10%` for now]
Anything that is a generated ID will often be a really long sequence of characters. Generally, IDs need to be unique and the longer a string is, the more options you have for naming it.
(For example, if you have a one-letter long name, there are 26 letters in the English alphabet that you can choose for it. But if you extend it to 2 characters, now you have
26*26 = 676 options for names. You can imagine the more characters it becomes, the more options you’ll have. If you have a system that has heaps and heaps of objects, you’ll need pretty unique names.)
Also I think there are probably security reasons too for IDs seeming long and a little random. And there’ll be other reasons too. I’m mentioning this mainly for if you happen to be looking at them and going like ‘why is this so long??’ which would be totally okay by the way
There is a way to put JSON projects back into your Drafts (and get them from your Drafts) using iTunes and connecting your device to a computer. If the editing is valid JSON for a Hopscotch project, the changes will be made in the project too. There are Hops who are more familiar with this (plus the Hopscotch Team too of course :)
I’m not exactly sure how it works in Hopscotch but I just know JSON is a way of storing data generally. This is from a veery limited understanding and my initial aim is just to make this more accessible so please feel very free to correct.
So I’m guessing: the JSON isn’t exactly the project itself, it is a way of storing what is in the project. You store that the user who made the project is t1 (for example) and that these particular blocks are in the project (e.g. Draw Trail, Move Forward 300 etc.) And when the editor opens a project, it looks at these notes (what blocks are in it, in what order, what objects you said were in there, and who made it etc) and then knows what to show or display.
if you start copying and pasting the JSON section for a Grow block or something, and repeat doing that in a row, logically I’m guessing you’ll end up with a whole bunch of Grow By blocks in your project rule, right? Well, you know what, let’s go find that out… coz we can do that (might have to try later though coz I will have to head off for now )
And with the JSON ‘not being the actual project itself’, peeking around, I can see that the filename for a project ends in
.hopscotch, so you can sort of see the JSON specifies more of the contents of a project —the blocks and rules inside it, its objects, its creator etc.
Is this code open source? I’d like to figure out a way to use this in our project, if possible. ^^
Hi Rawrbear! Yes! it is the first link at the very top of the topic that is awesome, (dream would be to work with others) Feel very free to ask about anything
Is Python a web language (meaning you can integrate it into websites)? Don’t know much about it, lol.
That’s so confusing and cool XD
Ahh, thank you so much! I’ll try learning C++ as fast as possible to get the application out sooner (if school isn’t in the way too much).
Yeah, you can import Python plugins into a website! You can also make/run Python PC applications and plugins with it if you install the language. ^^
Oh man - this is exactly what I hoped for when I published my hack. JSON’s are the key to hopscotch, and you are now the gatekeeper
I made a programming language that translates to Hopscotch jsons before, to be able to make projects on my computer. I know quite a bit about the structure of these files - if you ever have a question, don’t hesitate to ask
Yeah you can use Python for a number of things (it is referred to as a ‘general purpose’ programming language)
Wow are you using C++ for the JSON editor that you were working on? haha there’s no rush or anything I see you’re pretty keen about it though! and you must have quite a few things on your plate already too
Wow that’s awesome to hear and wow…
That is really cool!! A programming language, did you say? that is epic; how does it work? And that’s lovely; thank you so much, I think I’ll have quite a few questions already actually I think for the moment they’re things that I can investigate myself first for now (and will probably get a better idea if I look through closely first)
Oh, I have some of my wonderings in one of the posts above, actually I think I just need to get a general idea by peeking around more first.
Steps for starters: (a first edition)
Before you start, this involves installing some things so make sure everyone is okay with that. Also there is probably a risk that things might not work, so just be aware.
This is for the program to get a project URL and save its JSON contents in a folder.
You can download the latest Python 3 (this is made with 3.6.0 I think) which will let you have IDLE on your computer. IDLE is what you can use to run Python programs.
The program I made is using a programming language that is called Python, much like how Hopscotch is a programming language, except it just uses text instead of blocks.
Once you have IDLE installed, open it and make a new file (
File>Newshould do it). Go to the code in the original post, and copy and paste all the code from there into the new file. Then save the file (in a folder where you can find it), with a file name that ends in
.py(you could call it
In the folder where you saved the file, make a new folder inside there and call it
project_data— yep, with underscores and exact case and everything (Python won’t recognise it if you change case or any symbols)
Go back to IDLE and press F5 to run the program that you have open (or go to
Run>Run Moduleat the top menu)
I am expecting that you might run into an error that will probably say something like ‘No module named lxml’ or something like that. That’s because this program uses some code from a library called lxml (line 4):
from lxml import html
and we will need to install it. Installation was quick for me, but yeah I don’t remember what errors might pop up and what I’ve installed beforehand already
5. Find the Terminal shell application for your computer (on Mac, it is the Terminal application; on Windows…tell me if you are using Windows, will have to look it up). And then type in:
pip install lxml
and press Enter. This may take a little while to install.
Then go back to step 4 to run the file again once that’s done.
You will find the project JSON under the
project_data folder that you created earlier (hopefully…)
If you run into other errors, please let me know too, I don’t remember everything that might not work I’m also sorry if things don’t work; maybe I should put this at the start — edit, I will.
We were using GameMaker Language, but it’s not very good for making programs that search for data from currently-obtained local variables stored on your PC/Mac, plus it doesn’t support Apple operating systems very well. I was told to learn and use C++ instead, as it offers solutions to these problems, plus it’s a more common language.
Nope, it’s totally fine! This project seems it would be more fun/successful to develop than other projects I’m currently in the midst of ^^
You know what, I’ll learn Python instead. I haven’t actually touched C++ too much, plus it’ll make embedding your code easier.
I made a GitHub repo just now to store the new project’s code in. Maybe others would be willing to contribute as well
Cool, thanks for the tutorial! :)
Is this like the Hopscotch JSON editor app you were working on a while back?