playMaker

Author Topic: [SOLVED] How to do Modulo Math in Playmaker?  (Read 5051 times)

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
[SOLVED] How to do Modulo Math in Playmaker?
« on: July 25, 2013, 04:58:45 PM »
Hi there,

I have used Modulo in GameSalad and thought it might work well in this environment as well, but maybe its unnecessary.. 

so my intent is to have an INT variable..  when something is clicked it would become 1..  when an object is clicked again it would become 0.. using this formula:

( Var Name +1)%2

this way i can simply keep adding +1 to a variable each time a button is clicked but the number would keep flipping between 0 and 1..  which has worked well for me in the past. 

Thanks!
Caleb
« Last Edit: July 28, 2013, 02:21:01 AM by part12studios »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: How to do Modulo Math in Playmaker?
« Reply #1 on: July 27, 2013, 09:12:20 PM »
There's a custom action here:
http://hutonggames.com/playmakerforum/index.php?topic=4185.0

But there are simpler solutions you could use:
example: var = 1 - var
using the Int Operator

See attached screenshot for an FSM that flips an int variable between 1 and 0 every second.


part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: How to do Modulo Math in Playmaker?
« Reply #2 on: July 28, 2013, 02:20:34 AM »
That's awesome.  I've heard about custom actions, but hadn't yet found an opportunity to incorporate one.  now to figure out how to incorporate one :)  I'm sure its simply, just have to do a little searching.

As for the alternative suggestion I'll have to play with it and apply that. i'm not sure I follow how it would work, but I'll do my best to figure it out!  Everything is still pretty new to me so everything feels foreign till i apply it a few times. 

Sincerely!
Caleb

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED] How to do Modulo Math in Playmaker?
« Reply #3 on: July 28, 2013, 04:07:26 AM »
Hi,

 The modulo custom action can be found here:

http://hutonggames.com/playmakerforum/index.php?topic=4185.msg19579#msg19579

 to get it in your project, simply download the file attached to the post above, and put it anywhere in your project's assets. Typically tho, create a new folder called "PlayMaker Custom Actions" and put it all in, I also have sub folders for each category, so here you would also create a folder "Math" and have this modulo custom action in there.

once the modulo custom action is in your assets, it will become listed in the action browsers like ANY other actions, simply search for it or locate it in the math category.

bye,

 Jean

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: [SOLVED] How to do Modulo Math in Playmaker?
« Reply #4 on: July 28, 2013, 08:28:57 AM »
awesome thanks for the tip!  I kinda figured out how to get it in the project, so that was cool, but i didn't know the finer points on how to group things.  Much appreciated!

Thanks!
Caleb