#can someone explain to me what a bool variable js
1 messages · Page 1 of 1 (latest)
A bool variable just stores the information of either TRUE or FALSE
Variable = storage
Bool = True or False
I don’t understand the use of that
Example
When would I ever need that
You have a 30hz
Ok
Example you can make a button only work if the Bool is true
And how would you change the bool
What’s the point of that? Cant I just make it not work?
Or not connect the button to anything?
Let me explain first
Ok
Boolean aka Bool are True or False
This can also be seen as On or Off/Yes or No
You can use this in making something only work if the bool is true or only work if a book is false
Example a money system, you can check if your money is greater then a certain amount and if it is, it will output True but if your money is not above a certain amount it will output false
Cant I just do if: greater than, true or false?
Example, Gun handles have a bool that determines if your reloading, if your not reloading its false if you are reloading it’s true
Watch Untitled and millions of other Rec Room videos on Medal, the largest Game Clip Platform.
this explains it in-game terms
When the Bool is True it explodes, when the Bool is False it dosnt explode
Example there a chip called player get is grounded it just says if your touching the ground or not
If you are touching the ground it outputs TRUE if you are not touching the ground it outputs FALSE
It’s literally just True or False
What?!
There isn’t anything complicated about it
Are the bools even doing anything in that clip?
not the variables
theyre just there to show
Im changing the Boolean on the If chip
Then why couldn’t I just use if: player get is grounded
Then:
Wait
Is bool just an “if” chip mixed with “sequence”??
Then I’m clueless
Its kinda like an open gate or a closed gate
I don’t see a purpose in it
Its very important
Here’s something you will use bools for!
This is called an If chip
The red input in called the condition, this receives bools
If the bool is true it outputs from THEN
If the bool is false it outputs from FALSE
Like the five nights at Freddy remakes we’re you collect letters
You can make it so that if you have all letters it outputs true but if you don’t it outputs false
If it’s true it will execute from the then output so you can maybe award players for money
If it’s false it executes from the else output and for example you can say “you don’t have enough letters”
No
See i use Boolean in this ivnention right here.
What?
yeah im confused about this too
The player get is grounded has a bool output
Is this just a recreation of bool as a circuit
You then wire that to a IF chip
Ok…
ITS alway gonna be TRUE or FALSE
I’m saying specifically the “bool chip”
There is no “bool chip”
I mean bool variable
It works as normal as any other variable
It just saves the information True or False
How do you store stuff on it
^
I don’t see the purpose in that
You execute the chip
You input a Bool and execute the chip
Okay and it saves the true or false?
It will save it
yes
I don’t understand why I can’t just rerun the “if” chip
this is insane
what do you mean rerun the if chip?
Like why would I ever need to store whether something is true or false
If player has role? Isn’t that already a chip?
Yeah
Yo bro do you want a mini lesson? I can join you
i didnt mean to say that chip specifically
I'm going to make one comment and im not explaining again
Variables are chips that store data, the data is stores is based off what variable you are using (Bool variable stores a bool value, int variable stores an int value, etc)
When you execute a variable, that variable will store whatever is being input at that moment (So if I executed an int variable that had the input "5", it would store the value "5")
All variables of the same name and type (which are inside the same circuit scope) store the exact same value
This means if I had set my int variable "MyInt" to "5", that means all int variables named "MyInt" in the exact same circuitspace would also return "5"
"Circuit space"/"Circuit scope" is where you are placing your circuits, by default, this is "World space", but it can also be:
- A circuitboard
- An object board
- An AI Board
- A Player Definition Board
add me now @Ardenis-
Yeah I have an idea of what it does I just don’t understand the purpose in it
It stores a true or false value, its purpose is whatever you need it for
Want to record if the player has finished a race? bool variable, HasFinishedRace
Want to record if the player has done a one-time-event? bool variable, HasFinishedEvent
Want to record if the player is affected by a boost? bool variable, IsAffectedByBoost
If a player finished a race, couldn’t I just add 1 to an Int variable, and then test if they have at least 1
Keep in mind "True" or "False" could mean anything
Yes or no, 0 or 1
Anything in code is nothing unless you define it to be something
I mean, yes, you could, but thats a waste of CPU, unless you want to record the number of times they have finished the race aswell
But for a one time event, assuming it should only happen once ever, you'd use a cloud bool variable, since you wouldnt want to record the number of times a one time event would happen
I’ve invited you and requested you like 20 times bro
Ok I’m joining
Personally, I use int variables over bool variables most the time
I only use a bool variable when I absolutely do not need an int (eg. one time event)
Any time else, I'm using an Int Variable, eg. I wouldn't have a bunch of bool variables for an AI like "IsSprinting", "IsTargetting", "IsPathing", "IsSearching", "IsWandering", I'd just have one Int Variable, "AIState"
Ok I’m in the kitchen
Ok I’ll be right back
Like everyone explained bools are very important. a bool is Yes/No, True/False, Or Do/Don't. It's like a question on a test. "Does this equation equal to 3? 1 + 1 = 3" since it's wrong it'd be false. But if it was "1 + 2 = 3" then it'd be true. You use bools to determine if the player/server should be allowed to do this. You use books A LOT and it's very useful. You can also use bool variables to store a bool. It's not that complicated
And I swear to God if you say something along the lines of "but why would I need this?" Or "I don't understand" I am going to have a mental breakdown
oh lord what happened here
I feel like people misinterpreted my question. All I wanted to know was what a bool variable did. I understand the red port I just didn’t know what the variable did
It saves the value on the input
Yeah, i barely learned that yesterday, but I still don’t see a purpose in it
As opposed to giving an int to a player and testing if they have at least 1 (which is what I’ve always used)
it saves time, circuits, and cpu
Yeah but I’ve never had a scenario where I’ve only wanted to set something to true/false once
doesn’t have to be once
it can back to false, and go to true
like a variable called “GameActive”
Set it to true when the game starts
Set it to false when the game ends
The only purpose I’ve found in it is a button that can move a piston back and forth
It’s very useful, just depends on what you’re doing
Bro says he’s good at circuits and had to have 50 messages to explain a DATA TYPE 💀
me?
It’s not my fault he didn’t get
I had to slow down for him and explain each part individually
He’s was literally unteachable in game too
💀
@fervent niche The "why can't I just use greater than/equals" is actually a very good question. The answer: You can, but bool (true/false) is much faster than using numbers or strings due to how the computer processes data. In CrypticCreator's case (AIState), he has more than one thing he's tracking, so he must use a number.
You would want to store a bool in a variable when you are keeping track of something like a custom door. Is the door open? Yes/True or No/False. The next time the user interacts with the doorknob, you need to know if you want the door to open itself or close itself (using a rotator).
Sometimes there are support chips for things so you don't need to make your own bool Variable.
That’s because I already knew what the red port was, and I don’t think you knew that I knew, so when you tried explaining it to me, I was over complicating the question because I thought that you knew I knew
Do you still have questions?
I don’t think so, the only question I would have is “what is the purpose in this” but it’s just a faster way of my old way… I probably won’t use the bool variable, because my brain is so set to my old method, it won’t even process a use for the new one
If it is working, the only people who will notice an int vs a bool are other circuiteers and programmers. The people playing your game wont care at all.
One day when you bump into cpu overheating and really need to optimize something, you can come back and revisit it.
Okay, so that’s good. I don’t want to miss out on potential creations by not using it
Yeah, I’ll definitely keep that in mind if it overheats 👍 thank you
Modern computers really let things be very "sloppy" processing-wise. 🙂
Oh! Notably: I use a bool to put a gate on an Update 30Hz, because it's faster than any other check you can throw at it. When you have a bunch of those, that little slice of cpu execution power matters.
bool variable changed events
I thought of a spiffy example for bool vs int when you only need a bool: Imagine you are sitting at your kitchen table and there's a fly crawling across the table. You can hit it with a fly swatter or you can hit it with a shovel. Both of these will kill the poor insect, but the shovel takes a lot more resources to wield. The bool would be the fly swatter and the int would be the shovel. You also can't dig a hole very well with the fly swatter. Different tools for different tasks.
I have been summoned.
Bro it should not take this long just to explain what a bool is
Yeah but this is #1020094893458198578
what did you expect
i have a ai. my ai will die. when my ai is dead, i save true when its hit by my sword. now the ai wont run cuz of my if.
But there are lots and lots of nuances and information to consider for bools...
I know what a bool is 😭 I just didn’t know what the bool variable did
I ACCIDENTALLY CALLED SOMEONE HERE SORRY
oh well there's your answer
Only 144 messages
Bro has never heard of an If condition, how tf do you know what a “bool is without knowing it” tf
Please organize your circuits 💀🙏
Bro I’m about to make a tutorial on CV2 I’m done with this rotating circuits bs 💀
You’re not gonna like this but that’s as organized as it gets
I know what an if condition is 😭 I was just asking what a bool variable did that’s all!
All variables just "keep information for you". i.e. store/retrieve. The data types (bool, int, float, string, Color, Player, etc.) just say how to efficiently store that information. (data types go on to tell the computer how to efficiently process computations on that information)
What you probably mean to say is "asking what a bool Variable is used for".
Answer: bool Variables are used to save information that is only ever 1 of 2 things (true/false, yes/no, 0/not zero). i.e. "is a door open or closed", "is a light on or off", "is a player moving or standing still", "is a circuit currently running or not".
Yeah I know that variables store information, I just assumed bool variable did something different because it seemed useless to store a true/false statement to me
How is it useless?
variable changed events
“It seemed useless” that’s why I asked
Our computers currently work entirely on just a bunch of true/false bits. 🙂
think of all the player get is chips, all very useful and are all bools. ‘Player Get Is Grounded’, is the player grounded? Yes or No. That’s a bool variable
try making a room, then after around 10 minutes you’ll realise how important they are
I’ve already been making a map for a month now and never once needed it
have you used any if chips?
Yeah basically half my map
What
Yeah I know that, but I didn’t know what the bool variable did
then = yes, else = false
oh you mean the proper bool chip?
The bool variable
ok so the bool variable chip
Yeah… still don’t see a purpose in it other than to save CPU
well it depends what you’re making to be honest, in some cases it’s very important, in others you don’t use it at all