String to Value

This forum is currently in read-only mode.
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • hi,

    i'm loading a csv-file of xy-coordinates into a ListBox object to use a 'For each line' loop to spawn sprites at the specified positions. but ListBox.LineData() appears to return strings - or i suspect it to, because the results are always interpreted as 0 (zero) in the coordinate fields of the 'Create' action.

    is there a counterpart to str(value) that can turn strings into values?

    thanks for your time!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use 'int()'.

  • thanks!

    two things:

    • when using ListBox.LineText() instead of ~.LineData(), it works even without enclosing int()
    • when using ~.LineData(), it does not work in any case

    off topic, but what is LineData supposed to return?

  • LineData only returns something if you set data for the line (using the Set Line Data action); this is useful for storing extra data on lines other than text. In this case you'll want to use LineText, which is automatically converted to an integer by the parser.

  • In all of Construct, passing a string to a number parameter automatically converts it, so you can pass either "500" or 500, it doesn't matter. As Rich pointed out, LineData does not give the text, LineText does

  • Nice and Nice!

    I was actually adding a private variable to my text boxes to store additional information. I guess I didn't have to.

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