# Hopscotch Suggestions: Lists, Ability Arguments, and strings!

#1

Hey guys! I've always thought there were 3 main things that hopscotch is missing, so I thought I would put them together into a suggestion thread!
First off,

## Lists

This is a pretty simple one that I am sure has been suggested before.
We have values already and they are some of the most useful tools we have. But, what if we added in a way to store A LOT of values? Lists!
How lists work is instead of defining one value:
Score = 10
You can define multiple values in the same variable!
Score = {1,2,3,4,5,6,7,8,9,10}

### Why is this useful

A lot of reasons! The list would be too big to go through, so I'll just do a few examples.
You are making a game, let's say flappy bird. Every time you die you insert the persons score into a list.
Then when they start the game again you take the highest element in the list and display it next to "Best: "
So, if your best score was 10 it would say "Best: 10"

And what if you are creating a game with a board, such as tic tac toe? To save the state of each square you currently have to go:

``````set value firstsquare to 0
set value secondsquare to 0
set value thirdsquare to 0
...``````

Which is a complete waste of time. What if you could go like this:
Board = {0,0,0,0,0,0,0,0}
And when someone touches just do

``Set value List element SquareTouched to 1``

There are an infinite number of possibilites with Lists.
Here is a picture of what the syntax for some list functions might look like:

Note, saying

``Remove 5  from List``

Is saying remove element 5 from List.

## Ability Arguments!

Currently we have abilities which are great for copying code from one character to another, but, what if we allowed those abilities to take arguements?
What this means is that we can define a new ability like this:

`````` NewAbility(number)
Set Text to Number``````

And then use it like this:

``NewAbility(2)``

Which would execute the following code:

`` Set Text to 2``

Basically what we are doing is passing the ability "NewAbility" a value which it can then do stuff with.

### Why is this useful?

Again, a lot of reasons.
Say we want to make an ability to make a square of a custom side length.
Currently we can't make an ability for it because the ability will always make it of the same length.
With this we can go:
``````NewAbilityForSquare(len)
Repeat times 4:
Move forward with trail distance len
Turn 90 degrees``````

And then use it like:

`` NewAbilityForSquare(100)``

Would create a square with each side length 100.

And finally,

## Strings!

We have support for numbers in values, but what about text?
This suggestion just adds in support for text values, inputs, and a string library.

So, lets start out small. Text values. These would work just like normal values.

``````Set value text to "ExampleText"
Set text to text``````

Would set the text to "ExampleText"

Now, here is the fun part.

### Inputs!

Here is some example code:
``Set Value Text to input()``

(I put () by input to show it is a function)
What this code would do it make the text box editable while in the game, and once you hit done it would save whatever you typed into the variable "Text"

Now, we have strings, but what do we do with them?
Something!

If we are to implement strings, we need functions to do things with them!
Here are a few I think we need (Function names come from Lua):
String sub:
This just takes a substring of whatever string you pass it.
For example:

``String sub "test" 1,1``

Would return the first character of "test" which is "t"

String gsub
This replaces all instances of a substring with another
For example:

``String gsub "I am a banana", "banana", "Hopscotcher"``

Would replace all instances of "banana" in "I am banana" with "Hopscotcher"
So the above code would return "I am a Hopscotcher"

String length
Pretty self explanatory, returns the length of a string

String lower/upper
String lower would return the string but all in lowercase, upper would return the string but all in uppercase.

πππ official Hopscotch update ideas topic πππ
Factorial fΟnction and combinations fΟnction
#2

Great suggestions! I love the way you used this feature:

``I did not know what I could use this for``

But now I see it's useful for code

#3

Something I would really like to see is a repeat until block, because than it would be a lot more easier to stop the animation after you finished the game, or after you went to another page.

#4

@Jootje There are ways of doing "Repeat Until" or While loops and I made a project about it. Here's the link to the project on Repeat Until.

The way by me though (the second way) might crash your iPad when you are looking at the code unfortunately though it used to work fine

#5

While there are ways of doing while loops and repeat until statements, I think it still would be a good addition, just to make it simpler, because for a lot of things there is a way to "hack" it in, but making it an actual feature would make it easier for newer coders, since they might not know how to hack it in.

Also, Jootje, I think you should definitely make a thread about your ideas. Elaborate a little on why you want while/repeat until blocks and the Hopscotch team have a way better chance of adding it in

#6

Yeah @BuildASnowman it would be useful but for now at least you can hack it in

And speaking of elaborating on and showing your ideas, I love the way you showed yours! How did you add the text and shapes to represent the new block designs?

#7

I was thinking, instead of writing a ton of rules, you could have an or block.

#8

Like random or plus/minus

#9

@BuildASnowman How did you get those blocks in the picture? Like the list element 5 block?

#10

I used photoshop CS2, took 2 sample pictures of hopsctoch code and selected a red block. I then used the the brush to clear off the text. Then I chose a font near what Hopscotches font is and put in the text on the custom blocks, and then stretched the block to fit my needs. Then the tedious part was everything was all jagged and lumpy at the top, so I had to carefully select a line with the rectangular marquee and fill it with the correct block color. I then used the magic wand tool (Tolerance 64) to select a blank bubble and copy and paste it. on my custom block. Then I just copy pasted the block onto my other sample picture and removed the white background using a series of magic wand selections.

#11

@BuildASnowman that is so smart! I thought it was a block that only some have but now I realize it! That's so clever!

#12

I know this is from almost a year ago, but could I either make a new topic about this subject or revive this? Because I want to make a list of suggestions and actually show them to THT. I was thinking that I could make a topic with a list of suggestions and turn on Global Edit so everyone could add ideas, then show the list to THT. Is this ok @BuildASnowman, or can we revive this topic?

#22

This is sorta off topic, but can I use the picture to compare to the new update

I sorta miss the old one so ya

#24

Um @BuildASnowman? Sorry I just know that your active right now can you please look at my previous post?

#25

Sorry! I have a lot of my old topics on mute - I wasn't getting notifications

This is absolutely fine! Go ahead and copy whatever you want from this topic

#26

cloud values-everyone can change this value by doing something in the game
convert to binary-converts text to binary
translate from binary to text-turns binary into text

#27

Thank you so much!

#28

Why would you need binary? Just curious, I don't really see a use for it in games.

#29

because we can
i want cloud values to be only numbers(like scratch)

#30

Inputs would be the best! I've always wanted them ever since I used it in Python. You come up with the best ideas!