Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,634
Reaction score
1,453
First Language
French
Primarily Uses
RMMV
Hi


I am building my quest system.
I use for Quests the Rmmv Armors Items, $dataArmors[], because I do not use this DB in my project.
At the beginning of the game, I inject all in $dataArmors [?].meta my individually properties for Quest.
I write them in a .js file, because the comment window in the software is too difficult to manage.


My question is about my access to my SubQuests.
To access it, I currently use this, 'is work good but i dont like the way to acces'


$dataArmors[1].meta.Quest['SubQ'+0].title  // return the title from meta.Quest.SubQ0
$dataArmors[1].meta.Quest['SubQ'+0].Desc[0]  // return the Desc LV1 from meta.Quest.SubQ0


Here a example of the builder when the project boot,
You can see the SubQ0: { , he define all what are the SubQ0

$dataArmors[1].meta.Quest = {
SubType:['recipe', ' Item', 'switch'],// type et total number of subquest in Quest1
Status:false,
IsFinish: function check() {},//need to make a function to check all SubQ // .meta.Quest['SubQ'+id]
//SubQuest Custom edit for $dataArmors[1]
SubQ0: {
isfinish: CheckRecipe(154);
title:'title',
Desc:['description lv1 int ',
'more description lv2 int ',
'more more more description lv3 int '],
}
SubQ1: { } // ....
SubQ3: { } // ....

};



*But I would like to know if it would be possible to access , like this way.
I find this way a cleaner way to manage.



$dataArmors[1].meta.Quest.SubQ[0].title   // return the title from meta.Quest.SubQ[0]
$dataArmors[1].meta.Quest.SubQ[0].Desc[0]  // return the Desc LV1 from meta.Quest.SubQ0


So i build my attribut like thas , but i get  Uncaught SyntaxError: Unexpected token [

$dataArmors[1].meta.Quest = {
SubType:['recipe', ' Item', 'switch'],// type et total number of subquest in Quest1
Status:false,
IsFinish: function check() {},//need to make a function to check all SubQ // .meta.Quest['SubQ'+id]
//SubQuest Custom edit for $dataArmors[1]
SubQ: {
[//SubQ0
isfinish: CheckRecipe(154);
title:'title',
Desc:['description lv1 int ',
'more description lv2 int ',
'more more more description lv3 int ']
]
[],//SubQ1
[]//SubQ2....

}

};



Is that I put it wrong syntax, or simply not possible to build this way.
I'm not an expert in javascript but I'm wondering about this.
Have you some suggestion , am do a mistake ??


Tell me if I am not clear in my explanation, I did my best.
Thank you
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,699
Reaction score
940
First Language
English
Primarily Uses
N/A
Well without seeing any information on the error, it's a bit hard to debug it, but just by looking at it, I'm 95% sure your format is wrong. SubQ is an object that you try to cram an array into, but you didn't give that array a key to access it with. This is almost definitely invalid.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,634
Reaction score
1,453
First Language
French
Primarily Uses
RMMV
@Zalerinian


ok to be more clean.
I want something like this.
A array dynamic property object


var SubQ =[]; // now work Uncaught SyntaxError: Unexpected token [
$dataArmors[1].meta.Quest = {
SubQ[0]: {
title:'Title ',
}
SubQ[1]: {
title:'Title ',
}
}




This no work but ideally i want a easy access similar to this. :)


var i = 0;
$dataArmors[1].meta.Quest.SubQ.title  // return me title SubQ[0]
var i = 1;
$dataArmors[1].meta.Quest.SubQ.title  // return me title SubQ[1]




is my SyntaxError or is not possible to use named array for define a property like this in a object constructor ?
 
Last edited by a moderator:

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
453
Reaction score
211
First Language
English
Primarily Uses
RMMV
Believe it should be more like the following as an example:


var Quest = {
SubQ: [{title: 'A Title'}, {title: 'Another Title'}]
};


Then you can call the way you want:

Code:
Quest.SubQ[0].title; // 'A Title'
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,699
Reaction score
940
First Language
English
Primarily Uses
N/A
$dataArmors[1].meta.Quest = {
SubQ:
[
{
title: 'Title 1',
},
{
title: 'Title 2',
}
]
}




this is how you use an array in JSON, @Jonforum
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,634
Reaction score
1,453
First Language
French
Primarily Uses
RMMV
@Zalerinian @Sarlecc @nio kasgami


NICE NICE NICE  :D
Thank you very much everyone, I am very happy now and I learned something new.
You are all super


USE directly the JSON, This is a very good idea, but I gave up when I saw the formatting.
I find the syntax and formatting difficult to read.


JSON formating  :headshake:

Captdsfsfure.JPG



VS


JS formating

adfaf.JPG





And I do not yet know the language used.


Maybe study it soon :)
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
708
Reaction score
638
First Language
English
Primarily Uses
RMMV
USE directly the JSON, This is a very good idea, but I gave up when I saw the formatting.
I find the syntax and formatting difficult to read.


JSON formating  :headshake:






 

The formatting is not usually like that but because it's stringified before it's saved it shows up lke this. If you want to read the json, use a beautify extension in your editor or the native code formatting tool to get the original format back. Using my editor I was able to get the format to look like this.


Screenshot_1.png


The way you're doing things is fine but don't be scared of using a JSON file because of the way it looked, hopefully, this helps you become less worried about JSON.
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
562
Reaction score
807
First Language
English
Primarily Uses
RMMV
You can use JSON.stringify (data, null, '\t') to format it better. I use it with my own plugins.
 

Latest Threads

Latest Posts

Latest Profile Posts

Hmm... Game has 91 views, 25 downloads, 5 reviews and netted me 7 additional followers. Meanwhile the image I posted just yesterday on Imgur to showcase it has 45,197 views. Interesting, I think I have a new advertising idea. Also Twitter? The post got 16 retweets, 20 likes, and 1,683 views.... And a whole 3 hits to my game, completely valueless. I am glad I did this game jam, this information is quite valuable.
We're playing another Touch the Stars game jam entry, come join us! :D
Ok is telling someone that their drawing isnt good rude
I'm familiar with MZ thanks to jam now. I say it's a better working and looking MV. Lots of plugins too and FOSSIL helps alot. It's not bad.
Some more progress <3 and in most important news:
ALPACARAPTOR SPRITE! (not animated yet, though :( )
h4u90Sz.png

Forum statistics

Threads
113,654
Messages
1,076,468
Members
147,676
Latest member
Tasty_Fruit
Top