Jump to content

mod expression


Recommended Posts

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

Link to comment
Share on other sites

Guest Swann
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 by SWANN
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 4 years later...

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 by fenolis
  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...