playMaker

Author Topic: [Solved] Passing one value to another no more.  (Read 1182 times)

TicTac

  • Playmaker Newbie
  • *
  • Posts: 10
[Solved] Passing one value to another no more.
« on: October 28, 2021, 06:04:09 PM »
Hello  :)

I am trying to make sure that on a weapon with 1 bullet in the magazine and 1 bullet in the reserve it goes into the magazine and no more, like: 1/1 to 2/0 once reloaded.

I turn the problem around and it gives me pretty funny results. The best I managed to do and have 1/1 and when recharging 30/0 ... yes I do not understand why he gives me 30 which is a full charger. But it is a value given during an operation.

In the case of 1/1. After press Reload

Float operator

Float 1: Ammo (which has 30 base)
30.0 <- have 1 before press R
Float 2: 30
Operation: subtract
Store: difference
-29.0

Float Add

Float variable: Total ammo. (which in the fsm at this time cannot be higher than 30 because I separated in 2 parts because above 30 it works well, and for debug too)

0.0

Add: Difference
-29.0

Float Subtract

Float variable: Ammo
30.0
Subtract: Difference
-29.0

The result 30/0

I have tried several ways, some even I do not know where I went to look for them.
I had to do 10 ways, inverted the variables, actions, do several operations to define (tried) what remains and what we put. But the result is that ......... I'm not good at math it seems.

There you go, thank you for taking the time to read this.
ps translate by google
« Last Edit: October 29, 2021, 02:45:44 PM by TicTac »

TicTac

  • Playmaker Newbie
  • *
  • Posts: 10
Re: [Help] Passing one value to another no more.
« Reply #1 on: October 29, 2021, 02:44:00 PM »
Ok, It's good I solved it by myself.

It was not easy but with calculation and logic I did what I would never have thought to succeed.
It's tinkering but it works perfectly whatever the values.

But I haven't found a way to take the right value and put it purely in the left one.

Basically I remove the amount needed by the left value on the right side. (that's easy)
 Then I made sure to give the same quantity withdrawn to the one on the right for the value on the left, and it seems logical for everyone but doing it with opetaror, add, subtract, compare floats is something else.

And that's where it was complicated.
You wouldn't say it like that but it's a challenge.
I spent a lot of time on it.

If I had the time I would make a video of it because I haven't seen it anywhere.