Status
Not open for further replies.

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
This is kinda noobish question really.
Imagine we got a file at the same folder with the game.
Let's say we got a CSV file named ab.csv with a line on it being:
STR STR STR STR STR INT INT INT

text1, text2, text3, text4, text5, 9, 4, 1

Now imagine 500 lines like that.
I want to store them to an array (two dimensions) and get access to the data from there.

How can I import all the lines from a csv file to an array, and how can I have access to a specific value from a specific line?

I want to set variable 21 to 'text4'


$game_variables[21] = How do we refer to text4 value? Remember, not from the file. I want an array in RAM.

EDIT:

I am actually looking for a solution that will be executed through Eventing as a command or a bunch of commands. If that was PHP and not JS I would ask to put a CSV into a two dimension array that is symbolized like this: $DATA[j] in PHP but I don't know if it is similar in JS whatsoever. What I am asking is an equivalent command in JS that will run in MV and make such a data structure, drawing values from rows of a csv file.

EDIT 2:
Not sure if that would work in MV and how it would work:


What I know so far is that if I have this in JS:
var items = [
[1, 2],
[3, 4],
[5, 6]
];

I can easily refer to the items as a two dimension array. Similar to other languages. Okay!
console.log(items[0][0]); // 1
console.log(items[0][1]); // 2
console.log(items[1][0]); // 3
console.log(items[1][1]); // 4

What is missing is the way to make the variable contain a csv row.
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
3,332
Reaction score
1,249
First Language
Dutch
Primarily Uses
RMMV
you can try to study this plugin by Hime (ExpTables) which use that function.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
Not quite what I need, but I will give it a try. In the meantime, if anyone can suggest another solution, feel free to do so!
As I said, it is a noobish question implying I have never put my hands on JS really. I can play with Python or Java all right. But when it comes to JS I got zero experience, thus it makes the code kinda hard to follow.

Thus I would appreciate if someone would give a clean solution, I will edit OP giving more detailed info.
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
3,332
Reaction score
1,249
First Language
Dutch
Primarily Uses
RMMV
Himes exp tables use a CSV file and import the data from it.
if you can find out how that is done, you can do the same for the stuff you need.
maybe you can modify stuff to your needs :)

I have a plugin that require css, but it aint easy as well to modify the css file.
but its a nice way to study how its done and how they read it.

it's even possible to read other files as well like html, txt for intants which are
used for quest log or guidens, there are more files, but you have to import them correctly.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
maybe you can modify stuff to your needs :)
Or maybe I can't because I am not familiar with JS syntax.
I can see what HIME does.
What I need is not a plugin though.
Maybe a plugin that can do that with a plugin command, well that would be nice.
And then have plugin commands to set data into variables or something.
But you can manually give these commands.
The only thing missing is how I can put the csv on a data structure and HIME code doesn't help me a LOT on how to ONLY do that because after all it is a plugin, not a set of commands.



I am not sure if that would work inside MV.



Anyway, If I won't find a way, I will have to hardcode all entries one by one. Not what I got in mind really though.
 
Last edited:

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
480
Reaction score
1,470
First Language
Indonesia
Primarily Uses
RMMV
If in the end you are trying to access stored data and put em into in game variables, why not just use the js as a plugin then directly access it?
1588753280085.png
1588753420703.png
1588753461769.png
1588753493874.png
1588753505394.png

I've always do it like that, tryin to spread this breakthrough, but keep it to myself in the end.
Feels like I'm the only one doing it... unless there's a problem doing it like this?
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
O.O

Wait WHAT?
Can you please send me an example code? I wanna see how you implemented it as a plugin and how you made the structure inside it. It could be an alternative.
But to be honest I would prefer a csv approach to have more flexibility on adding and removing stuff ad-hoc from the csv file and have the application being updated with more or less data automatically.
I can always update a js file instead, what am I talking about?
That awkward moment that someone steps into and tells you: "Bro, you are thinking it the wrong way!"

i-am-impressed-ey364l.jpg


Both @ShadowDragon and @Kuro DCupu thank you, but if you could give me a sample code with a bunch of entries, that would be perfect. I wanna know how a plugin opens and close. Meanwhile I will be actually searching. I can take it from there and start building.
 
Last edited:

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
480
Reaction score
1,470
First Language
Indonesia
Primarily Uses
RMMV
It's just a loose variable inside a function without any accessor.
But I do have a sample exclusively to make tutorial out of it.

There's the attachment.
Just create new project, then overwrite folder data and js. You have to manually include the plugin from the plugin manager tho.
 

Attachments

  • Project.zip
    6.7 KB · Views: 8

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,088
Reaction score
2,680
First Language
Greek
Primarily Uses
RMMZ
So since I was torturing myself to find a way to add a csv file to an array in RAM.
Then I read about the fabulous idea to just put the data into a plugin.
Then I started thinking to the right direction.
What if We can actually script EVERYTHING using a kinda complex but simple Eventing system?

What I needed, was Script commands.
And then it hit me!!



◆Control Variables:#0001 = [2,2,3]
◆Control Variables:#0020 = 2

◆Script:$gameVariables.value(1)[1] = 1;
◆Script$gameVariables.setValue(2, $gameVariables.value(1)[1]);
◆Script$gameVariables.setValue($gameVariables.value(20), 'Hello');
◆TextNone, Window, Bottom
: :\V[1]
: :\V[2]
: :\V[4]


Works like a charm.
You can iterate, you can change value, you can read value, thus I think this is the best way to play ball.

So now I want to ask about something else.
But that question will be for my next thread... which is the following one, and I share so people here can also benefit:



Closing.

 
Last edited:
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Today we be doing an unscheduled stream! Lets get some work done on the titlescreen for Lightestone! <3
www.twitch.tv/riazey
I can't believe it... my mom is going to sign me up for the Planet Fitness down the street! I need to lower my cholesterol according to my doctor, and I'll need to lose some weight to fit into Helen Henny's skirt (I ordered a skirt for my mascot outfit and realized it was a bit too small). My doctor says I need to lose weight anyway.
I blame my lilest bro for the duck suit. Sketched it and realized it had to be added to a mock fashion magazine cover. The titles are actually inside jokes about the place this NPC is from.
EvKECQJVEAw3Qux
Kes
After a few hectic months, my hiatus is over, and I'm now back. Good to see so many familiar names posting. And a forum update while I was away.
V1.3 of Demo, a new concept artist on the team, character voices are coming into light more... I'm happy to say that the fangame is making good progress.

Forum statistics

Threads
108,855
Messages
1,040,096
Members
141,300
Latest member
Torcham
Top