• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Script to change map connections

12
Posts
6
Years
    • Seen Mar 28, 2022
    Hi, I am trying to create a map that changes at a certain point in the game. I am aware that I could do this by creating multiple versions of the map and be transferred to different versions depending on a switch. Unfortunately, the area I'm trying to change is part of quite a large connected area, and there is only a small bit I'm trying to change. I could create a copy of the entire connected area, but every map transfer from every door will have to have the same conditions, and any changes I make on one map, I will have to make on others.

    I have created a short script that actually manipulates the connections.dat file and it works, but only when I close and open the game. Even leaving the map and returning doesn't work. I have noticed that when I update a connection through the debug menu, the connection changes in real time when I exit the menu. I was wondering what I need to add to my script to make this change? The player will not be on any part of the connected map when the change is made. The connections will be reset when the player starts a new game, so I am not worried about it being permanently changed.

    Code:
    def switchconnection(originalmap,newmap)
      
      data = load_data("Data/connections.dat")
      newdata= load_data("Data/connections.dat")
      for i in (0...data.length)
        if data[i][0]==originalmap #|| data[i][3]==originalmap
          newdata[i][0]=newmap
        elsif data[i][3]==originalmap
          newdata[i][3]=newmap
        else
          next
        end
        
      end
      if newdata!=data
        save_data(newdata,"Data/connections.dat")
      end
      
    end
     

    Bradman551

    Bradman
    6
    Posts
    2
    Years
    • Seen Mar 10, 2023
    I have been trying find a way to do basically the exact same thing. I want to change the map connections to a new map of viridian city in flames but I have no idea how to do it.... Did you get an answer for your question? Also would you be willing to give me a quick tutorial of how you made your script or send me somewhere that can show me?
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    Hi, I am trying to create a map that changes at a certain point in the game. I am aware that I could do this by creating multiple versions of the map and be transferred to different versions depending on a switch. Unfortunately, the area I'm trying to change is part of quite a large connected area, and there is only a small bit I'm trying to change. I could create a copy of the entire connected area, but every map transfer from every door will have to have the same conditions, and any changes I make on one map, I will have to make on others.

    I have created a short script that actually manipulates the connections.dat file and it works, but only when I close and open the game. Even leaving the map and returning doesn't work. I have noticed that when I update a connection through the debug menu, the connection changes in real time when I exit the menu. I was wondering what I need to add to my script to make this change? The player will not be on any part of the connected map when the change is made. The connections will be reset when the player starts a new game, so I am not worried about it being permanently changed.

    Code:
    def switchconnection(originalmap,newmap)
      
      data = load_data("Data/connections.dat")
      newdata= load_data("Data/connections.dat")
      for i in (0...data.length)
        if data[i][0]==originalmap #|| data[i][3]==originalmap
          newdata[i][0]=newmap
        elsif data[i][3]==originalmap
          newdata[i][3]=newmap
        else
          next
        end
        
      end
      if newdata!=data
        save_data(newdata,"Data/connections.dat")
      end
      
    end

    I have been trying find a way to do basically the exact same thing. I want to change the map connections to a new map of viridian city in flames but I have no idea how to do it.... Did you get an answer for your question? Also would you be willing to give me a quick tutorial of how you made your script or send me somewhere that can show me?

    It doesn't work because the old data is still stored in the RAM and needs to be reloaded. You can do this:
    Code:
    # At the end of the function:
    MapFactoryHelper.clear
    MapFactoryHelper.getMapConnections
    By the way, "connections.dat" doesn't exist; it's "map_connections.dat" (at least in v18 and v19).

    EDIT:
    While I don't have a clear answer as to how to create a changing map, I feel that changing the database is very dirty, and very bad practice because it is bug-inducing if you don't know perfectly what you are doing.
    For example, if the database has changed in the game, but then you (the dev) make an update, and the player replaces the old connections.dat with the updated one, but the updated one is a database at the satrt of the game, before the change has occurred?

    My guess: if it's a small part of the map that changes, just cover it with events. If it's intractable with events, just make a new map with lots of conditionals to the doors leading to it. I am afraid there is no easy way to handle this.
     
    Last edited:
    13
    Posts
    1
    Years
    • Seen Sep 17, 2022
    It doesn't work because the old data is still stored in the RAM and needs to be reloaded. You can do this:
    Code:
    # At the end of the function:
    MapFactoryHelper.clear
    MapFactoryHelper.getMapConnections
    By the way, "connections.dat" doesn't exist; it's "map_connections.dat" (at least in v18 and v19).

    EDIT:
    While I don't have a clear answer as to how to create a changing map, I feel that changing the database is very dirty, and very bad practice because it is bug-inducing if you don't know perfectly what you are doing.
    For example, if the database has changed in the game, but then you (the dev) make an update, and the player replaces the old connections.dat with the updated one, but the updated one is a database at the satrt of the game, before the change has occurred?

    My guess: if it's a small part of the map that changes, just cover it with events. If it's intractable with events, just make a new map with lots of conditionals to the doors leading to it. I am afraid there is no easy way to handle this.

    How should it change by event? I should change a small part but I haven't figured out how to do it yet.
     
    Back
    Top