How to get map region from given map ID

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
744
Reaction score
474
First Language
Polish
Primarily Uses
RMMV
In short: I have 2 maps: 10 and 36. While visiting 36 I want to get all tileEventsXy from map 10. Is it possible?

Below my example script. It will return all tiles for given `region`. I would like to add 2nd parameter, which will be mapId

Code:
    /**
    * @return array
    * returns tiles with available events for given region
    */
    Game_Interpreter.prototype.getRegionActiveTileList = function(regionId) {
    var tileList = [];
    for (var x = 0; x < $gameMap.width(); x++) {
      for (var y = 0; y < $gameMap.height(); y++) {
        if ($gameMap.eventsXy(x, y).length !== 0) {
          if ($gameMap.regionId(x, y) == regionId) {
            tileList.push({x : x, y : y});
          }
        }
      }
    }
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,425
Reaction score
7,710
First Language
German
Primarily Uses
RMMV
Only the current map is in memory, and only that maps region IDs can be directly accessed.
To read the region IDs of a different map you need to first load that other map into a new data structure (you can't overwrite the current map while doing that).
 

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
this seems like one of those times where if you better articulate what your main goal is, some one may be able to provide a better solution than your current way of doing things; i.e. why do you need to know the number of events on a different map than the one you're playing on?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I am guessing you have two almost-identical maps and want to check what the differences are?
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,440
First Language
French
Primarily Uses
RMMV
In short: I have 2 maps: 10 and 36. While visiting 36 I want to get all tileEventsXy from map 10. Is it possible?

Below my example script. It will return all tiles for given `region`. I would like to add 2nd parameter, which will be mapId

Code:
    /**
    * @return array
    * returns tiles with available events for given region
    */
    Game_Interpreter.prototype.getRegionActiveTileList = function(regionId) {
    var tileList = [];
    for (var x = 0; x < $gameMap.width(); x++) {
      for (var y = 0; y < $gameMap.height(); y++) {
        if ($gameMap.eventsXy(x, y).length !== 0) {
          if ($gameMap.regionId(x, y) == regionId) {
            tileList.push({x : x, y : y});
          }
        }
      }
    }

hi!
PHP:
var myMapID = $gameMap._mapId; // current map id
! or am not fully understand what you try to do !
what you do with event seem ok
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
or am not fully understand what you try to do !
He wants to look at a region id on a given tile on a different map to the map he is on. Only one map (the map you are on) is loaded into memory at any one time. So the data is not available for the map he wants to pull the region id from.
 

Joy Diamond

Talkative
Veteran
Joined
Nov 12, 2017
Messages
135
Reaction score
173
First Language
English
Primarily Uses
RMMV
Greetings Fizzly,

In short: I have 2 maps: 10 and 36. While visiting 36 I want to get all tileEventsXy from map 10. Is it possible?
It's certainly possible & easy ... but ...

this seems like one of those times where if you better articulate what your main goal is, some one may be able to provide a better solution than your current way of doing things; i.e. why do you need to know the number of events on a different map than the one you're playing on?
+1. Agreed. We need to better understand what you are trying to do. You can very easily "get all the tileEventsXy from map 10" ... using them though ... that is a totally different & much much more difficult issue .... so ... can you articulate what your main goal is please?​

Thanks,

Joy Diamond
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,440
First Language
French
Primarily Uses
RMMV
He wants to look at a region id on a given tile on a different map to the map he is on. Only one map (the map you are on) is loaded into memory at any one time. So the data is not available for the map he wants to pull the region id from.
ok yes , the only way its load the JSON data , but this will affect a lot performance.
am not remanber how map region work, but its load in Scene manager, so only the current map.
But you can load the JSON data from other map, this is not a problem as long as you load them also in the loading phase.

am not rember , but you have a script from dev here , he do this

EDIT: ok am rember this plugin
https://forums.rpgmakerweb.com/index.php?threads/orange-custom-events.46527/
look around source code, it allow you to target what you need .
and dont forget to give a bone to @Hudell
 
Last edited:

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
744
Reaction score
474
First Language
Polish
Primarily Uses
RMMV
What I'm trying to do is simple field system. I want to check is crop watered on field map (but it should be checked while going to sleep in house - other map). And that's where my problem is... I'm using Orange Custom Events as well, I'll check the code then! Thanks guys and thanks to @Hudell for making Orange Custom Event!
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
My suggestion would be to change how things work a little:
  • Save crop state using variables
  • Instead of saving the copied events to the map, create them as temporary and re-generate them every time you enter the map, based on the variable values.
  • Check the variable values when you're on the other maps.
Something like that would use a lot of variables, but with some JS code you can easily loop through them.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,440
First Language
French
Primarily Uses
RMMV
like hudel say!
 

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
is there no way to handle crop data with @Hudell Farming Simulator? this would be a big flaw in the plugin...
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
I never made any farming plugin.
 

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
@Hudell apologies, i have seen you represent a farming simulator multiple times around the forums and assumed you played a role in its development. i hope i did not offend.

regardless, whichever farming simulator plugin is being used, if the individual who wrote it did not provide a way to store and manage the player's crop data conveniently, then in my opinion, the plugin is fundamentally flawed. this is why all important elements of RPGMaker are stored in global variables; it allows access to them whenever the need arises, regardless of the current state of the game.

as it stands, developers are forced to figure out how to manipulate the data on their own; this is not very intuitive as the developer will probably encounter many problems over the course of development. developers may even find that the plugin does not help them accomplish the things they expected from a farming simulator. a curious thing...

anyway, you are going to need to manually store crop data before transitioning off the map if you want to reference that data while off the map. you will make your changes to the data as you see fit, but then you will need to manually apply that data when you re-enter the farm.

^^so much easier if the plugin creator integrated this into the plugin.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
I'm working on a farming game, but I have not made any farming plugin.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,425
Reaction score
7,710
First Language
German
Primarily Uses
RMMV
@dbchest
Farming does not need a dedicated plugin, almost every farming function can be done by events as long as you augment them with a few additional functions like self-variables and event-based timers. And there are already plugins for that.
 

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
@Andar i agree with you, but pros and cons, right? having a plugin perform some small back-end labor could definitely give the developer some convenience when they encounter situations like the one being discussed here, no?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,425
Reaction score
7,710
First Language
German
Primarily Uses
RMMV
@dbchest no, plugins are not automatically better than eventing, it always depends on what a developers wants.
Sometimes a plugin is the solution, especially if something cannot be done otherwise.
But other times it is much easier to use the existing engine framework with events, because it is too much work to reprogram that in a plugin.

And farming is one of the areas where eventing will always be better as a plugin due to customisation. Every farming game will have its own different seeds and items and skills, and using a plugin you would be limited to the options given by the plugin.
So unless you pay someone for an exclusive custom plugin, your game will be better if you use events with your own custom item and seed list.
 

Joy Diamond

Talkative
Veteran
Joined
Nov 12, 2017
Messages
135
Reaction score
173
First Language
English
Primarily Uses
RMMV
Greetings,

Summary:
The difference between theory & reality is that:
  • In theory, they are the same;
  • In reality, they are different.
Details:

A plugin can, from a theoretical functionality point of view, do a better job than using the existing engine framework.

The problem is, that is theoretical point of view, and not reality.
  • Reality is: The real issue is transfer of knowledge (from the creator of the software to the user of the product)
Regarding transfer of knowledge:
  • RPG Maker MV has done a superb job of creating a simple interface that is "SIMPLE enough for a child", and that whole interface is supported by an active community, tons of tutorials, examples, and tested & used by thousands of people.
  • Thus the transfer of knowledge issue has been solved, and solved well.
  • A new person can quickly learn how to make event, etc, and create a reasonable farming game.
Now a plugin, can be way more powerful than the existing engine frame work; however, it fails on transfer of knowledge (how to use it):
  • For the developer of a plugin, it seems, oh ... this is so easy to use ... and so much more powerful than using the limitations of RPG Maker MV;
  • However, for the user of the plugin ... they don't know how to use the plugin --- as it is lacking in proper transfer of knowledge (i.e.: the whole active community, tons of tutorials, examples, and tested & used by thousands of people).
  • In fact, if you read the boards for the majority of plugin's here, transfer of knowledge, is the limiting factor in their more popular adoption & use.
Thus writing a good plugin to solve the farming problem is insufficient, you also need to solve the whole transfer of knowledge issue. Unless that issue is properly resolved (and resolving it is about 100x to 1000x harder than writing a plugin):
  • Then, in reality, using the existing engine framework (with it's successful transfer of knowledge) is the far superior choice.
Conclusion:

I mostly agree with Andar; with the exception, if you *COULD* solve the transfer of knowledge issue, then a plugin would be better (however, solving the transfer of knowledge issue is really really hard).​


Playfully,

Joy Diamond.

P.S.: Also regarding "from the creator of the software to the user of the product":
  • That is a major issues, plugin makers, in general create software; however users want a product.
  • The two are vastly different.
  • Products are 10x to 100x harder than software.
 

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
@Andar it was not my intention to imply that plugins were automatically better than eventing; i am an advocate for finding the best possible solution for problems, albeit event or plugin creation, and often times it is plugins that work in tandem with eventing that give us the most creative power as developers.

fundamentally, however, it is my opinion that eventing is more limited than plugins, because we only have control of whichever elements the editor programmers gave us (they do a really good job too, in my opinion) through eventing, but plugins give developers more power in that they can grant us access to all elements of the engine and allow us to create new data structures to handle that information as well.

a well-crafted plugin that works with eventing to manage crop data would be the route i would take, personally, but a nice farming system can be accomplished solely through eventing.

i would like to add that a plugin for a farming system would not require any heavy reprogramming of the default functionality; a good plugin for this kind of system would serve to extend the Game_Event class mostly, providing plugin commands for managing crop data, and as an extension the plugin would not limit users in any way.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,354
Members
137,801
Latest member
topsan
Top