Many topics are about how they set costumes to variables. So they'll make a script like the top script here
http://imgur.com/qCgHB
So it should switch to the costume with the name of the variable value right?
Wrong.
It will switch to the costume number. This can make things like health bars etc rather hard. So here is how to fix it (the bottom image):
http://imgur.com/qCgHB
This will turn the set of numbers into a string. So it will go the by the costume name, not number.
Hope this helps
Offline
It always tries to go by the costume name first; it'll only go by the costume number if there isn't a costume with the same name as the variable.
Offline
Both those scripts do the same thing. Joining a variable value with nothing isn't going to change it.
Offline
Oops, said that on the wrong account.
Offline
TargetheroTest wrote:
Both those scripts do the same thing. Joining a variable value with nothing isn't going to change it.
Au contraire, joining the (x position) reporter, for example, with nothing like so:
set x to (10.1) forever set [xposition v] to (join (x position) []) endwill cause the watcher for x position to show 10.1 and the watcher for the xposition variable to show 10.09999999999991.
Offline
sparks wrote:
TargetheroTest wrote:
Both those scripts do the same thing. Joining a variable value with nothing isn't going to change it.
Au contraire, joining the (x position) reporter, for example, with nothing like so:
set x to (10.1) forever set [xposition v] to (join (x position) []) endwill cause the watcher for x position to show 10.1 and the watcher for the xposition variable to show 10.09999999999991.
That wont have any effect on a variable(in place of the x reporter). They aren't auto-rounded, 10.1 will still be exactly 10.1, variables will always be exactly what you set them to, so using a blank join block wont change anything.
Last edited by Targethero (2012-02-10 16:06:24)
Offline
TargetheroTest wrote:
Both those scripts do the same thing. Joining a variable value with nothing isn't going to change it.
Afraid I must disagree.
Joining a variable value with nothing will turn the input into a string. Using the string it will switch to the costume name. However if it's a number, it will switch to the costume number.
Offline
rabbit1131 wrote:
TargetheroTest wrote:
Both those scripts do the same thing. Joining a variable value with nothing isn't going to change it.
Afraid I must disagree.
Joining a variable value with nothing will turn the input into a string. Using the string it will switch to the costume name. However if it's a number, it will switch to the costume number.
Say I have a script like this:
when gf clicked set [variable v] to (11) switch to costume (variable)If there is a costume named "11", it will switch to that costume, If you dont have a costume called "11" then it will switch to the eleventh costume. The same will happen with this script:
when gf clicked set [variable v] to (11) switch to costume (join (variable) [])
Last edited by Targethero (2012-02-10 16:56:48)
Offline
Targethero wrote:
sparks wrote:
TargetheroTest wrote:
Both those scripts do the same thing. Joining a variable value with nothing isn't going to change it.
Au contraire, joining the (x position) reporter, for example, with nothing like so:
set x to (10.1) forever set [xposition v] to (join (x position) []) endwill cause the watcher for x position to show 10.1 and the watcher for the xposition variable to show 10.09999999999991.That wont have any effect on a variable(in place of the x reporter). They aren't auto-rounded, 10.1 will still be exactly 10.1, variables will always be exactly what you set them to, so using a blank join block wont change anything.
Build that script. The variable reporter shows 10.09999999999991. I didn't just make that up, I tested it first
To clear this up, I have created a project showing this download
this project has 11 costumes, costume 2 is named 11.
there are two block sets in the project.
switch to costume ((11) + (0))will switch to costume 11 whilst
switch to costume (join [11] [])switches to costume 2
Last edited by sparks (2012-02-10 17:04:35)
Offline
sparks wrote:
Build that script. The variable reporter shows 10.09999999999991. I didn't just make that up, I tested it first
Im not saying the script you posted wont do as you say, I know it will, I've used that method many times lol. Im saying that if you do the same thing but with a variable instead of the x reporter, a variable wont change, you wont get an extended answer. Like this script:
set [variable2 v] to (10.1) forever set [variable1 v] to (join (variable 2) []) endThe answer obviously wont change from 10.1
sparks wrote:
there are two block sets in the project.
switch to costume ((11) + (0))will switch to costume 11 whilstswitch to costume (join [11] [])switches to costume 2
Yes but
switch to costume (join [11] [0])will also switch to costume 11, and
switch to costume ((11)+())will switch to costume 2.
Last edited by Targethero (2012-02-10 17:20:32)
Offline
Oh I see what you're on about. I also just tried out the scripts in the first post and they are wrong as variables are strings to begin with. In fact, it switches to the name as default with a variable unless you put the variable in a (var) + ( )) situation, turning it into a number.
Last edited by sparks (2012-02-10 17:26:27)
Offline
sparks wrote:
Oh I see what you're on about. I also just tried out the scripts in the first post and they are wrong as variables are strings to begin with. In fact, it switches to the name as default with a variable unless you put the variable in a (var) + ( )) situation, turning it into a number.
Offline
Actually, those are not the reults I was getting. I tried setting the variable, and it kept setting it sometimes to a number, sometimes to a string. I was not using any operators.
Offline
sparks wrote:
TargetheroTest wrote:
Both those scripts do the same thing. Joining a variable value with nothing isn't going to change it.
Au contraire, joining the (x position) reporter, for example, with nothing like so:
set x to (10.1) forever set [xposition v] to (join (x position) []) endwill cause the watcher for x position to show 10.1 and the watcher for the xposition variable to show 10.09999999999991.
Effectively, using a blanked join block stops Scratch rounding values, this can be very useful.
This is because sometimes scratch cannot display a sprite at an exact position so it slightly alters the position but auto-rounds it for display (although retains the value for processing). Adding a space character to the number turns it into a string so it stops auto-rounding.
Offline
um I don't see how that'l do anything.
Offline