How do I...efficiently call up text on the fly?

0 favourites
  • 8 posts
From the Asset Store
Voice call plugin based on webrtc protocol for construct 3
  • So, I am in the process of prototyping a skill tree and am running into a few issues. I have telling myself "There has GOT to be a better way" quite a bit. So, here's what I am doing:

    The left side of the layout is a pane that contains a WoW/Diablo II style skill tree with a number of colorful icons that can be clicked on. On the right side is a pane that is intended to give statistical information once you click on a power.

    Here is how things are set up now:

    -Currently, I have a 2 dimensional array. In each row is the power name and relevant information all of this is set at beginning of layout. This means for each attribute of a power, I have to create an event to add it to the array. This is a colossal pain in the butt.

    -The right pane has a number of text boxes that call text from the array depending on the power icon, that is clicked, in the left pane.

    Is there a better way to store and more easily re-call data? Is there a way where a simple xml or text call can store this information and another object can easily recall it?

    Thanks!

  • Here are few ideas. I am assuming that arrays first column holds the 'name' and second column holds some stuff that you want to appear on mouse over or whatever.

    for 0 to array.height

    .. create text at 100, 100+100*loopIndex // these could be icons or whatever, you could set icons frame/animation based on array value

    .. set text to array.at(0, loopIndex)

    .. set text.Index to loopIndex // an instance variable that defines which row of the array this text represents

    This would automagically create a text box for each of your array values.

    on mouse over text

    .. set mouseOverText to array.at(text.Index, 1)

    This would display a mouse over info from the array when you mouse over a related text object.

    Edit: Quick example

  • First off, thank you very much for replying! Secondly: My array looks something like this:

    -The first row contains several columns. The first is name and the second through 13th provide further statistical data. Damage, Range, Keywords, etc.

    -The second row would contain a second power and its details.

    or 0 to array.height

    .. create text at 100, 100+100*loopIndex // these could be icons or whatever, you could set icons frame/animation based on array value

    .. set text to array.at(0, loopIndex)

    .. set text.Index to loopIndex // an instance variable that defines which row of the array this text represents

    At risk of revealing that I am a noob, I am going to have to ask... what is loopindex? I am just getting into arrays. So, I don't entirely follow what you're suggesting. I've looked at the sample project you sent and I understand only the first event. The second and third, I think I get... but the Loopindex part is confusing me.

    Again, thanks so much for responding. Double thanks for posting your example.

  • loopIndex would be the current 'round' of loop. So if we for example have a for loop that repeats 5 times it would work like this:

    for 1 to 5

    .. append loopIndex to text

    Text would read: 12345 after the for loop would have finished running, adding a number each 'round' the loop does.

    What this allows us to do with arrays, we can for example go through each row with loopIndex. So the same for loop with array could work something like this:

    for 1 to 5

    .. append array.at(loopIndex) to text

    After the loop text would read whatever was contained in array values 1 through 5. I'll try to expand on that example a bit tomorrow if I got time, to make it easier to understand. :)

    In your case, you could just add rows 2-13 to the part where text is displayed (the on click event). I'll expand the example with this when I got some more time :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Boom! Knowledge. Thank you for that. I would appreciate further examples, they're tremendously helpful. In the meantime I will try to implement what I've learned here.

    Another question:

    Is there an easier way to populate data into an array (or other data storage object)? Can an array or some other data storage object call data from a text or .csv file line by line?

    Regards,

    Phil Z

  • I expanded the example a bit, added comments and few extra columns.

    Yes, there is easier way to import large data sets: check out tutorials about importing data in XML or JSON format :)

  • That improved example helps a great deal. Thank you! I haven't been able to find a tutorial that explains how to call data from XML or JSON. I did manage to find a tutorial that explains how to add such files to the project file though. So, I suppose that's a start.

    Do you know of a tutorial that can help load data from an XML file and toss that into an array or something that can be easy referenced and manipulated?

  • I'm still pretty stumped and have started two other threads. One to focus on finding a solution with XML and another for JSON. Neither have yielded fruit unfortunately. So, I could really use some help if someone has time.

    If someone could provide an example of how to call up a specific string of data in an XML file or JSON file that would be amazing. Here's been my flow so far...

    1) Create XLS file with a simple spreadsheet.

    2) Use this site to convert it into XML, JSON, whatever...

    3) Plug this new file into Construct 2 as a project file.

    Here's where I currently am with my project.

    I am happy to swap the data from JSON to XML. That's not a problem. I'd just like to call up specific pieces of data. Like the first string with a specific tag. If anyone could give me an example of how to do this I would be eternally grateful.

    Regards,

    Phil

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