0 Favourites

ListBox Object, For Each, and why is this not working?

This forum is currently in read-only mode.
  • So basically, at the start of the layout, I have an event that lists the names of .dat files in a folder to a listbox, then I have an subevent that happens immediately afterwards:

    ListBox: 494 For each line

    ListBoxSet line ListBox 0 .CurrentIndex data to GetToken(ListBox 1 .LineText(ListBox 2 .CurrentIndex),1, ".")[/code:7y7v5245]

    Basically this should strip every line from the ".dat" at the end of it, but for some reason, it doesn't seem to work. It works if I change "Set line data" to "Add line", so the "For each line" is most certainly run, but it doesn't seem to edit the line data for some reason. Later, when I try to do this (still a subevent to "Start of layout"):

    ListBox: 494 For each line
    System: 0 ListBox 0 .LineText(ListBox 1 .CurrentIndex) Equal to global('language')

    SystemSet global variable 'languageindex' to ListBox 0 .CurrentIndex

    ListBoxSelect line ListBox 0 .CurrentIndex[/code:7y7v5245]

    It doesn't seem to work either. I basically want to look for a line that is equivalent to the global string 'language' and set a global value called 'languageindex' to the line number of it, yet it doesn't change the value of 'languageindex' at all. Neither of these events do not work even if I put them as independent events instead of subevents.

    Any help?

    EDIT: Okay, so apparently LineData != LineText. I managed to partially fix it by changing it to LineData, but then it wasn't working when I tried to read the LineData later on. Now, the real question is: Why the heck can you not alter the actual line text?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I don't think many people have played around with the application side of Construct, apart from maybe me. Even I haven't really done all that much with it apart from creating some very basic data storage fields, mainly as a proof of concept.

    Unfortunately, I don't think I even used the listbox object at any stage... so I'm afraid I won't be much help, sorry.

    Maybe one of the dev's can shed some light on this?


  • Set line data associates data with a line. So if you had a list of names you could set an e-mail to go with each line which wasn't visible, for example. It won't change the item name.

    As the copy as text is a bit dodgy, it'd help if for the second issue you uploaded a .cap file. But there is a FindLine expression; you don't need to do a for each loop and check the text.

  • Rich, what I basically wanted to do was turn a list with this:



    Into this:



    I figured out that LineData is separate thing from LineText, but now my question mainly is that why can't I alter the actual LineText, only LineData?

    Construct in general is missing quite a lot of things in regard of creating applications (and using application rendering), but those really belong to a separate topic, and this particular problem was about doing a multilingual game. In any case, I managed to get around this by adding my edited lines to another ListBox, but in the future it'd be nice not to have to do this.

  • The control plugins are very complete':

    http://msdn.microsoft.com/en-us/library ... 85%29.aspx

    There is no API function to replace the text of a line. What you should do is add them how you want them. There is a 'For each file' condition of the File object, for example. You could use this and strip the '.dat' out before you add the file.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
4,517 857,213
Tinimations's avatar
Unread sticky
1,586 437,238
matriax's avatar
Unread hot topic
378 33,253
part12studios's avatar