Filling array with data from text file

Get help using Construct 2

Post » Sat Jun 29, 2013 11:08 am

I am trying to make an RPG and I need to enter a great amount of data in 3D arrays (world map, objects, dialogs...). I would like to work on text files and then load them in arrays at start of layout for use in the game. I know there are already multiple topics on this problem but none of them provide a clear way of doing this.

Here is what I figured out :

- You can use a super long JSON string, but the syntax is not intuitive and not suitable for great amount of data

- You can add external files in the game project file and call them through AJAX but I am missing a step on how to fill the array

Here are my questions :

- What text file format should I be working on ? (.txt, .xml, Json, other ?)

- How can I get the data from the text file and fill the arrays with them ?


Those questions were asked before but I coudln't understand the answers given. Could someone help me please ?
B
3
Posts: 5
Reputation: 385

Post » Sat Jun 29, 2013 5:44 pm

@OPG

I can be misunderstanding the problem(English isn't my native language), so correct me if I am wrong:

You want to be able to work on files to load inside arrays, but only for your convinience (so the user shall not be able to edit it).

If that is the case, I think it is possible for you to create another quick project on C2 to have an JSON array editor suitable for your needs, then, you just put the retrieved content in a .JSON file, which you include in C2 project files, and load into arrays using the Ajax object.

I am not sure on how to do it, but creating an easy-to-work-on array editor to make array editing simplier, then use them into the original project may be the solution to need

If someone has a better idea, Or if I am All wrong, correct me please.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Mon Jul 01, 2013 8:39 pm

Hi Aphrodite,

I'm french too so we will both make English mistakes !

Thank you for your answer, however it is not the good solution for me.

I plan to make a 100x100 array with a specific data in each spot. If I go through C2 to make it, it means doing 10 000 events to fill each spot...
I would like for example to use a CSV file that I could edit in Excel and then "translate" it to an Array in C2.

Perhaps I am wrong but there is no way of "filling" manually an Array in C2 without doing a lot of events ?

Merci !
B
3
Posts: 5
Reputation: 385

Post » Mon Jul 01, 2013 10:58 pm

this can help

CSV, CSV2Arrayvtrix2013-07-01 23:02:48
ImageImage
B
69
S
21
G
7
Posts: 827
Reputation: 10,017

Post » Tue Jul 02, 2013 11:02 am

I made an ingame level editor in my previous game and wrote a tutorial about it few weeks ago, it makes level making much more easier, you can make your RPG levels quickly inside your game and export the whole JSON file quickly into your downloads folder. After this you export this file into your project, the tutorial also shows you how to make a loader to load the json back into te game. You can add more parameters to the array by increasing the first parameter(currently 4). This method saves you a lot of time. For example if you want to add a character dialog you just drag a text box from the side menu and after adding text you save the textbox text into the array.

https://www.scirra.com/tutorials/585/how-to-make-an-ingame-costume-made-level-editor

I hope, that was helpful.trollface2013-07-02 11:03:29
B
14
S
5
G
4
Posts: 107
Reputation: 4,788

Post » Wed Jul 03, 2013 1:21 pm

Great thank you for your help.

@vtrix I'll try the CSV plugin but i guess I won't be able to put my game on the arcade if I use it.

@trollface I'll also have a look to your level editor, the initial time investment will probably allow me to save a lot of trouble later on !
B
3
Posts: 5
Reputation: 385

Post » Wed Jul 03, 2013 5:57 pm

@OPG they are working on something to allow plugins,could be soon, so if it easy to use i would use it, anyway have you also considerd tmximporter with the tileprogram, you can search for it,.. have fun making your game!
ImageImage
B
69
S
21
G
7
Posts: 827
Reputation: 10,017


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Yahoo [Bot] and 8 guests