YesNoOk
avatar

Merge variables into one (Read 1389 times)

Started by DR119, December 15, 2017, 02:57:23 am
Share this topic:
Merge variables into one
#1  December 15, 2017, 02:57:23 am
  • avatar
  • **
I want to display the value of a variable during gameplay, so I have to split the variable to make each number parsable for Mugen. But how do I "merge" those variables back into one again?
Last Edit: December 16, 2017, 03:25:45 pm by DR119
Re: Merge variables into one
#2  December 15, 2017, 03:13:32 am
  • *****
  • Shame on you!
    • USA
var(1) + var(2)?
But seriously I think you want something like
var(1) + (Var(2)*10) + (var(3)*100)
so if
var 1 =9
var 2 =6
var 3 =4
you'd get 469 as your result.

It may be easier to just use an additional variable for the original value that doesn't get split.
vVv Ryuko718 Updated 10/31/22 vVv
Re: Merge variables into one
#3  December 15, 2017, 04:00:04 am
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Use bitwise operators if you want to mimic standard data types.
Last Edit: December 15, 2017, 04:03:23 am by Jesuszilla
Re: Merge variables into one
#4  December 16, 2017, 12:34:44 am
  • avatar
  • **
var(1) + var(2)?
But seriously I think you want something like
var(1) + (Var(2)*10) + (var(3)*100)
so if
var 1 =9
var 2 =6
var 3 =4
you'd get 469 as your result.

It may be easier to just use an additional variable for the original value that doesn't get split.

But how do I prevent the numbers to get higher than 9?
Because if I want to do it like this:
var(1) + (var(2)*10)

anim = 1000 + var(2)

anim = 1000 + var(1)

and if one of the vars equals 10 or higher, Mugen won't show the numbers correctly
Re: Merge variables into one
#5  December 16, 2017, 01:31:45 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Are you using VarAdd to increment each var?

Instead of adding 1 each time have it check if it's 9, in which case subtract 9 making it 0 again

Var(1) = Cond(var(1) = 9,-9,1)

Re: Merge variables into one
#6  December 16, 2017, 03:17:25 pm
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Why do you need 3 variables to begin with? If you want to store a 3 digit number, you could simply use a single variable and display the different digits with arithmetic operators
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: Merge variables into one
#7  December 16, 2017, 04:07:49 pm
  • avatar
  • **
Why do you need 3 variables to begin with? If you want to store a 3 digit number, you could simply use a single variable and display the different digits with arithmetic operators

You mean like
var(1) full variable
var(2)=var(1)%10  ones
var(3)=(var(1)/10)%10  tens
var(4)=(var(1)/100)%10  hundreds
Re: Merge variables into one
#8  December 16, 2017, 04:29:39 pm
  • ****
    • USA
    • twitter.com/inktrebuchet
There is probably no need to use var(2),(3)or(4).

Where ever those variables are being used, you could use the math (var(1)%10) instead.