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!
Offline
You could have arrows that change the slider.
[blocks]<forever>
<if>mouse down and touching arrow key right
<change{ number }by( 1 )[/blocks]
Offline
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
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.
Offline
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.
Offline
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
Offline