playMaker

Author Topic: Every 20k, Add 1 Life?[SOLVED]  (Read 4310 times)

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Every 20k, Add 1 Life?[SOLVED]
« on: December 20, 2013, 12:35:27 PM »
Hello;

I am just wondering how you guys would handle this. Right now I have a float var setup to handle the scoring and all works perfectly. However I am having an issue or my brain is just over tired.

I am wanting to have it where every 20,000 points (Float), Add 1 to Life (INT)

How would I go about doing this?

Thanks guys.
« Last Edit: December 23, 2013, 09:28:03 AM by jeanfabre »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Every 20k, Add 1 Life?
« Reply #1 on: December 20, 2013, 12:46:07 PM »
Like this!

Check the attached object out.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Every 20k, Add 1 Life?
« Reply #2 on: December 20, 2013, 07:44:22 PM »
Thanks for the reply, I tried your recipe today and it spits out a loop error, I fixed the loop error but it still refuses to work.

The life interger just refuses to add 1 to its total amount. I have the INT set as a global (LivesRemain), with a default of 3, when equal to 20,000 add 1 to LivesRemaining does not work. I also have it setup to convert INT to string before sending info to my score label. Everything is working perfect except the extra life.....

Any othe ideas?

Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Every 20k, Add 1 Life?
« Reply #3 on: December 21, 2013, 05:47:46 AM »
Hi,

 You are overthinking this.

If you divide 30,000 by 20,000 it will give you 1.5, you round down that 1.5 and it will give you 1, with 50,000 you would get 2.5, rounded down : 2

so you only need a very simple division and rounding.

RoundDown(Points/20000) -> lifes

I have attached a simple scene showing this setup.

bye,

 Jean

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Every 20k, Add 1 Life?
« Reply #4 on: December 21, 2013, 08:06:46 AM »
Thanks for the reply, I tried your recipe today and it spits out a loop error, I fixed the loop error but it still refuses to work.

The life interger just refuses to add 1 to its total amount. I have the INT set as a global (LivesRemain), with a default of 3, when equal to 20,000 add 1 to LivesRemaining does not work. I also have it setup to convert INT to string before sending info to my score label. Everything is working perfect except the extra life.....

Any othe ideas?

Thanks.

That's weird, works prefect on my end.

So you should just need a float compare that compares the score to a variable like nextLife (20k) then when it reaches it and fires it goes into another state that adds +1 to lives global var and also increases the nextLife variable by 20k and goes back to the compare state. Gravy.

If the global int isn't changing you might be overriding it somewhere?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Col. Phil Bilko

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Every 20k, Add 1 Life?
« Reply #5 on: December 22, 2013, 07:41:53 AM »
Like this!

Check the attached object out.

Ok I looked at your recipe again today with fresh eyes and had it working in less than 5 mins. I hate how you can look at something this simple for too long and it over complicates itself. You have shown me a clean way of getting this to work well.

Now I can actually ship my game as this was the ONLY issue holding back its release!

Thanks again for both of your guys help it is really appreciated!

Merry Christmas.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Every 20k, Add 1 Life?
« Reply #6 on: December 22, 2013, 09:01:00 AM »
Ok I looked at your recipe again today with fresh eyes and had it working in less than 5 mins. I hate how you can look at something this simple for too long and it over complicates itself. You have shown me a clean way of getting this to work well.

Totally true. I would assume you'd get this if you were using regular coding or an FSM system... It's kinda one of the things we all have to keep a watchful eye out for when the games we're making start getting more and more complex.

For this a good suggestion would be using copious amounts of comments (there's an action you can add that'll let you insert comments as well as each FSM and node can have comments attached.) Sure, it's one extra step but not doing so can lead to a lot of confusion when you're tracking down pernicious bugs and such (which I've probably had happen more times than I'd like to admit. :lol:)