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

#1 2013-01-20 11:52:01

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

How to tell a variable to go to a certain location.

Hi,

I have a project that needs the "score" variable to go to a certain place other than the top left corner... Is there a way to do this?


Regards,

CAA14

Offline

 

#2 2013-01-20 11:54:01

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: How to tell a variable to go to a certain location.

You can't move variables around with scripts.  Within Scratch, you have to drag the variables to the correct locations, and then save the project with variables shown.  When you upload to the website, they'll be where you put them.

Offline

 

#3 2013-01-20 12:02:15

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Well, when ever i restart scratch, it rearranges my sprites, and resets my variable locations... Not only that, but it also causes some of my perfectly good scripts not to work... should i reinstall? Or post it as a beta and see if it works here?

Thanks for responding,

Regards,

CAA14

Offline

 

#4 2013-01-20 12:09:19

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: How to tell a variable to go to a certain location.

Make sure that your variables are all shown (the checkboxes are marked in the Variables palette) when you save the project.  Otherwise, they'll move to the top-left corner. 

What do you mean by "rearranges my sprites"?

About scripts not working... I'm not sure what that could be.  I've never run into that problem before.

Offline

 

#5 2013-01-20 12:25:42

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Hi,

What i mean by "scripts rearranging" is that in the sprite selection menu(Bottom Right), each time i reopen scratch and my project, they are in a different order.

I'm glad you've never had that problem... It's very frustrating.  sad
Thanks again,

Regards,

CAA14

Offline

 

#6 2013-01-20 13:46:48

bullelk12
Scratcher
Registered: 2012-05-26
Posts: 100+

Re: How to tell a variable to go to a certain location.

Unfortunately, you can't, it's very annoying.


http://mag.racked.eu/cimage/i6000/Achievement++get%21/Scratcher+love+minecraft%21/mca.png

Offline

 

#7 2013-01-20 13:48:26

bullelk12
Scratcher
Registered: 2012-05-26
Posts: 100+

Re: How to tell a variable to go to a certain location.

and CAA, could you upload that game to the scratch website so that I can try and see what's wrong?


http://mag.racked.eu/cimage/i6000/Achievement++get%21/Scratcher+love+minecraft%21/mca.png

Offline

 

#8 2013-01-20 13:57:03

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Hi,

I would like to upload a beta of my 1st project, nut before i do i need to know if i can change it's name after i upload it. If i can, i sure will.

Regards,

CAA14

Offline

 

#9 2013-01-20 13:58:16

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

Hi,

What i mean by "scripts rearranging" is that in the sprite selection menu(Bottom Right), each time i reopen scratch and my project, they are in a different order.

I'm glad you've never had that problem... It's very frustrating.  sad
Thanks again,

Regards,

CAA14

Well if you're scripts aren't working, then it might be a problem with the code itself. Could you post your code or your project?

Also, you might be interested to here this, but in Scratch 2.0, there'll be a new block that'll let you move variables wherever you want.

Now, as for your sprites being re-positioned, this shouldn't be happening. Re-installing Scratch might help, though I'm not 100% sure as I've never heard of this before, and it's never occurred to me. If that fails, then you could always put a [go to x: () y: ()] block in each sprite to move it to its correct position at the beginning of each project run.

Last edited by ErnieParke (2013-01-20 14:00:38)


http://i46.tinypic.com/35ismmc.png

Offline

 

#10 2013-01-20 13:59:45

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

Hi,

I would like to upload a beta of my 1st project, nut before i do i need to know if i can change it's name after i upload it. If i can, i sure will.

Regards,

CAA14

Yes, you can, but you first have to upload with the same name as it originally had. Then, after you've uploaded, you can click on the project's name and change it from there.


http://i46.tinypic.com/35ismmc.png

Offline

 

#11 2013-01-20 14:07:44

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Hi,

Thanks again, Ernie.
There are certain scripts that i know are working that will randomly not work, with nothing changed from when they did work.
Also, i had to do the go to thing.  smile
And, what i really meant by "rearranging my sprites" was that the menu in the bottom right would rearrange my sprites, the menu that shows you all the sprites you have in your project.

Regards,

CAA14

Offline

 

#12 2013-01-20 14:14:31

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

Hi,

