How do I subtract global variables from one another?

  • I'm trying to make a type of calculator for my work and I want to subtract global variable 2 from global variable 1 and then subtract global variable 3 from that number and paste it to a text object. so far I have "HIGH: " &HighLevelStart - &DropLossHigh - &SplitterLoss

    It doesnt like me using the & signs, I've tried with and without parenthesis, with and without & signs, I'm kind of stuck. thanks in advance.

  • Try this:

    "HIGH: " & (HighLevelStart-DropLossHigh-SplitterLoss)

    & is a concatenation symbol, used to attach two strings together. You should not use it in math formulas.

  • Thank you so much! I didnt know that, but it makes sense. I feel dumb now haha. now its accepting it but isnt doing the calculation, where it should say the final result, it just says NaN so I'll have to play around some more. thanks again!

    -edit: I fixed it, I was missing a period in another line

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Actually, I was not technically correct in my previous comment.

    Yes, "&" is used to concatenate strings, but this is also a logical "AND" which can be used in math formulas

    For example:

    newHealth = health- (armor<1 & shield<1)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)