Is there a way to get a value (from user) during runtime and assign it to a variable that has been created? For example, if trying to do a simple number guessing game, is it possible to ask the user for a number, assign it to variable "guess" and compare it to variable "number", which has been randomly generated?
Offline
There are a few ways.
1) Right click on the variable on the programming screen and choose "slider". THis allows the user to change the variable in game.
2) Use a set of "If" statements to set it via keyboard entry (if 1 pressed, set "number" to 1 etc)
3) Have buttons on screen that when clicked, set the variable to a number. (If "Button1" clicked, set "number" to one.)
Using different variables for the units, tens or even 100's and 1000's allows multi-digit numbers to be set with just the 0-9 keys, as does multiplying the exisiting number by 10 before adding to it.
IE, number set to zero. Player presses 3, "Number" increased by 3 (to make 3). Player presses 2, Number multiplied by 10 (30) then increased by 2 (32)
Offline
The calculator programs show how to enter arbitrary numbers from a keyboard:
http://scratch.mit.edu/projects/kevin_karplus/76772
Offline