Array into an array into an object

ICF-Soft

Veteran
Veteran
Joined
Aug 15, 2015
Messages
254
Reaction score
124
First Language
Spanish
Primarily Uses
RMMV
I am trying to enable an array filled with arrays throught the notebox, but I'm stuck trying to make it work and I don't know where is the problem.

It starts aliasing DataManager.isDatabaseLoaded and add notetags on enemies:

DataManager.processEnemyNotetags = function(group) { var note1 = /<(?:my notetag)>/i; var note2 = /<\/(?:my notetag)>/i; for (var n = 1; n < group.length; n++) { var obj = group[n]; var notedata = obj.note.split(/[\r\n]+/); obj.my_array = []; var esFlag = false; for (var i = 0; i < notedata.length; i++) { var line = notedata; if (line.match(note1)) { esFlag = true; } else if (line.match(note2)) { esFlag = false; } else if (esFlag) { line = line.split(":") if ((line.lenght > 1)&&(line[0] != Nan)&&(line[1] != Nan)) { obj.my_array.push(line); } } } }};So it whould recognice something like:
<my notetag>
1:1
2:5
</my notetag>

Then it checks before combat... :

ICF.myfunc.setup = Game_Enemy.prototype.setup;Game_Enemy.prototype.setup = function(enemyId, x, y) { var result = 0; var ary = $dataEnemies[enemyId]._my_array; if (ary.length == 0) { result = 0; } else if (ICF.Param.myVarAbsolute) { for (i = 0; i < ary.length; i++) { if (ary[0] == $gameVariables.value(ICF.Param.myVar)) { result = ary[1]; break; } } } else { for (i = ary.length - 1; i >= 0; i--) { if (ary[0] <= $gameVariables.value(ICF.Param.myVar)) { result = ary[1]; break; } } } ICF.myfunc.setup(enemyId, x, y);};But it throw errors on ary.length on every variation I make to the plugin.
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
You spelled length wrong, so it doesn't know what to do.

EDIT:

Just to be clear (and also because I realize that my initial comment may seem harsh), in the code you have that is checked before battles, you have mispelled 'length' as 'lenght'. If you correct it, you shouldn't encounter that issue anymore. 
 
Last edited by a moderator:

ICF-Soft

Veteran
Veteran
Joined
Aug 15, 2015
Messages
254
Reaction score
124
First Language
Spanish
Primarily Uses
RMMV
Thanks. I'll check script to see if it works now. I can't believe how had I mispell this.
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
Ya you spelled length wrong. Your logic is a bit coupled but that shouldn't affect any thing :)
 

ICF-Soft

Veteran
Veteran
Joined
Aug 15, 2015
Messages
254
Reaction score
124
First Language
Spanish
Primarily Uses
RMMV
Still not working.

TypeError

Cannot read property 'length' of undefined

 

For some reason it can't retieve the array.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
Because you are checking "_my_array", when it's called "my_array" in your first function.
 

ICF-Soft

Veteran
Veteran
Joined
Aug 15, 2015
Messages
254
Reaction score
124
First Language
Spanish
Primarily Uses
RMMV
I tried $dataEnemies[enemyId]._my_array$dataEnemies[enemyId].my_array$dataEnemies(enemyId)._my_array; and $dataEnemies(enemyId).my_array;

None of these works.

Only the one showed in my function doesn't throw an undefined error.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top