Status
Not open for further replies.

Furia25

Villager
Member
Joined
Mar 18, 2019
Messages
18
Reaction score
8
First Language
French
Primarily Uses
RMMV
Hello, this is my first thread. (I am on mv)
Sorry for my potentially bad english, this is not my first language.

It's a very precise question, i'd like to count how many of specific region are in a map in a script.
Pictures are better than words.

1628093529377.png
For example the script/function will return 38 tiles,
Sorry, I can't express myself well, thank you in advance for your help.
PS : I looked in rpg_object.js, but nothing that tells me how...
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
5,019
Reaction score
4,346
First Language
EN
Primarily Uses
RMMZ
You will need to loop through all tiles on the map and check the region ID of each one, e.g.
JavaScript:
var n = 0; for (var x = $gameMap.width(); x--;) for (var y = $gameMap.height(); y--;) if ($gameMap.regionId(x, y) === 111) n++; n
This is written for use in an eval, e.g. Control Variables -> Script. Explanation:
  • var n = 0; => initialise tile counter
  • for (var x = $gameMap.width(); x--;) => loop through all x values
    for (var y = $gameMap.height(); y--;) => loop through all y values
  • if ($gameMap.regionId(x, y) === 111) n++; => +1 to counter if the region is 111
  • n => return the value of the counter
Details on the for loop in JavaScript:
 

Furia25

Villager
Member
Joined
Mar 18, 2019
Messages
18
Reaction score
8
First Language
French
Primarily Uses
RMMV
You will need to loop through all tiles on the map and check the region ID of each one, e.g.
JavaScript:
var n = 0; for (var x = $gameMap.width(); x--;) for (var y = $gameMap.height(); y--;) if ($gameMap.regionId(x, y) === 111) n++; n
This is written for use in an eval, e.g. Control Variables -> Script. Explanation:
  • var n = 0; => initialise tile counter
  • for (var x = $gameMap.width(); x--;) => loop through all x values
    for (var y = $gameMap.height(); y--;) => loop through all y values
  • if ($gameMap.regionId(x, y) === 111) n++; => +1 to counter if the region is 111
  • n => return the value of the counter
Details on the for loop in JavaScript:
Thank you very much I'll try this :kaoluv:
 

Furia25

Villager
Member
Joined
Mar 18, 2019
Messages
18
Reaction score
8
First Language
French
Primarily Uses
RMMV
You will need to loop through all tiles on the map and check the region ID of each one, e.g.
JavaScript:
var n = 0; for (var x = $gameMap.width(); x--;) for (var y = $gameMap.height(); y--;) if ($gameMap.regionId(x, y) === 111) n++; n
This is written for use in an eval, e.g. Control Variables -> Script. Explanation:
  • var n = 0; => initialise tile counter
  • for (var x = $gameMap.width(); x--;) => loop through all x values
    for (var y = $gameMap.height(); y--;) => loop through all y values
  • if ($gameMap.regionId(x, y) === 111) n++; => +1 to counter if the region is 111
  • n => return the value of the counter
Details on the for loop in JavaScript:
[SOLVED] Thanks ! Have a nice day :kaoluv:
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
10,402
Reaction score
6,583
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Obvious One.gif
Meet my new mascot. He's also a mimic! No prizes for guessing this guy's name, though, haha
BANNER2.png
I put out a new pack and I swear, I did not realize how it looks like the ones on the right are scared/nervous of the one on the left until way after o_O I just wanted to showcase some of them randomly xD
Well, if anyone has a funny, simple, easy RM game they want me to playtest/review, I would love it.
Someone close to me straight up told me they didn't think my relationship with my girlfriend would last. No lead up, very bluntly. Like it's obvious or something. Trying not to let it get to my head, but it's hard.
The distraction would be a life saver.
QuestMZPlugin.png

My first foray into a plugin that I plan to release. Working on something for those who want to set up a Dragon Quest style battle HUD with minimal fuss. Includes the ability to round the battleback corners to fit your windowskin and, of course, front-view animations.

QuestMZPLugin_CustomWindow.png
Do you ever wonder where the heck everyone is going at 9:00 at night? Like... guys, go home! Get some sleep! Me? Oh, I'm out to get pizza 'cause I decided supper time was 9:30 tonight.

Forum statistics

Threads
134,756
Messages
1,250,346
Members
177,516
Latest member
uglychristmassweaterbio
Top