So,I am making a task for an among us collab ,and i used the create variables library for this,so you are supposed to press a button to make a fuel variable to go up(This is where i used the library to make the fuel variable),but when i press the button,the variable does not go up,so when the variable reaches 100,the variable is supposed to get deleted and the task ends,but it can't end because the var value does not go up
in short: do not use the create-variable-library. Ever. It is not meant for projects that you do, it's meant for curriculum writers' internal work, when they need to port some bunches of custom blocks over to another version. There is - nothing - you gain from using that library. On the contrary: Whenever you feel you need to create a variable programmatically it's a sure indicator that you're doing it wrong and that you did not understand the problem at hand.
I'm going to start another initiative to remove that library. It only confuses novices, because they think there's some deeper truth there or something that's "missing" in Snap. This library should never have been accepted.
@jens: I don't disagree, but I'm not sure someone who thinks they need the library will understand why they don't from what you said.
@simulator-master: You have one variable created through the library, fuel. Why can't you just create that variable the normal way? I guess because you think you have to delete it later? Why do you have to do that?
... Oh, I see. You are using the existence of that variable as a flag (a true/false value). Instead, make a variable fueling? whose value is initially True, and instead of deleting the fuel variable, set fueling? to False. Then you don't need to mess with currenttask either.
(By the way, this is a grownup programming language, so you could name that variable current task and thereby make your code much more readable.)
they obviously just use the library because they don't understand variables in the first place. So "going meta" on variables is this mirage of learning something about them which isn't there. I feel we're doing a disservice to learners by providing it.
AFAIK no popular professional PL lets you do that - for good reasons. So, it's not even something that would help find your way around Java, Python, JavaScript, C, Ruby, whathaveyou.
I did say "I don't disagree," but you're just yelling at @simulator-master instead of teaching him. He used the variables library because it's there and because he didn't know how he's supposed to do what he wants. He's a kid. He's learning to program. Our job is to help him learn. If you just want to yell at somebody about the library, yell at me, and let me deal with the forum. :~(
Everything goes as expected, but there are two "fuel" variables - one for the Sprite and the other for its clone. To share the variable and see it updated, you can use
Not exactly.... my cousin uses it for making 'users' in a 'server'.(though he can just use the users that they are being communicated by :P)
A user in it is a variable, and it works perfectly fine(though, he hasn't used "the change by block in the library.
The reason why i am using the library is because i do not want a lot of variables in the finished game,so i just create a temporary variable so I use less variables.,plus,if the other people in the collab use a lot of variables,well then i do not want to add more,I just want a variable that will last for the task and be deleted when it is done
@jens
Also,I know what variables are,I just thought that i will use the library for 1 temporary variable in the project,the description said "Create and manage global/sprite/script variables in a script".there was NO disclaimer that said "library is only meant for curriculum writers' internal work",plus,it had a delete variable block and create variable block,perfect to make a temporary variable @bh
If this was in the game(i am in a collab),I thought of using this library to make a temporary fuel variable because that could make the amount of permanent variables needed less,also,the fuel variable is supposed to indicate how much percent of fuel is in the canister and is supposed to last until the task is done,then the crewmate will do other tasks while the fuel variable is gone
P.S. I know that i need to name the variable Current_task , but i named it Currenttask for some reason
So, the best way to make a temporary variable is with the SCRIPT VARIABLES block. That way, the variable will automatically be available just long enough, and more important, available only to that script, which is how you avoid stepping on collaborators' toes.
You can also use SCRIPT VARIABLES to make a variable that's available to more than one other script but not to every script, but it's more complicated. See Chapter VIII of the Reference Manual.