How to get map region from given map ID

● ARCHIVED · READ-ONLY
Started by fizzly 20 posts View original ↗
  1. 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});
              }
            }
          }
        }
  2. 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).
  3. 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?
  4. I am guessing you have two almost-identical maps and want to check what the differences are?
  5. fizzly said:
    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
  6. Jonforum said:
    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.
  7. Greetings Fizzly,

    fizzly said:
    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 ...

    dbchest said:
    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
  8. Shaz said:
    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
  9. 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!
  10. 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.
  11. like hudel say!
    puppy-coding.jpg
  12. is there no way to handle crop data with @Hudell Farming Simulator? this would be a big flaw in the plugin...
  13. I never made any farming plugin.
  14. @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.
  15. I'm working on a farming game, but I have not made any farming plugin.
  16. @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.
  17. @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?
  18. @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.
  19. 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.
  20. @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.