Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: fis on April 10, 2011, 06:19:48 AM

Title: [solved] Substraction operation
Post by: fis on April 10, 2011, 06:19:48 AM
There is an ability to add up variables in PM. I'm talking about the FloatAdd action.
But what about the substraction? Is it possible in the current version of PM?
Title: Re: Substraction operation
Post by: Pleasuremaker on April 10, 2011, 10:49:04 AM
You just need to use negative values in the Add field. No need for another action for that.
Title: Re: Substraction operation
Post by: MaDDoX on April 10, 2011, 04:31:23 PM
You just need to use negative values in the Add field. No need for another action for that.
True, although if you need to subtract from a variable you'll need two actions - one to multiply the variable value by -1 and a second one to add that result to the intended variable. In that case an actual subtract float action would be handy.

Sounds like a great exercise into creating a custom action for whoever wants to get into the most powerful aspect of playmaker, after all it'll be just one signal switch. C'mon guys, try it, it won't bite you! :)
Title: Re: Substraction operation
Post by: tobbeo on April 10, 2011, 08:05:16 PM
I don't quite get it? I use subtract all the time using FloatAdd. In the add field I just say for an example " -2 ". I guess what you are saying is that if you have a variable that you must keep as a positive float var but sometimes want to subtract it from another float you'd have to do it in two steps like you said.

Wouldn't it be as easy as going into the custom action of FloatAdd and exchange the + for a - and call it FloatSubtract?
Title: Re: Substraction operation
Post by: tobbeo on April 10, 2011, 08:23:48 PM
Well, my very first custom action completed! It was as easy as I thought, I replaced + with -, I replaced "Add" with "Subtract" and "add" with "subtract" (case sensitivity differences). I put it in "Share New Playmaker Actions":

http://hutonggames.com/playmakerforum/index.php?board=19.0
Title: Re: Substraction operation
Post by: fis on April 11, 2011, 10:19:26 AM
My gratitude :)!
It's more convenient to use one action instead of two.
Title: Re: Substraction operation
Post by: tobbeo on April 11, 2011, 10:40:04 PM
Sure! Gratitude is what will make me want to share more custom actions when I get to learning it better. So thank you :).