playMaker

Author Topic: Subtract Question!  (Read 1403 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Subtract Question!
« on: July 28, 2017, 01:36:56 PM »
Hi!
I want to subtract from an Int Variable. That sounds easy, but I only want to subtract 100, 200, 300 etc. Let me explain. If I add 112 to the Int variable, I want to subtract only 100 so it's only 12 left and the same if I add 250, I want to subtract only 200 so it's only 50 left. The same with 332, 440, 520 and so on. Are you understand my point? Is it a way to do this? If so, how? I need to use a calculation I think, but I'm not sure what kind of action I need.

While I'm waiting for a reply, I will try at my own. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Deek

  • Full Member
  • ***
  • Posts: 133
Re: Subtract Question!
« Reply #1 on: July 29, 2017, 12:43:14 PM »
If I understand correctly, you only want the last 2 digits of every number. The probably easiest way for that is to convert the int to a string (Action: "Convert Int To String"), then use the Action "Get String Right", set Char Count to 2 and convert the string back to an int (Action: "Convert String To Int").

If you meant to subtract a predefined int from a factor of 100, you have to create a second int, give that int the number you want it to subtract (1 if you want it to subtract by 100), use "Int Operator" and multiply that int by 100. Then subtract your main int from that newly created one (with a second "Int Operator" action).
You can also set the value for the second int with "Set Int Value".

I hope one of them were what you asked for. If not, please ellaborate further or give more detailed examples.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Subtract Question!
« Reply #2 on: July 29, 2017, 07:01:21 PM »
Hi!
I found a way to do it. Not exactly what I asked for, but I was thinking a little bit wrong.

In my game you need to pick up people and fly them to the destination platform.
The bonus you get depends how your landing is, how far you land from the human, how fast you fly them to the destination etc.

I have 2 variables for dollars and cents. What I was thinking wrong was, if I get more than 1 dollar in bonus, I add 1 to the dollar variable. Not 100 to the cent variable which is 1 dollar. If I get 32 cent for each landing, I get 128 cents when the cent variable reaches 100, so I use compare and add 1 to the dollar variable and subtract 100 from the cent variable so it will be 28 cent left.

Well, I don't know if you understand me, but I got it to work now anyway. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no