iff(cond, a, b)Duncan1246 wrote:OK, and ifff(math.random()<.5,1,-1)??
Returns a if cond is true, otherwise returns b.
so iff(math.random()<.5,1,-1) returns 1 for a randomly generated number below .5 and returns -1 for number equal or larger then .5
iff(cond, a, b)Duncan1246 wrote:OK, and ifff(math.random()<.5,1,-1)??
Yes.Duncan1246 wrote:So, the first line means facing is facing if facing exists, OR math.random if not. OK, and ifff(math.random()<.5,1,-1)??
Thanks for your reply!
Thanks, Dr D, better to know it, it's very useful.Dr.Disaster wrote:iff(cond, a, b)Duncan1246 wrote:OK, and ifff(math.random()<.5,1,-1)??
Returns a if cond is true, otherwise returns b.
It's something Petri added to Grimrock's lua.Duncan1246 wrote:it's very useful.
Another common way to do this in Lua isDuncan1246 wrote:Thanks, Dr D, better to know it, it's very useful.Dr.Disaster wrote:iff(cond, a, b)Duncan1246 wrote:OK, and ifff(math.random()<.5,1,-1)??
Returns a if cond is true, otherwise returns b.
Code: Select all
cond and a or b
unless a is false !minmay wrote:Another common way to do this in Lua isCode: Select all
cond and a or b
Code: Select all
GameMode.setGameFlag("DisableMovement",true)
viewtopic.php?f=22&t=7951&start=740#p96678Eleven Warrior wrote:As soon as the code runs I need to turn the party in any of the ddirections 0,1,2,3.
Isaac wrote:
ifff(math.random()<.5,1,-1) returns a value of 1 or -1, depending upon whether the math function returns a high or low result. The value is later given as dir to the party:turn(dir) function. It determines whether the party turns left or right.
Thanks for these precisions.minmay wrote: ]Another common way to do this in Lua isCode: Select all
cond and a or b