Finding how many actors are in a project using scripting

NeptuneTron

The Salticid Scholar of the North
Veteran
Joined
Jan 13, 2018
Messages
40
Reaction score
25
First Language
English
Primarily Uses
RMMV
This is a rather unusual request, but I want to be able to find out how many actors there are in my game project using scripting, so I don't have to update the number every time I want to add another actor.

I tried using $gameActors.length(), but this did not work, I think in part due to the fact that the .json file for Game Actors essentially uses an array of arrays.

Any ideas?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,682
First Language
English
Primarily Uses
RMMZ
Code:
$dataActors.length();

I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.

 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
$gameActors refers to the party in the current game, and if there are several saved games, they might each have different content in $gameActors.

$dataActors is what you've got in your database.

What are you doing that you need to find out this number via a script, and specifically the number of actors in the project/database rather than the number of actors in the party?
 

NeptuneTron

The Salticid Scholar of the North
Veteran
Joined
Jan 13, 2018
Messages
40
Reaction score
25
First Language
English
Primarily Uses
RMMV
Thank you for all the help!

What are you doing that you need to find out this number via a script, and specifically the number of actors in the project/database rather than the number of actors in the party?
As to this, I'm running a loop that compares image information from an event to that of the database of actors to find if there's a match in a systematic way. In order to optimize the code, I want to run this loop as few times as possible, which means that the absolute maximum number of times I'd want to run it would be for as many actors as there are.

Once again, thanks for all the help!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
But the number of actors in the database is not going to change as you play the game, is it? Unless you have a plugin that creates more actors.

The number of actors in the party will change, but not the number in the database.
 

NeptuneTron

The Salticid Scholar of the North
Veteran
Joined
Jan 13, 2018
Messages
40
Reaction score
25
First Language
English
Primarily Uses
RMMV
I know the number of actors in the database isn't going to change over the course of the game, but it will over the course of development, so doing it this way means that I never have to go in and update the specific number of actors I want it to run through, as it will automatically run through the number of actors that are, and no more than that, meaning that the code is optimized for the fewest iterations without me needing to ever change the number that it measures.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top