Can somebody explain how this if expression works, or what lock does? And is there anyway It can be written simpler?
-- this code is on line 47 in wheel main, It handles the input for the hsv wheel
if
if lock then (m < 0.8) else (not huewheel)
then
-- mouse in inner circle
elseif
if lock then (m < 1) else (huewheel) then
-- mouse in hue wheel
end
I am not familiar with this kind of “if expression”
the placefile where the code lies is here: colorwheel (1).rbxl (32.5 KB)
on line 47 in WheelMain
local bool = true
local value = if bool then "Yay!" else "Nay!"
print(value) --> prints "Yay!"
In the code example, the example checks if bool is a truthy value, then it evaluates to the given values:
-- what this looks like using a normal if-then expression
local bool = true
local value;
if bool then
value = "Yay!"
else
value = "Nay!"
end
print(value) --> prints "Yay!"