Hopscript: Hopscotch Text Language (Concept)

Yeah, I just made a new project just to test that because it was working just close enough to correctly to make me think I was just crazy, but itā€™s definitely broken:

It doesnā€™t even work when they are in the exact same place

Luckily this is the perfect reason to test out the debugger, so itā€™s actually good that I have some reason to use it without having to make some huge project quite yet

2 Likes

Woah, I specified the starting postion of both objects as starting in the same place and it works correcttly now.

It even correctly identifies no overlap.

So I wonder if the problem comes from non-integer starting positions, and the ios app doing something different around the first frrame fixes that

1 Like

Is Polar Bear by Petrichor working or is it not loading for you too?

If it does load, does the background turn blue when the squares overlap? If it doesnā€™t then my thing works correctly, itā€™s just correctly bugged

1 Like

In JS, numbers go up to 17 digits of precision, and then it starts bugging out. So maybe it has to do with that?

Hmm, I tried opening it in my browser, and it doesnā€™t want to play at all. Interestingly, it throws a console error because thereā€™s no variable named main:

// Uncaught ReferenceError: main is not defined

function playHandler(event) {
  if (event) {
    event.stopPropagation();
    event.preventDefault();
  }
  if (!project_screenshot || !main) return false; // <---- error here
  project_screenshot.remove();
  // ...

Not really sure what that means, but judging by the variable names in the loop, I guess it has to do with the project thumbnail?

To me it was not loading the player because of missing cors headers lol

main is the instance of HSMain that plays the project

Hm, yeah, in both browsers, it initially fails to load because of CORSā€¦

image

1 Like

I figured it out, i had misread the minified code for activating conditional rules. Instead of

if (rule.conditionIsTrue(ruleGroup)) {
            if (!rule.hasBlocksToExecute())
                rule.isActive = false
			rule.activate()
		}

I had

if (rule.conditionIsTrue(ruleGroup) && !rule.hasBlocksToExecute()) {
        rule.isActive = false
		rule.activate()
	}
1 Like

What should I use to represent this block:
image
Right now I am thinking of change_scene(to: Next_scene) but that is not very intuitive I think, but I canā€™t really think of anything else better.

Itā€™s quite a weird block in the actual app editor too, the next and previous scene keys are the same shape/color/group as the keys for each individual scene.

2 Likes

I think I settled on something like this:

Scene first_scene:
	text text(x_position: 512, y_position: 384, text: "This is the first scene"):
		When is_tapped(Screen):
			change_scene(to: Scenes.Next)

Scene second_scene:
	text text_2(x_position: 512, y_position: 384, text: "this is the second scene"):
		When is_tapped(Screen):
			change_scene(to: Scenes.Previous)
			change_scene(to: Scenes.first_scene)

because it is more consistent ways to refer to variables (Game.variable_name etc.) and easier to implement. I donā€™t really like how different from hopscotch it is though.

4 Likes

oops lol i think thatā€™s a discourse bug

4 Likes

Awesome!! Iā€™ll check it out :)

To be honest, I have to learn the JSON format more in-depth still, but I will try to gain an understanding of this codebase when I get the time.

That sounds like a huge refactor, but it would be really amazing in the long run for sure.

That is such a massive lifesaver actually lol

3 Likes

One of the things I hope to do by april is to start on a typescript library to make it easier to interact with the project json and use that for the big refactor Iā€™m planning.

If you were to use something like that, how would you want it to look like? Ideally it wouldnā€™t require very in-depth knowledge of the specific internal structure of the project to do simple things.

3 Likes

That depends. Are you thinking about making a middleware lib that works kind of like a backend for AEā€™s Project Explorer? Or is it even lower level than that?

I think either way, it would be really nice to have a lower-level API like that, which could be applied to both the development of other custom codegen tools, as well as Hopscript. :)

If you write it in something like C or Rust, that would be even more of a bonus so I could write my own native frontend from that lib! IDK if itā€™s worth dealing with interop though, or the learning curve for that if you donā€™t know those languages.

Iā€™m gonna have to take a look at this much closer before I can give more specific advice tho.

2 Likes

git is so so nice compared to 7 drafts of slightly different names :P

i should go look at the repo first, after though iā€™m happy to give ideas and discuss, this is a cool project

1 Like

My biggest struggle has always been project updates - (unless they added drafts for uploaded projects and I missed that), you can only work in small patches at a time and thatā€™s really tough

1 Like

yeah thatā€™s a source of frustration for me too - could be something to mention for hopscotch in general in rodrigoā€™s idea requests topic

both sound great, and i like the idea of some api tools to interface with personal codegen projects

1 Like

Iā€™m thinking mostly a library to make working with hopscotch projects easier, so something (ie hopscript) would interface with this library to create a hopscotch project, sort of like:

let project = HSProject()
let scene = project.addScene(named: "Scene 1")
let object = scene.addObject(named: "Spooky gorilla", type: .frankenrilla, xPosition: 100, yPosition: 200)
// Add code to the object, add more objects, etc.
...
print(project.jsonify()

so a library to make dealing with hopscotch json easier, instead of having to reimpliment a whole bunch of that functionality in every project.

Yeah, I originally wanted to make something like this in swift, but because I want to use it for hopscript which I eventually want to be usable from the web I figured itā€™d be easiest to make it in typescript.

Do you have any specific ideas of what you would want to be able to do with it? Ideally the most common tasks would be pretty easy and simple to get done

3 Likes

pretty much what you just described, library bridging the gap between hopscotchā€™s json and exterior programs, with either hopscript or userā€™s choice as the frontend.

for specific ideas, support for secret blocks, and perhaps operations that normally wouldnā€™t be possible in the hopscotch ui but still work internally? (unsure of a good example, perhaps complex conditionals like when is pressed and 7=7? if the handler for those doesnā€™t like that then itā€™s not an issue :)

essentially tools to get as much out of hopscotch that we can, especially that which is hard to work with in the native editor

2 Likes

Yes, you would definitely be able to do whatever is possible. Youā€™d be able to use any block id anywhere, even if ti wouldnā€™t actually do anything in the app ā€“ actual usable blocks, secret blocks, nonexistent/modded blocks, etc. Obviously it would provide an enum or something similar with a collection of known ids, but if you want to do something else you can. Specifically in my hopscript implementation the actual blocks are defined in hopscript code so being able to use arbitrary block ids is essential for even the very first use case.

I donā€™t think that when is pressed and 7=7 would work, as far as i know is pressed isnā€™t a boolean, itā€™s specifically activated when a press is detected.

2 Likes

If you want it to be native, you could look into WebAssembly! It lets you compile your native code into a virtual machine that works across browsers.

I want to make different tools for Hopscotch games. Level editors, animation editors, stuff like that. HSAPI would make development on these things trememdously easier. :D

So for example, I could add Tiled support into Hopscotch using the API if I wanted to! Breaking out of the confines of the Hopscotch editor itself would be massive for the work I dream of making.

2 Likes