Thanks again, Ernie.
There are certain scripts that i know are working that will randomly not work, with nothing changed from when they did work.
Also, i had to do the go to thing.  smile
And, what i really meant by "rearranging my sprites" was that the menu in the bottom right would rearrange my sprites, the menu that shows you all the sprites you have in your project.

Regards,

CAA14

Ahhh... My complete mistake. Somehow when I was typing up my post, that wormed its my way into my head, but either way, this still shouldn't be happening.

Now about the scripts that randomly won't work, well most likely those scripts includes multiple variables, and conditionals, all of which can give different results if you've changed any scripts recently. That's why I'm asking to see your scripts, to make sure something along these lines didn't occur, unless you've changed absolutely nothing in these past few days, in which case then it's probably not a problem with your scripts, though it's always nice to double check.

Last edited by ErnieParke (2013-01-20 14:15:29)


http://i46.tinypic.com/35ismmc.png

Offline

 

#13 2013-01-20 14:32:20

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Hi,

I just posted a beta version.

Search, "Target Practice (Beta)" and you should find it.

Please help if you can.

Regards,

CAA14

Offline

 

#14 2013-01-20 14:41:38

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

I really, really, really want to know what's wrong with my scripts.
It's driving me nuts.
I just want this project to work and be over so i can move on.

Regards,


CAA14

Offline

 

#15 2013-01-20 14:45:50

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

Hi,

I just posted a beta version.

Search, "Target Practice (Beta)" and you should find it.

Please help if you can.

Regards,

CAA14

Well three things:

1). This is just a tip; if you ever don't want to use Scratch's built in varibale viewer, you could always make your own. Just ask if you'd like to hear more.

2). Aren't the targets supposed to hide whenever you shoot them?

3). In your Crosshair sprite, you have several scripts that look like this:

