Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Get list name from a variable?
- NimaiMalle
-
Scratcher
9 posts
Get list name from a variable?
How come I can't do this:

I want to build up the list name in a variable, then access the list. I can't drag a variable into the item…of block, though.
Why wouldn't that be allowed?

I want to build up the list name in a variable, then access the list. I can't drag a variable into the item…of block, though.
Why wouldn't that be allowed?
- drmcw
-
Scratcher
1000+ posts
Get list name from a variable?
because dataTable won't necessarily contain the name of a list.
- NimaiMalle
-
Scratcher
9 posts
Get list name from a variable?
True! But many things in Scratch work just fine without the reference existing. For example, I can access item 1000 from a list that only contains 5 things, but it correctly returns a blank value. Would think this could easily work the same way for variable and list names that don't exist.
I guess this is more of a feature request…
I guess this is more of a feature request…
- MoreGamesNow
-
Scratcher
100+ posts
Get list name from a variable?
Huh, it actually does seem a little counter-intuitive that that wouldn't work in Scratch. I mean, you can call a costume by its name. I guess an answer (if it was a conscious decision) might be that calling variables through other variable's values can't really be done in most languages (for you sticklers out there, there's lots of languages that don't use pointers :p)
- daylight32
-
Scratcher
3 posts
Get list name from a variable?
it's a much needed feature, to use a variable to give a list name. just like you can with a costume. currently you have to write a huge stack of if-elses every time you need to use logic to select a list, if you have many diff lists. i have 15 or so that i need to access variably.
Last edited by daylight32 (Dec. 4, 2018 01:06:38)
- Artanail_Lazentujin
-
New Scratcher
4 posts
Get list name from a variable?
is there a place where I can support this being added as a feature? has it been suggested somewhere or something? after a battle for an rpg thing ive got, the only way the HP value can be updated to the masterlists ( each character has their own list of their stats and whatnot), ive got to do the whole
if list of current playernames contains “sally”
update this stuff in sally masterlist
if list of current Playernames contains “mike”
update this stuff in mike masterlist
ect
it would be GREAT if i could do :
__Repeat until {(index) > current playernames}______
|
| update the stuff in (index) of playernames of masterlist
| change (index) by 1
^
<_________
Where index would start at 0 guess
and player names is at 4 names/items
, And “1” of playernames would be “Sally”
and the masterlist named “Sally” would be referenced and updated due to item 1 of player names ALSO being Sally.
then ide need one little piece of code that works for every single player, and when i need to add a NEW plyer, i dont have to add to the everygrowing 5 or so stacks it takes for me to work around NOT having this :'(/
if i CANT reference a list by it's name using an answer or a list item. can i at LEAST reference a list through it's name in a variable? or a brand new variable type? or.. ill take ANYTHING.
if list of current playernames contains “sally”
update this stuff in sally masterlist
if list of current Playernames contains “mike”
update this stuff in mike masterlist
ect
it would be GREAT if i could do :
__Repeat until {(index) > current playernames}______
|
| update the stuff in (index) of playernames of masterlist
| change (index) by 1
^
<_________
Where index would start at 0 guess
and player names is at 4 names/items
, And “1” of playernames would be “Sally”
and the masterlist named “Sally” would be referenced and updated due to item 1 of player names ALSO being Sally.
then ide need one little piece of code that works for every single player, and when i need to add a NEW plyer, i dont have to add to the everygrowing 5 or so stacks it takes for me to work around NOT having this :'(/
if i CANT reference a list by it's name using an answer or a list item. can i at LEAST reference a list through it's name in a variable? or a brand new variable type? or.. ill take ANYTHING.
- Wainggan
-
Scratcher
500+ posts
Get list name from a variable?
is there a place where I can support this being added as a feature? has it been suggested somewhere or something? after a battle for an rpg thing ive got, the only way the HP value can be updated to the masterlists ( each character has their own list of their stats and whatnot), ive got to do the wholePlease don't necropost, create a new topic.
if list of current playernames contains “sally”
update this stuff in sally masterlist
if list of current Playernames contains “mike”
update this stuff in mike masterlist
ect
it would be GREAT if i could do :
__Repeat until {(index) > current playernames}______
|
| update the stuff in (index) of playernames of masterlist
| change (index) by 1
^
<_________
Where index would start at 0 guess
and player names is at 4 names/items
, And “1” of playernames would be “Sally”
and the masterlist named “Sally” would be referenced and updated due to item 1 of player names ALSO being Sally.
then ide need one little piece of code that works for every single player, and when i need to add a NEW plyer, i dont have to add to the everygrowing 5 or so stacks it takes for me to work around NOT having this :'(/
if i CANT reference a list by it's name using an answer or a list item. can i at LEAST reference a list through it's name in a variable? or a brand new variable type? or.. ill take ANYTHING.
- 8243874
-
Scratcher
100+ posts
Get list name from a variable?
(This post was removed because other people noticed about necropost earlier than me)
Last edited by 8243874 (Nov. 20, 2019 17:59:03)
- Discussion Forums
- » Help with Scripts
-
» Get list name from a variable?