the whole boolean thing

VALEN T.

Member
oh bbcode legends pls help a dude out i have no idea how to work this

so i think i've a p good command over scripts and shit - this thing:
Code:
[script class="xxx" on="whatever"]
addClass yada something
removeClass this that
hide me
show time
fadeIn 800 fries
fadeOut 300 chips
[/script]


right ?

so now can someone please explain how the whole boolean if thing works ?

Code:
[script class="heart"]
set addedClass 0
[/script]

[script class="heart" on="click"]
if (eq ${addedClass} 0) (addClass move 1) (removeClass move 1)
if (eq ${addedClass} 0) (addClass move 2) (removeClass move 2)
if (eq ${addedClass} 0) (addClass move 3) (removeClass move 3)
if (eq ${addedClass} 0) (set addedClass 1) (set addedClass 0)
[/script]

a few questions:

(1) why am i setting addedClass to 0 in the script class="heart" ?

(2) what is addedClass ? can i change it so that it says anything else instead (i.e. have it say set opinion 0 ?)

(3) is the script class="heart" even important ?

(4) do i have to set the set addedClass 0 to 0 ? what difference would it make if it was set to 1 ?

(5) what does the if (eq ${addedClass} 0) mean ?

(6) i've seen, in other codes, where users set the "0" in if (eq ${addedClass} 0) to 1 or 2. what difference does that make ?

(7) so there's the whole if (eq ${addedClass} 0) (addClass move 3) (removeClass move 3) but what if i just want the "move" class added to "3" permanently ? could i leave it like if (eq ${addedClass} 0) (addClass move 3) or will that mess things up ?

(8) what do these "1" and "0"s even mean ?? (i think it's the whole "yes" and "no" thing...correct me if i'm wrong)

these are just a few i have but please, just make it make sense 😭
 
Last edited:
So in bbscript, there is no proper TRUE and FALSE value, so instead we're replicating that behavior with numbers instead. We chose 1 and 0 as they traditional represent true and false. You can use any number pair you'd like.

addedclass is a variable. In the code we first have to set it to 0 in a separate script that only runs once, when the page loads. This let's us use the variable later without any messiness. Since it is just a variable, you can name it anything you want.

Yes, it is the only way the script detects anything. The first one runs only once, but the second one has the on= option. This means that every time the div with the class "heart" is clicked, it'll run the script.

The reason why it's set to 0 is to create the variable. You can change it to any other number, but since 1 and 0 are traditionally read as true and false, and the variable is called addedclass, it should be interpreted as "a class has/hasn't been added."

if (eq ${addedclass} 0) is the if part of the if then statement. The logic translates to "if addedclass = 0", then perform the following.

So if you want the move class to be added to "3" permanently, then you can remove the other part. The third part of a if-then statement is an else. This means if the "addedclass" is not equal to 0, then it'll run the third part instead of the second part.
 

Users who are viewing this thread

Back
Top