6 posts
Posted 06 April 2013 - 07:20 AM
i want to know if it is possible to put an if statement into a variable? if so how?
example of what i want to do
x = if i < 1 then
rs.setOutput("side", true)
end
2217 posts
Location
3232235883
Posted 06 April 2013 - 07:22 AM
rs.setOutput("side", i <1)
not sure what you want though
8543 posts
Posted 06 April 2013 - 07:22 AM
No. Unless you're trying to use a function? What is the use case here, what are you actually trying to accomplish?
Edit:
rs.setOutput("side", i <1)
not sure what you want though
This always sets the output, rather than only setting the output if i is less than one.
1522 posts
Location
The Netherlands
Posted 06 April 2013 - 07:29 AM
You can use the ternary operator
local x = z==1 and 'its ture' or 'its false'
2217 posts
Location
3232235883
Posted 06 April 2013 - 07:33 AM
This always sets the output, rather than only setting the output if i is less than one.
.-.
rs.setOutput("side", i <1 or rs.getOutput("side"))
that better?
6 posts
Posted 06 April 2013 - 07:40 AM
nvm i figured it out while thinking of a way to explain. the code i want. very sorry about this. it was my stupid for forgetting how the code works.
2088 posts
Location
South Africa
Posted 06 April 2013 - 07:41 AM
rs.setOutput( "side", i < 1 and true or false )
2217 posts
Location
3232235883
Posted 06 April 2013 - 08:23 AM
rs.setOutput( "side", i < 1 and true or false )
"and true"
dafuq?
"or false"
i dont even
seriously these do nothing .-.
2088 posts
Location
South Africa
Posted 06 April 2013 - 09:26 AM
Lol ternary operator… What do you mean it doesn't do anything? I thought just plain
rs.setOutput( 'back', i < 1 )
would work but…
rs.setOutput("side", i <1) not sure what you want though
This always sets the output, rather than only setting the output if i is less than one.
EDIT:
Oh misunderstood lol, but setting it to false doesn't matter so rs.setOutput('side', i < 1) is fine really