Alright, here we go: Dictionary lists!
In programming (for those of you who don't know) dictionaries are lists with "keys" and "values". Each value is obtained by using its key. For example,
Foo: Bar
Hello: World
My dictionary has the value "Bar" at the key "Foo". You can also use numerical keys, like so: (this would help with backwards-compatibility)
1: Foo
2: Bar
3: Baz
Now "Baz" is at "3" and "Foo" at "1". So how would this help? I've come up with a few examples.
1. RPG-like inventories
Users could create inventories with keys being the items and values the quantities, like this: (click to enlarge)
2. Lists of unique strings with prices, data, etc.
Users could create lists of unique strings (the keys) with data (such as prices) as the values. For example, here is a small receipt program (in which I spelled receipt wrong):
Note: the reason I have code is because these examples are real, live, working code in a mod.
No more searching/looping through lists to find an item! Just use its key!
New users also wouldn't have to use this functionality as they can use purely numeric keys.
Last edited by nXIII (2010-08-30 21:22:34)
Offline
WHEN IS THE MOD RELEASED?!?
Maybe if Panther becomes stable enough, we can use this for Armour RPG...
Offline
Cool, but you could probably just use 2 lists
Last edited by Lucario621 (2010-08-30 19:10:13)
Offline
Interesting idea! It's really confusing, though - I don't think new users would understand that well.
Besides, what I do right now to achieve the same effect is to use two lists; one for indexing and another for the actual list content. It's not that hard, and it's simple enough for new users to understand.
Offline
GREAT idea. I can see so many uses! Although, I do agree with coolstuff on that.
Offline
Offline
omg you have NO idea how many times I've wanted this. Actually, this should be pretty easy to implement in my private mod... *starts hacking*
Last edited by rubiks_cube_guy238 (2010-09-01 20:23:18)
Offline
Harakou wrote:
Correct me if I'm wrong, but isn't this a list with the ability to have strings as indices?
Yep. That's pretty much it!
Offline
ScratchReallyROCKS wrote:
Harakou wrote:
Correct me if I'm wrong, but isn't this a list with the ability to have strings as indices?
Yep. That's pretty much it!
![]()
In that case, while I don't see a whole lot of use for this, it could be rather useful and make projects using this sort of system easier. So I give my support.
Offline
Harakou wrote:
ScratchReallyROCKS wrote:
Harakou wrote:
Correct me if I'm wrong, but isn't this a list with the ability to have strings as indices?
Yep. That's pretty much it!
![]()
In that case, while I don't see a whole lot of use for this, it could be rather useful and make projects using this sort of system easier. So I give my support.
![]()
It'd be perfect for cryptography, like saving passwords in an OS. You could have a cell labeled 'a' and it's value would be 'b' so that in a string to be encoded, you could find the value in the dictionary list for each letter.
Offline
To be honest, I really want 2 dimensional arrays in Scratch, which would be slightly more helpful than this though...
Offline
shadow_7283 wrote:
To be honest, I really want 2 dimensional arrays in Scratch, which would be slightly more helpful than this though...
Yes, but it is possible to make a list act like a 2-dimensional array.
Anyways, all you have to really do to allow dictionary lists is turn the cellMorphs variable in ScratchListMorphs into a dictionary instead of an orderedcollection.
Last edited by rubiks_cube_guy238 (2010-09-02 07:32:06)
Offline
This idea looks like it would be right at home in BYOB.
( I hate the)
60 second rule!
60 second rule
60 second rul
60 second ru
60 second r
60 second
60 secon
60 seco
60 sec
60 se
60 s
60
6
Offline
Do you have the changes? Can you post them?
Offline
rubiks_cube_guy238 wrote:
shadow_7283 wrote:
To be honest, I really want 2 dimensional arrays in Scratch, which would be slightly more helpful than this though...
Yes, but it is possible to make a list act like a 2-dimensional array.
Anyways, all you have to really do to allow dictionary lists is turn the cellMorphs variable in ScratchListMorphs into a dictionary instead of an orderedcollection.
Yes, and then add support for that with numberMorphs (have to be completely redone) and all the ops need to be changed and some added, and you need to do a bunch of other thing I forgot...
Oh, yea: you need to make it backwards-compatible. I did this by automatically decrementing numerical indices (above n) when you delete one.
Offline
oh whattheheck, i'm not going to bother doing the hacking. i've tried several times, and its just not working out for me.can you just post the entire class somehow?
Last edited by rubiks_cube_guy238 (2010-09-02 21:05:18)
Offline
Harakou wrote:
ScratchReallyROCKS wrote:
[offtopic]I just noticed, that is a very odd shopping list
![]()
Uh, 800 computers?
I could really use that.
Offline