Are Arrays Global?
-
@Deeeds For now, I wouldn’t worry about the Value behaviour, you can try figure that out in your other post lol, because been I don’t really get the point of having Value behaviour versus Box Container. A box container literally just stores a bunch of text, that’s it. You can extract the text, or change it using set input field (or even dragging a behaviour output into it). Any object can get or set any array (by getting it as text, then using it in modify array or get array value behaviours) as long as you’ve given the object a way to access it.
-
@Aidan-Oxley Please stop talking about arrays as text. This is not what they are.
And it's certainly not all that they are.
Take a moment to go look up what arrays are, under the hood.
Or, if you'd like, I can have a crack at explaining them in plain english.
-
@Deeeds I’m talking about hyperPad arrays. I’ve used them, as text. The text is obviously useless unless you use a behaviour to look at the array. I can make a behaviour attempt to get the array “hello”, and it will probably just output nothing because the text is is the wrong format. If an array isn’t just a bunch of text, why can I set a label to an array, have another object get the label’s text, and then use that in array behaviours?
-
@Deeeds - yes please, could you explain Arrays in a different way? They fascinate me but never been able to use them since I do not entirely understand what they are and more important “how, where and when” to use them.
Thank you! -
@Aidan-Oxley Because that's the way you're using an array, as a string store. But that's not what an array is, that's one of the ways it can be used.
-
Here’s an array, it’s storing a whole heap of stuff:
["66","["0","12","8"]","["0","12","16"]","["0","20","8"]","["0","20","16"]","["3","24","12","8","12"]","["3","8","12","24","12"]","["3","8","4","24","20"]","["3","24","4","8","20"]","["3","8","20","24","4"]","["3","24","20","8","4"]","["3","16","20","16","4"]","["3","16","4","16","20"]","["1","8","16"]","["1","20","20"]","["1","12","20"]","["1","24","16"]","["1","24","8"]","["1","20","4"]","["1","12","4"]","["1","8","8"]","["2","16","8"]","["2","12","12"]","["2","20","12"]","["2","16","16"]","["2","16","12"]"]
I can paste this into a Get Array Value behaviour, and it will find values in there. -
@Aidan-Oxley This is a string representation of the contents of an array. Not the array itself. Everything there is a string, including the [brackets]
-
@CAnesia Do you have any programming experience outside of hyperPad?
And how much knowledge of the internals of a computer do you have?
CPU, RAM, HDD... bits, bytes... etc??
-
@Deeeds Yes. That string is what the array looks like. You can use behaviours to extract the values from it. Value with index 0 is 66 in the above array. Value with index 1 is another array [“0”,”12”,”8”]. As long as an object has access to one of these strings of text, it can interact with that array.
-
@Deeeds I have no programming experience (other than things like Scratch and GameMaker) outside hyperPad, I partly know what my computer components do but I don’t know how they work. EDIT: Oops, I replied to a comment directed at CAnesia.
-
@Deeeds - Hardware understanding sure, I was selling computers and repair them in my 20’s.
Programming some, hobby levels. I still look at programmers as “wizards” and used some of: VBA, LiveCode, Arduino some Lisp and tried Lua for a while beside hyperPad... still can not understand Arrays and never actually implemented them or actually use them.
So please give it a try, maybe I’ll get them ... -
@Aidan-Oxley @CAnesia asked for an explanation, so I was asking for a base point of understanding.
But it's amazing to learn that about you. You've come a long way inside hyperPad and GamePress!!!
-
@CAnesia @Deeeds Will probably tell you something different, but here’s what I know about arrays:
As far as I know, an array in hyperPad is a string of text in a specific format that stores multiple values. This is useful for times when you want to store multiple values at once, for one example you can broadcast a message with a single value in it, or you can broadcast an array with multiple values, some random example array: [“1”,”2”,”3”,], so that is 3 values (1,2,3) in one string of text. Using Get Array Value on that string of text with index set to 0 will output 1, index 1 outputs 2, and index 2 outputs 3.
And because of how the format works, maybe you could see that you can have an array inside an array (so Get Array Value at it’s index will output another array that you can use). That example in my previous comment, the big array, stores an entire level for a game, the objects in the level and where they are positioned. -
I’m explaining more how to use an array, not what one is.
-
@CAnesia @Aidan-Oxley
Arrays: In English... Part 1!
Imagine a road that goes forever over a flat plain. and there’s nothing there. Kind of like SimCity before you build anything. Just a huge expanse of nothing, with a road through it.
That’s unused memory.
Where we put things along that road is going to have an address. You’re the first person in this new land, so you build a house somewhere along this road, and number it:
Number 1, Memory Road,
Your friends come visit and they like your house. And the road. And the empty wasteland around it.
So you give them the plans to your house, and the same amount of land as you have, and they all build houses, one after another, along the road, straight up from your place.
They’re address numbers 2 through 16 along this road. Their houses are slightly different and their BBQ’s each very different, and they all buy furniture you don't understand and eat weirdly, but the amount of land they use up is all the same. Kind of like a modern gated community.
Capitalism bringing us the conformity of communism without the social protections. Yippee.
Because each house has its own number, and is exactly the same size, the newspaper delivery boy can ride past on his bike each morning, simply reaching into his basket and throwing papers into the yards of each house without thinking.
It's SUPER simple for him. He rides at the same rate, pretty much looks straight ahead, and just reaches into the basket at a regular rate and throws a paper over his shoulder into each yard. Without thinking.
Whilst singing out-loud, with headphones on. "You're gonna hear me Rooooaaaaar....."
EASY! Even a moron can do it.
The newspaper delivery boy loves this route because it’s the easiest 16 houses. Straight line, no thinking, just throw the papers at a regular rate whilst coasting at a regular speed on his bike.
This is how computers see arrays. They LOVE them.
-
@Aidan-Oxley
I need both explanations and your post described good enough for me to at least understand when to use it ... Thanks! -
@Deeeds
Yay! A very nice part 1 - one thing I assumed about them and you nailed it: CPU loves them (speed).Am I very wrong if I describe and think of an Array as a Excel sheet? - that is what I have in mind when I read something or hear Array
Looking forward for the part 2
For my curiosity: is clear that you are a “Vizard” and hyperPad is a joke for your level so why are you on hyperPad? Don’t get me wrong I surely appreciate you are a part of it ...
-
@CAnesia said in Are Arrays Global?:
For my curiosity: is clear that you are a “Vizard” and hyperPad is a joke for your level so why are you on hyperPad? Don’t get me wrong I surely appreciate you are a part of it ...
Thank you. You're wrong.
There are many partial answers to this question, none of which, in isolation, lead to a useful or meaningful response.
But one of them is definitely that I'm NOT a "Vizard".
I look like Karl Marx. But much bigger, in every direction, and am prone to far more arrogance and contempt.
I'm fond of telling people that "I'm in marketing", laced with an enormous amount of disdain for myself, and marketing.
It is the best explanation of what I do, and who I am. Particularly if you can grasp that marketing is really about controlling products, more than anything else, because it's a verb.
Game engines and interactivity creativity applications are the next wave of meaningful tools for a fast approaching era where we shrug off the chains of social networking.
To this day, cocos2D-iPhone remains a valid 2D game engine because Apple completely dropped the ball on Sprite Kit.
Chipmunk2D is nowhere near threatened by Box2D, it's vastly superior for most applications. And its founder and creator is a gentleman and a scholar.
HOWEVER... cocos2D-iPhone has a couple of glaring bugs in it, a legacy of its origin and the last of three founders having left before it was sufficiently trailed in the modern era of iOS... wherein Apple made some dramatic changes to underlying systems in order to prepare for their future, which we're in now with the 120fps iPads.
hyperPad is based on cocos2D-iPhone and Chipmunk, but only really glances the surface of what they're capable of.
It is an interesting project, held back by...
-
@Deeeds
I found this post which is great in helping my array understandings, but I really enjoyed your part 1 written previously so please get the part 2 posted ... please!
You can't add an item at index location 5. It's simply impossible. You can't even add one at index 4, because that doesn't yet exist. But you can ~append~ item to the array. This extends out the array adding more space for itself, and makes an extra index. Now your new object is stored at index 4.
And arrays are super sensitive to the order in which things are stored, being absolute sticklers for this detail is both their massive advantage (reliability and predictability) and their short coming, because re-ordering or shuffling an array requires a lot of operations. The order of objects in an array gives it structure and meaning, as you can always be sure that what you want is where you put it, in the order you put everything in, so you can always know what's next... and so can your CPU and memory system.
Modern computers do an enormous amount of "predictive" processing, and iterating over an array (let's say, adding a 10 to every item in an array) is something that they're VERY good at, as they'll quickly figure out the space between each item and that the iteration is happening, and grab whole chunks of the array early, before instructions come in, and start working on them before being explicitly asked, presuming the results are going to be needed.
This is of enormous benefits to games, where every frame requires exactly this sort of operation to move all the objects in a game world.
So if you ever get the chance to use arrays for positions, rotations, interactions, etc... then do. Use them as much as you can.
Thanks!
-
@CAnesia I will. Sorry for the delay.
Have several ideas on where to go next with the road metaphor, but need a moment of inspiration.
There's much to cover with arrays, and they're the most important computing construct for games. Plus they're a bit extra special in hyperPad, because they really do seem to be global.