#can someone explain to me what a bool variable js

1 messages · Page 1 of 1 (latest)

fervent niche
#

What does a bool variable do? I never use it because it sounds funky, and I have no idea what it does.

outer grotto
#

Variable = storage
Bool = True or False

fervent niche
#

I don’t understand the use of that

outer grotto
#

Example

fervent niche
#

When would I ever need that

outer grotto
#

You have a 30hz

fervent niche
#

Ok

outer grotto
#

Example you can make a button only work if the Bool is true

fervent niche
#

And how would you change the bool

outer grotto
#

Bools are literally just true and flase

#

I’m trying to think of the best example

fervent niche
#

Or not connect the button to anything?

outer grotto
#

Let me explain first

fervent niche
#

Ok

outer grotto
#

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

fervent niche
#

Cant I just do if: greater than, true or false?

outer grotto
#

Example, Gun handles have a bool that determines if your reloading, if your not reloading its false if you are reloading it’s true

haughty galleon
#

this explains it in-game terms

#

When the Bool is True it explodes, when the Bool is False it dosnt explode

outer grotto
#

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

outer grotto
#

There isn’t anything complicated about it

fervent niche
#

Are the bools even doing anything in that clip?

haughty galleon
#

not the variables

#

theyre just there to show

#

Im changing the Boolean on the If chip

fervent niche
#

Then:

#

Wait

#

Is bool just an “if” chip mixed with “sequence”??

haughty galleon
#

No.

#

Boolean is only a yes or no

fervent niche
#

Then I’m clueless

haughty galleon
#

Its kinda like an open gate or a closed gate

fervent niche
#

I don’t see a purpose in it

haughty galleon
#

Its very important

outer grotto
#

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”

haughty galleon
#

See i use Boolean in this ivnention right here.

haughty galleon
outer grotto
fervent niche
outer grotto
#

You then wire that to a IF chip

fervent niche
#

Is bool the red one

#

Int is green

#

Float is blue

#

?

outer grotto
#

Yes

#

bool is red

fervent niche
#

Ok…

outer grotto
#

ITS alway gonna be TRUE or FALSE

fervent niche
#

I’m saying specifically the “bool chip”

haughty galleon
outer grotto
#

There is no “bool chip”

fervent niche
#

I mean bool variable

outer grotto
#

It works as normal as any other variable

#

It just saves the information True or False

fervent niche
#

How do you store stuff on it

haughty galleon
#

^

fervent niche
#

I don’t see the purpose in that

haughty galleon
#

You execute the chip

outer grotto
#

You input a Bool and execute the chip

fervent niche
#

Okay and it saves the true or false?

outer grotto
#

It will save it

outer grotto
fervent niche
#

I don’t understand why I can’t just rerun the “if” chip

wooden adder
#

this is insane

outer grotto
#

I need to like become a better teacher bruh

#

I just can’t

outer grotto
fervent niche
haughty galleon
#

Yeah

#

you could check "If" "Player has Role"

#

Booleans are used right there

fervent niche
haughty galleon
#

Yeah

outer grotto
haughty galleon
#

i didnt mean to say that chip specifically

fervent niche
#

Sure if you can

#

Sure if you can

#

Oops

wooden adder
#

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
outer grotto
fervent niche
fervent niche
#

Invite me

wooden adder
outer grotto
#

or invite me

fervent niche
wooden adder
#

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

wooden adder
outer grotto
fervent niche
#

Ok I’m joining

wooden adder
#

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"

fervent niche
#

Ok I’m in the kitchen

fervent niche
#

Ok I’ll be right back

ripe mirage
#

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

lament frost
#

oh lord what happened here

fervent niche
#

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

lament frost
fervent niche
#

As opposed to giving an int to a player and testing if they have at least 1 (which is what I’ve always used)

lament frost
fervent niche
lament frost
#

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

fervent niche
#

The only purpose I’ve found in it is a button that can move a piston back and forth

lament frost
#

It’s very useful, just depends on what you’re doing

edgy mango
outer grotto
#

I had to slow down for him and explain each part individually

#

He’s was literally unteachable in game too

wary frost
#

@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.

fervent niche
wary frost
#

Do you still have questions?

fervent niche
#

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

wary frost
#

One day when you bump into cpu overheating and really need to optimize something, you can come back and revisit it.

fervent niche
fervent niche
wary frost
#

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.

wary frost
#

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.

solar willow
#

Bro it should not take this long just to explain what a bool is

grand verge
#

what did you expect

terse sage
wary frost
fervent niche
radiant jetty
#

I ACCIDENTALLY CALLED SOMEONE HERE SORRY

grand verge
lament frost
#

Only 144 messages

edgy mango
somber night
edgy mango
haughty galleon
fervent niche
wary frost
#

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".

fervent niche
lament frost
#

How is it useless?

steep trail
#

variable changed events

fervent niche
wary frost
#

Our computers currently work entirely on just a bunch of true/false bits. 🙂

rose rune
#

try making a room, then after around 10 minutes you’ll realise how important they are

fervent niche
rose rune
fervent niche
rose rune
#

💀

#

what does are the inputs on an if chip

#

Execute

#

and

#

Bool

fervent niche
#

What

rose rune
#

If is an bool

#

if is yes or no

fervent niche
#

Yeah I know that, but I didn’t know what the bool variable did

rose rune
#

then = yes, else = false

rose rune
fervent niche
rose rune
#

ok so the bool variable chip

fervent niche
#

Yeah… still don’t see a purpose in it other than to save CPU

rose rune
#

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