This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » Suggestions
  •  » Allow for putting variables into list block slot and list blocks into-

#1 2012-12-19 14:39:46

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Allow for putting variables into list block slot and list blocks into-

--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.


6418,

Offline

 

#2 2012-12-19 16:03:17

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

i agree.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#3 2013-01-17 18:51:37

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

Bump!


6418,

Offline

 

#4 2013-01-17 19:01:28

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

This is available in several mods, but I don't really support. There are many workarounds you can use for this.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#5 2013-01-17 19:42:23

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

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.


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#6 2013-01-17 20:03:29

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

CheeseMunchy wrote:

--variable block slot.

Like this:

set (item [2] of [list v]) to [0]
Why not just use the
replace item [2 v] of [list v] with [0]
block?

or
delete [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.


Why are the secret organizations getting all the attention?  mad

Offline

 

#7 2013-01-17 20:21:22

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

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)


6418,

Offline

 

#8 2013-01-17 20:31:12

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

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.


6418,

Offline

 

#9 2013-01-17 21:03:43

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

Re: Allow for putting variables into list block slot and list blocks into-

^^(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:

Code:

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:

Code:

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)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#10 2013-01-17 21:24:02

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

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?


6418,

Offline

 

#11 2013-01-17 21:28:23

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

Re: Allow for putting variables into list block slot and list blocks into-

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".


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#12 2013-01-17 21:50:00

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Allow for putting variables into list block slot and list blocks into-

Oh. That's too bad.  tongue


6418,

Offline

 
  • Index
  •  » Suggestions
  •  » Allow for putting variables into list block slot and list blocks into-

Board footer