|
| 26 Aug 2016 09:03 PM |
something = true
print(something == true and true or false)
which one acts as elseif/else?
This siggy is copyrighted © |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 26 Aug 2016 09:04 PM |
what the or means that if the condition is not true then...
Formerly ToxicDominator - add 17,509 posts |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 26 Aug 2016 09:05 PM |
print(something == true and 'it is true!' or something == false and 'it is false' or 'where am i')
send me trades |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 26 Aug 2016 09:06 PM |
The or is what you're looking for. print(false or 5) -> 5 print(true or 5) -> true
And requires both left and right statements be truthy. Or goes to the right statement if the left isn't truthy. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2016 09:12 PM |
Would this work
local random = math.random(1,3) print((random == 1) and 1 or (random == 2) and 2 or random == 3 and 3)
This siggy is copyrighted © |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 26 Aug 2016 09:14 PM |
why don't you just do print(random)
send me trades |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2016 09:16 PM |
trying to make a number/letter generator with something similar to the above code stated in the OP (finished, works)
This siggy is copyrighted © |
|
|
| Report Abuse |
|
|