Comparing values...

0 favourites
  • 8 posts
  • I have a number value (Cost) that's drawn from an array and brought into a text field that I then compare with a Global number (BankUniversal).

    System > BankUniversal = Cost.Text etc... works fine.

    But, if I want to have an action take place that relies on BankUniversal = Cost.Text -10 I get the following error:

    So how do I write it so that I can compare BankUniversal with Cost.Text -10

    Thanks all

  • Either int(Cost.Text)-10 or float(Cost.Text)-10 would work. It would be best to reference the original value though, rather than the string version.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It would be best to reference the original value though, rather than the string version.

    Yeah I did think it might be best to change the string to a number value first. How would I go about this?

    Thanks for your help

  • Either go back to the array, or add an instance variable to the Text object and set it at the same time as the Text. That way you have the original number and the Text version.

    (edit:typo)

  • Either go back to the array..

    Can I set the data in each cell as a string or integer?

    ...or dd an instance variable to the Text object and set it at the same time as the Text.

    ...dd?

  • Array data can be either, but you want it to be numbers here.

    "Add..."

  • Ok - I have 3 possibilities when displaying that array data:

    • NOT ENOUGH POINTS (shows dummy picture, and unavailable text for product name and short description)
    • NEARLY ENOUGH POINTS (shows dummy picture, product name and short description and unavailable text for short description when the BankUniversal is less than 10 points away from the full cost)
    • ENOUGH POINTS (shows product picture, full product name and description)

    Here's the event sheet...

    But here's the result:

    It shows both unavailable and full product names at the same time. What am I doing wrong here?

    Thanks

  • You are still comparing a number to text, and you need to make the checks exclusive, since conditions 6 & 7 can be true at the same time. There is no need to check against Cost.Text at all, use productList.At(loopindex, 0), and add Else to events 6 & 7.

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