Status
Not open for further replies.

Furia25

Villager
Member
Joined
Mar 18, 2019
Messages
17
Reaction score
5
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
2,743
Reaction score
2,096
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
17
Reaction score
5
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
17
Reaction score
5
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
8,920
Reaction score
5,847
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

Happy Friday, y'all! I just got home from work and am sitting down with a nice cider, and I'm ready to chill and enjoy myself. Not sure if I'm gonna dive into any of my game-related projects or not tonight.... we'll see how I feel after unwinding for a bit I guess!
Just found out that mint tea made from chocolate mint tastes a bit like hot cocoa with candy cane stirred in. As I'm allergic to chocolate this makes me very happy.
It's special day for me tomorrow so time to vanish for 24 hours lol.
So Deltarune Chapter 2 is supposed to release today... if it's out already, has anyone played it? And I can't because I have a stinking Mac and not a Windows PC.

Forum statistics

Threads
115,140
Messages
1,087,554
Members
149,650
Latest member
devdezzy
Top