• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Swapping tilesets without reloading map

  • 24
    Posts
    6
    Years
    • Seen Jul 24, 2023
    Hi all,

    I've been plugging away at this problem for a while and have yet to come up with a solution. I made a post a while ago about swapping tilesets based on day/night, which works well for the most part.

    (Placed in def updateTileset in Game_Map, around line 70)
    Code:
     def updateTileset
        tilesets=[1,2,3,24,29]
        if tilesets.include?(@map.tileset_id)
          if PBDayNight.isNight?
              tileset = $data_tilesets[@map.tileset_id+40]
          else
              tileset = $data_tilesets[@map.tileset_id]
            end
        else
            tileset = $data_tilesets[@map.tileset_id]
        end

    It effectively swaps to a different tileset during nighttime. The only issue is that it will only swap tilesets when the player does something to reload the map, such as entering/exiting a building or moving far enough into a different map. I've been trying to find a way to call some kind of map update (which, I've learned, is different from a map refresh) as soon as the switches for day/night are turned on/off, but with no success. Does anyone know more about this than I do? I'd appreciate any help, even if it's just to point me in the right direction.
     
    You could try using a Common Event set to Trigger: Parallel, and use a switch to keep track of day/night. You can have it check if it turns from day to night or vice versa, and if so then update the tileset by changing "$game_map.map.tileset_id". You could try something like the following in your Common Event:

    Code:
    @>Conditional Branch: Script: [1, 2, 3, 24, 29].include?($game_map.map.tileset_id)
     @>Conditional Branch: Script: PBDayNight.isNight?
      @>Conditional Branch: Switch [XXXX: IsNight] == OFF
       @>Script: $game_map.map.tileset_id -= 40
       :       : $game_map.updateTileset
      : Branch End
     : Else
      @>Conditional Branch: Switch [XXXX: IsNight] == ON
       @>Script: $game_map.map.tileset_id += 40
       :       : $game_map.updateTileset
      : Branch End
     : Branch End
    : Branch End
    @>Script: $game_switches[XXXX] = PBDayNight.isNight?

    Where XXXX is whatever switch ID you want to use. The switch is always one step behind the current time of day, so it will know when it transitions between times. You may need to refresh or update $game_map after "$game_map.updateTileset" if this doesn't work immediately. Also, this only works for the transitions between day/night, not for map transitions. The code you currently have would still need to be there, except if you leave it in "updateTileset" then it will conflict with the code I provided above. I think you should move what you had before to the "onMapChange" proc instead, so you'll have your own code in onMapChange and my code in a common event.
     
    Sorry to come back to this so late. I tried the method that NettoHikari posted, and it achieved the same effect as my original script. The problem still lies in not being able to refresh/reload the maps Tileset graphics without switching maps entirely. Ultimately, I've decided to give up on this particular method and try to work something else out. Thanks for the help and for reading this far :)
     
    Back
    Top