Fuel overflow.

CaptFinnCaptFinn Member Posts: 1,828
edited January 2013 in Working with GS (Mac)
Ive watched some score keeping type videos. But Ive yet come across one that covers my problem.

Here is my problem.

My ship is constantly using fuel and constantly gaining fuel based on colliding with fuel pod actors.

Example:
Fuel Pod 1= 20 Units of fuel
Fuel Pod 2= 30 Units of fuel. etc etc

My fuel tank holds 100 units of fuel. Atrribute Integer "FUEL" Start games at Fuel units 100

My timer says every 1 sec change Fuel to Fuel -2. So Im using 2 units of fuel every sec.

If I collide with a pod. That pod adds that many units to fuel attribute.

Now I've given the pods a rule. IF ALL "collides with Ship" and "Fuel attribute is less than 100". For that
pod to add its fuel units.

Here is the issue. Lets say the ship has 90 Units. And it hits a pod that gives 20 units. The fuel attribute is now 110.

I know this is because it is how I've coded it. But I would like it to top off at 100 even if the fuel pod has more than the tank can hold. SO when it has 90 units of fuel and hits a 20 unit pod. The tank will register 100 and not 110.

Im thinking this could be done with % based rules. But I know nothing on how to do this.

can someone point me to a good video to explain this?

Comments

  • TesseractEngineTesseractEngine Member Posts: 180
    Just add a rule at the end of your adding fuel rule that says When fuel >100 change fuel to 100.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    Hi @Jeffnichols it all seems fair enough the rules you have so far...

    To take account of the issue you're experiencing, simply add another rule nested in your existing rules:

    When scene.Fuel > 100
    Change Attribute scene.Fuel to 100

  • TesseractEngineTesseractEngine Member Posts: 180
    I'd like a Ninja badge now please! :D
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hey @TesseractEngine You do deserve one; whistled in, then out again, without sight or sound to me...impressive! :-)
  • TesseractEngineTesseractEngine Member Posts: 180
    @gyroscope I'd tell you how I did it...but I am sworn to never reveal the secrets of...

    ...THE THREAD NINJA!

    ;)

    I think there must have literally been seconds between our posts.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013
    @gyroscope I'd tell you how I did it...but I am sworn to never reveal the secrets of...

    ...THE THREAD NINJA!

    ;)
    Ha! I've got it: the first rule of the thread ninja - you do not talk about the thread ninja... :D
  • CaptFinnCaptFinn Member Posts: 1,828
    thanks guys
    I was praying it wasnt a % thing
Sign In or Register to comment.