when gf clicked
forever if <(color [#000000] is touching [Color...]?) and (mouse down?)>
 change [score v] by ((score) + (orange points))
 wait (1) secs

Well, there are two problems in this script. First off, each time you shoot, you're doubling you're score, which you don't want. The other problem is that you could hold the mouse button down, never shoot, and still get points. Instead, you might want to try using this:

when gf clicked
forever if <(color [#000000] is touching [Color...]?) and (mouse down?)>
 change [score v] by (orange points)//So score won't double.
 wait (1) secs//Optional addition of a "reload".
 wait until <not (mouse down?)>//More realistic.

Now that should fix some of the problems. About the others, seeing as I didn't create this, what are they?

Last edited by ErnieParke (2013-01-20 14:47:27)


http://i46.tinypic.com/35ismmc.png

Offline

 

#16 2013-01-20 14:53:10

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Hi,

Thank you! I can't believe i did not see the doubling thing, how stupid!

Okay, the other problems are that the "block" sprite and "multiplier" sprite are supposed to disappear when "level_End?" is "yes", but the multiplier does not.

Thank you so much, and sorry about the bone headed scripts.

Regards,

CAA14

Offline

 

#17 2013-01-20 14:58:28

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Also, The block is not covering all targets.

Regards,

CAA14

Offline

 

#18 2013-01-20 15:02:01

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

and, once i get this project finished, I'd love to hear how to make my own variable viewer.

CAA14

P.S. Over all, how was my first project?  lol

Offline

 

#19 2013-01-20 15:06:01

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

Hi,

Thank you! I can't believe i did not see the doubling thing, how stupid!

Okay, the other problems are that the "block" sprite and "multiplier" sprite are supposed to disappear when "level_End?" is "yes", but the multiplier does not.

Thank you so much, and sorry about the bone headed scripts.

Regards,

CAA14

Well it's okay; I was just like this when I started out with Scratch.  wink

Anyway, the reason why your multiplier isn't stopping/hiding whenever a level finishes is because when it enters its loop to fly around, nothing is making it get out of that loop when the level finishes, and nothing is preventing it from showing when it shouldn't. So, instead, you could try turning the show blocks into this:

if <(level_End?) = [yes]>
 hide
 stop script
else
 show
end

Along with that, on the right hand side of the script-area, the second script down, you having something similar to this:

when I receive [level1_Start v]
if <(level_End?) = [yes]>
 stop script
else
 repeat (times_to_fly)
  Script...
 end
end

I'd actually be much more efficient if you redid it this way, though you don't have to:

when I receive [level1_Start v]
repeat (times_to_fly)
 if <(level_End?) = [yes]>
  stop script
 else
  Script...
 end
end

That's all.

Last edited by ErnieParke (2013-01-20 15:10:22)


http://i46.tinypic.com/35ismmc.png

Offline

 

#20 2013-01-20 15:18:39

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

Also, The block is not covering all targets.

Regards,

CAA14

This should be an easy one to fix; so what you could do is first, implement a script like this:

when gf clicked
broadcast [layer1 v] and wait
broadcast [layer2 v] and wait
broadcast [layer3 v] and wait
More, if you want...

Then, in your Crosshair sprite, instead of it going to front and back a layer, just use this script:

when I receive [layer3 v]
go to front

Then, in your block sprite, you could use this:

when I receive [layer2 v]
go to front

Thirdly, in all of your targets, you can get rid of all of the [go to front]/[go back () layers] blocks, and replace them with this:

when I receive [layer1 v]
go to front

Finally, in your Blast sprite, you could add in a fourth layer called "Layer4" and have it go to front whenever it's called, or you could just make it go to front whenever you shoot.


http://i46.tinypic.com/35ismmc.png

Offline

 

#21 2013-01-20 15:20:32

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

and, once i get this project finished, I'd love to hear how to make my own variable viewer.

CAA14

P.S. Over all, how was my first project?  lol

Great and fun! I think that you could really work on making it more compact in general and more resourceful when it comes to variables, though you did a nice job!

Now, about the variable viewer, first what you'll have to do is create a sprite with costumes of the numbers 0~9, with 0 being the first costume, 1 being the second costume, ect... Then, just repeat that till you have as many as you need. Finally, make it turn into whatever costume you need. Here are some samples:

Note: This is a sample script of the ones place.

when gf clicked
forever
 switch to costume (letter (length of (Score)) of (Score))
Note: This is a sample script of the tens place.

when gf clicked
forever
 if <not <(Score) < (10)>>
  switch to costume (letter ((length of (Score)) - (1)) of (Score))
 else
  switch to costume [0 v]
 end

Viola! It's done!

Last edited by ErnieParke (2013-01-20 15:27:23)


http://i46.tinypic.com/35ismmc.png

Offline

 

#22 2013-01-20 15:52:31

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Thank you so much!

I will attempt to correct the script.
Question:

Ummm, the layer thing isn't making any sense... It looks to me like it will make the targets go to the front, or does "move to front" keep in mind other sprites that are also in front and fall in the back of them, or does it reset the front?

Thanks a lot!

CAA14

Offline

 

#23 2013-01-20 16:20:33

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

I tried the score thing, and it didn't work...

maybe i did it wrong, i made a new sprite with 10 costumes, 0-9, and then put those two scripts that you told me about in it.

CAA14

Offline

 

#24 2013-01-20 16:26:26

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to tell a variable to go to a certain location.

CAA14 wrote:

I tried the score thing, and it didn't work...

maybe i did it wrong, i made a new sprite with 10 costumes, 0-9, and then put those two scripts that you told me about in it.

CAA14

Well you're going to need more than one sprite, and each one needs it's own individual script, not both, or else it won't work. Again, could you show your scripts?

CAA14 wrote:

Thank you so much!

I will attempt to correct the script.
Question:

Ummm, the layer thing isn't making any sense... It looks to me like it will make the targets go to the front, or does "move to front" keep in mind other sprites that are also in front and fall in the back of them, or does it reset the front?

Thanks a lot!

CAA14

You're correct when you said that it "keep in mind other sprites that are also in front and fall in the back of them", so the targets would end up in the back, the Blast would end up in the front, and your Block sprite would end up in front of the targets.

Edit: I don't know if you know this by now, but if you ever want to close one of your topics, you can just use the report button. The same goes with editing them.

Last edited by ErnieParke (2013-01-20 16:44:03)


http://i46.tinypic.com/35ismmc.png

Offline

 

#25 2013-01-20 16:44:26

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to tell a variable to go to a certain location.

Ok, thanks,

I'll upload a beta #2 now.

I will forget about the score display until i get the layers working.

Thanks,

CAA14

Offline

 

Board footer