Pages: 1
--variable block slot.
Like this:
set (item [2] of [list v]) to [0]or
delete [10] of (variable)This currently can't be done in the Scratch 2.0 alpha and this simple alteration would change the project I'm working on from about 20 ENORMOUS scripts to about 8 small scripts.
Offline
Bump!
Offline
Yuck.
Sorry, I don't support.
These blocks don't work like you think they do.
In your first example, (Item [2] of [list v]) returns the contents of the second entry of your list... as a string. You can't set a string to a value. You can only set a string variable to a value. You'd need to specify it differently. As shown, it is specified as what is stored in your list, not your list itself.
Offline
CheeseMunchy wrote:
--variable block slot.
Like this:set (item [2] of [list v]) to [0]Why not just use thereplace item [2 v] of [list v] with [0]block?
ordelete [10] of (variable)This one doesn't make sense...I don't know why you'd need it, but there's a workaround.
This currently can't be done in the Scratch 2.0 alpha and this simple alteration would change the project I'm working on from about 20 ENORMOUS scripts to about 8 small scripts.
Offline
Pretty sure sure Wes is the only one that understood me.
I guess more explaining is in order:
There are NO workarounds for this...
This would work flawlessly. I think. lol.
In the first example there is already a variable named [insert what item 2 of "list" is here].
set (item [2] of [list v]) to [0]In the second example there is already a list named [value of "variable" here].
delete [10] of (variable)This addition is actually more helpful than it sounds. :P
Last edited by CheeseMunchy (2013-01-17 20:24:58)
Offline
BoltBait wrote:
In your first example, (Item [2] of [list v]) returns the contents of the second entry of your list... as a string. You can't set a string to a value.
I don't quite see what you mean.
Offline
^^(item [# v] of [list v]) is a "reporter" block. It gives you the value of an item in a list; it is not a reference to that item in that list.
It makes more sense when you have the experience of working in what people 'round here call a "text-based language". This example is in Lua:
function number() return 1 end number() = 3
The function number() returns a number: 1. What you're trying to do, is kinda like that last line, equivalent to this:
1 = 3
You're trying to set a number, and not a variable that perhaps holds that number, to another number. That's not possible. Try it out here; should give you a syntax error.
What you want to do is already possible with another Scratch block; see sonicfan12p's post.
____________
As for the other block, it's perfectly possible with 2.0's custom blocks.
define: delete (number) of (string); store in (variable) //it's not really like this in 2.0, but you get my point if <(length of (string)) > (number)> stop script //nothing happens end set [newVariable v] to [] set [i v] to [1] repeat (length of (string)) if <not <(i) = (number)>> //to remove the specific letter from the string. set [newVariable v] to (join (newVariable) (letter (i) of (string))) end change [i v] by [1] end set (variable) to (newVariable) //apparently you won't be able to make reporter blocks in 2.0 (D:<), so I must resort to this ugly workaround.
Last edited by technoguyx (2013-01-17 21:07:50)
Offline
technoguyx wrote:
^^(item [# v] of [list v]) is a "reporter" block. It gives you the value of an item in a list; it is not a reference to that item in that list.
What's the difference between the value of an item in a list and a reference to that item in that list?
Offline
The reference is the reference to that value; a pointer to the location in the memory that contains the value. When you declare a variable:
set [foo v] to [bar]The variable foo is a reference to the string "bar".
Offline
Oh. That's too bad.
Offline
Pages: 1