|
| 25 May 2012 10:53 PM |
| I'm learning how to script in RBX Lua and I'm currently learning about Booleans. I don't understand what they would be used for though. Just an example would work, I'm not looking for any code. |
|
|
| Report Abuse |
|
|
|
| 25 May 2012 11:03 PM |
if true then print("this will print") end
if false then print("This won't print") end
pizza = false
if pizza then print("This won't print") end
if (value == 3) then print("Will print if value is equal to 3") end |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 25 May 2012 11:07 PM |
| a boolean is a true or false value, it can be used for like 3459839485983384599 things. |
|
|
| Report Abuse |
|
|
pwnedu46
|
  |
| Joined: 23 May 2009 |
| Total Posts: 7534 |
|
|
| 26 May 2012 12:33 AM |
Booleans are used for all conditional statements (if, while, repeat). They can be used for on-off switches (on = true and off = false.) They're also good if you need to toggle an arbitrary value to signal the start or end of something.
value = true value = not value
will toggle the value variable to the opposite value. |
|
|
| Report Abuse |
|
|
|
| 26 May 2012 08:39 AM |
A boolean is either true or false, like for the brick property of Anchored, it is either yes or no (true or false). THat is a boolean value.
ex. lalala=true while lalala do insert script here end |
|
|
| Report Abuse |
|
|
MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
|
| 26 May 2012 09:14 AM |
A Boolean is a true/false or number value. Or even string value. So things like this:
Boolean = false if Boolean==false then Boolean=true print("This is false") end if Boolean==true then Boolean=false print("This is true") end
Now we use numbers.
Boolean = 0 if Boolean=="0" then Boolean="1" print("This is 0") end if Boolean=="1" then Boolean="0" print("This is 1") end
And now we use strings.
Boolean = "Hi!" if Boolean=="Hi!" then Boolean="Bye!" print("Hi!") end if Boolean=="Bye!" then Boolean="Hi!" print("Bye!") end
MrMcAero |
|
|
| Report Abuse |
|
|
MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
|
| 26 May 2012 09:14 AM |
Boolean does mean true/false value, but can easily become a string or number value.
MrMcAero |
|
|
| Report Abuse |
|
|
|
| 26 May 2012 02:40 PM |
pwn, Mr,
Thanks! Your posts helped me out the most.
Everyone else,
Thanks still! |
|
|
| Report Abuse |
|
|
| |
|