Arrays/Lists/Collections in Hopscotch

I would use lists (especially a 2D list) to store different colors, text, and more…

Would also be more code efficient depending on how they are used…

2 Likes

WHY
There have been a few projects where arrays could be helpful. Such as storing positions of different positions of spaces in a grid
WHAT
It could have add to array, set array and remove from array blocks. You could also be able to loop through arrays
WHERE
It could be its own tab or in the variables tab
MORE USES

  • Level design (loop through array and add a specific block based on what’s in the array)
  • Easier way to store positions
  • Store UI
  • Put any other ideas below
    @omtl
9 Likes

it’s like:

var array = [1, 2, 3];

and you access items in the array like array[0] (which would equal 1)

2 Likes

Lists are a more general term. You can usually use them interchangeably. Lists are usually implemented with arrays (not always though. Linked lists are not, for example.)

1 Like

How did I not see this topic lol it was literally posted in 30 mins ago

it was just merged with your topic, which makes it seem like it was posted in 30 minutes ago

1 Like

Arrays would generally in their own category called “Lists” which could, in theory, be placed right next to the variables tab. A lot of new variables like “item in list,” would also be needed to make it all work. Blocks like “Remove from List/Array” and “Add to List/Array” would also make this very useful…

If this gets added eventually, I cannot wait to see what kinds of awesome things people make using them…

1 Like

Everything that would be useful with Arrays/Lists/Collections:

  • Multi-Color Storage
  • Multi-Text Stoarge
  • Instruction Register
  • Saved Levels
  • Advanced Encoders and Decoders

All lot of these are already possible with what we currently have, but arrays would make the process a lot faster…

Oooh cool. I like arrays.[quote=“AwesomeOnion, post:1, topic:53136, full:true”]
This might be something we’ll try in the beta editor, but no guarantees on when that will be.

One reason we haven’t implemented a collection type in Hopscotch is that for it to be useful, I think you’d need a lot of built-in functionality. This would clutter up the editor for more beginner users.

In the comments can you give specific examples of what you’d use collections for? That will help me think about what they would enable.

Also, feel free to shout out ideas about what to call them!

Again, this is not on the roadmap yet, it’s strictly exploratory :slight_smile:
[/quote]

1 Like

A feature I’d like to see in Hopscotch is:

Lists

I’d use it for this type of project:

Anything that uses lists

Here are some examples of Hopscotch code that could be improved if we had this:

My word search generator

Here is an example design I’ve made:

I’ve seen something similar in another programming languages, it looks like this:

Append(1, list)
List[1]
ReplaceAtPos[text,2,list]
And so on.

14 Likes

Hi, Mathematics2, welcome to the forum.

You might remember me. I’m Crosbyman64 (the Crosbyman64).

I used Scratch before so I definitely know what you’re talking about.

8 Likes

Hi @Mathematics2! Welcome to the forum!

I think that this is a great suggestion and I can think of lots of uses for lists!

7 Likes

I can think of a couple:

  1. Much faster tile finding system (in terms of platformers). It would be convenient to just do item # of (item) instead of having to check all indexes to find what you’re looking for

  2. Data Strings in general (and Awesome_E would agree with me on this one).

5 Likes

I know right! Lists are possible right now but they are all hard to see or in my lists case slow. I hope it’s added soon. That will really help!

5 Likes

I just noticed you typed your name as Mathamatics2 instead of Mathematics2… clever…

2 Likes

If it does get added, it’ll most likely be added as arrays, as I found them to be more useful than lists.

In terms of Python, arrays can handle mathematical operations whereas lists cannot, and they can store data very compactly. The only downside is that arrays need to be declared, which is to be expected anyways. As variables in hopscotch need to be declared, and lists also need to be declared in scratch.

Q: What is an array?
A: An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number.
It’s basically the superior version of lists.

Imagine if you could declare an array simply by inputting values separated by commas, I would definitely make that one way of declaring them because then I could just type in all the values and instantly have an array (I would also make a duplicate as a variable to return the entire string for copying purposes).

i.e., set array (list) to (127,255,192,64) = list=(i[127,255,192,64]) //this is referencing python in a way

2 Likes

In WolframLagige it’s “list={1,”this is a list!”,3}

2 Likes

And yes that’s what it’s called silly me.:man_shrugging:

1 Like

Thank you for noticing that. I fixed it.

1 Like

Welcome to the forum!

2 Likes