This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-29 18:57:44

chrisbown
Scratcher
Registered: 2011-07-29
Posts: 100+

list problem

when i try to remove a item from a list in a variable, it won't remove it even though the value of the variable is in the list, anyone discovered this problem or a way to fix it?


check out this: Tank physicshttp://scratch.mit.edu/projects/hamstercake11/3082288

Offline

 

#2 2012-07-01 07:39:10

benjamin2
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: list problem

The problem is the block that says remove item from list, if a variable is inserted, detects item positions in a list, not the actual items in the list.

So if you have:

Item 1: 2
Item 2: 1

And you set a variable to 1 and ask it to delete what is stored in the variable, it gets rid of the first item in the example above, not the second.

I haven't yet figured a way around this, but if I do I'll try to help.


http://i.imgur.com/gp6tZ.gif

Offline

 

#3 2012-07-01 15:53:18

chrisbown
Scratcher
Registered: 2011-07-29
Posts: 100+

Re: list problem

i haven't found a solution but i have found a way around it on my game which had a list problem but I have already realeased it ultimate cards it's a card game.


check out this: Tank physicshttp://scratch.mit.edu/projects/hamstercake11/3082288

Offline

 

#4 2012-07-01 15:59:19

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: list problem

If you want to delete a specific value, use;

set [i v] to [1]
repeat (length of [list v])
  if <(item (i) of [list v]) = [Value]>
    delete (i) of [list v]
  end
  change [i v] by [1]
end


Why

Offline

 

#5 2012-07-02 11:17:17

chrisbown
Scratcher
Registered: 2011-07-29
Posts: 100+

Re: list problem

RedRocker227 wrote:

If you want to delete a specific value, use;

set [i v] to [1]
repeat (length of [list v])
  if <(item (i) of [list v]) = [Value]>
    delete (i) of [list v]
  end
  change [i v] by [1]
end

thanks for the,tip


check out this: Tank physicshttp://scratch.mit.edu/projects/hamstercake11/3082288

Offline

 

Board footer