Tong Le Posted March 11, 2010 Share Posted March 11, 2010 I want to generate something every 5 frames. The only one way I am thinking about is using mod or if(($F % 5 == 0),0,1). But I think my expression is not, cos it gives me error when i use either mod() or %. How can I get these kind of result? Thanks, Tong Le Quote Link to comment Share on other sites More sharing options...
Guest Swann Posted March 11, 2010 Share Posted March 11, 2010 (edited) if(($F % 5 == 0),0,1) Because you try to make two booleans in one check. You ask Is $F divide by 5 (this is first boolean so it can be true or false) and then again you asking IS $F%5 is equal to zero(this is second boolean). So you asking something like: Is true/false is equal to true/false. NO You compare values and if this compare is true/false than it will work. This is correct: if($F%5,0, 1) If you want to make nested if statements make this: if($F%5, if($F == 0, 0, 1), 2) Edited March 11, 2010 by SWANN Quote Link to comment Share on other sites More sharing options...
Tong Le Posted March 11, 2010 Author Share Posted March 11, 2010 Because you try to make two booleans in one check. You ask Is $F divide by 5 (this is first boolean so it can be true or false) and then again you asking IS $F%5 is equal to zero(this is second boolean). So you asking something like: Is true/false is equal to true/false. NO You compare values and if this compare is true/false than it will work. This is correct: if($F%5,0, 1) If you want to make nested if statements make this: if($F%5, if($F == 0, 0, 1), 2) aha, thanks. Swann. 1 Quote Link to comment Share on other sites More sharing options...
Fenolis Posted November 17, 2014 Share Posted November 17, 2014 (edited) Replying to a (possibly) dead thread, but from what I understand, $F%5 would do a $F/5 and return an integer remainder, so the expression would output a sequence 1,2,3,4,0,1,2,3,4,0,etc as $F increases. If, on the other hand, you wanted an output of 0,0,0,0,1,0,0,0,0,1,etc, I believe the expression to use would be if(($F % 5 == 0),1,0) This would perform a modulus function on $F, giving you the previously stated sequence 0,1,2,3,4,0,1,2,3,4,etc, which the conditional if() then checks for equality to the value , and if the boolean equality returns a true ($F can be divided by 5 with no remainder), output a 1, else output a . Edited November 17, 2014 by fenolis 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.