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

#1 2011-08-27 08:54:13

bickball
Scratcher
Registered: 2007-08-21
Posts: 10

My project - help!

I'm not exactly new to Scratch but I'm no pro. Right now I'm working on a project with some friends that is going to act a more or less a calculator for a board/sidewalk game that we've invented. It's almost entirely variable-based; the only sprites are the buttons to get to different pages.

Needless to say, I've run into some problems. Here's some, but I'll likely post more on here later.

In this, a lot of variables are needed to be manually set. (Set "construction workers" to 457) I can't seem to find a good way of doing this with variables. When it is set to slider, since many of the numbers will be in the upper thousands, it doesn't allow for very precise numbers because with high maximum limits the intervals start going way up.

Tied in to the previous question, I've run into a problem with a certain function. I want the variable "nonworking population" to equal "population" minus the total amount of workers. I entered:
<when green flag clicked>
<forever>
<set{ Nonworking }to((( Population <-> workers ))
(Actually for that last part there I had to do "Population" minus "chicken farmers" + "bean farmers"... (7 more)... + "vegetable farmers".)
It either doesn't work, or nonworking population skyrockets to some giant amount with no stop.

I'll be asking more questions later; thanks for the help!


Variables!

Offline

 

#2 2011-08-27 12:57:15

ellscharstark
Scratcher
Registered: 2010-10-09
Posts: 100+

Re: My project - help!

You could have arrows that change the slider.
[blocks]<forever>
<if>mouse down and touching arrow key right
<change{ number }by( 1 )[/blocks]


From ellscharstark - I like boring signatures but I love colours!  smile   tongue   lol
P.S. I live in England!

Offline

 

#3 2011-08-27 13:20:20

technomaniac
Scratcher
Registered: 2011-08-15
Posts: 94

Re: My project - help!

I dunno, but if this has to do with adding and subtracting, you could always look at my calculator project. It might contain some of the scripts you need.

Offline

 

#4 2011-08-27 20:03:49

bickball
Scratcher
Registered: 2007-08-21
Posts: 10

Re: My project - help!

Very helpful indeed! Another thing that's come up is the immense amount of scripting that needs to be done due to the amount of variables. All the variables need to be hidden and shown depending on the page. Though the arrow idea is excellent, it seems it would only add to this incredible amount of scripting that needs to be done already. Is there way I could cut down on all of this; make it simpler?

Also, is there any way to select locations for shown variables? It gets annoying when I have a variable that I want to show on multiple pages, but it remains in the same spot, no matter the page.


Variables!

Offline

 

#5 2011-09-05 12:46:43

bickball
Scratcher
Registered: 2007-08-21
Posts: 10

Re: My project - help!

Bump.


Variables!

Offline

 

#6 2011-09-05 13:06:16

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: My project - help!

Unfortunately you can't program variables to move around; you can only hide or show them. Some users have gotten around this by having a second variable watcher elsewhere that mirrors the value of the main variable. By alternating which of the two (or more) watchers is showing, you can make it seem as though the variable has moved.

As for simplifying coding, the fact that any sort of variable change has to be "hard coded", to speak, limits how much you can trim off.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#7 2011-09-05 15:24:44

AIOlover
Scratcher
Registered: 2011-05-08
Posts: 100+

Re: My project - help!

With the variables that need to be selected manually, you could do something like this.

Ask [How many people do you want?]
Set [Population] to {answer}

If you want to make it so that the answer has to be a number, so that your program isn't confused if someone answers with a word instead of a number, you could do this.

Ask how many people
If answer divided by 1 is greater than zero and smaller than one hundred billion
Set population to answer, and say thanks
Else
Say since you obviously don't care, I'll make up a random number for you. Set population to random number between one and one million

Hope this helps!
AIOlover


I'm currently http://blocks.scratchr.org/API.php?user=AIOlover&amp;action=onlineStatus&amp;type=text!
big_smile ~AIOlover~ big_smile

Offline

 

Board footer