Seen 12 Hours Ago
Posted 1 Week Ago
23 posts
1.3 Years
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)
 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.
Male
Seen 9 Hours Ago
Posted 1 Day Ago
68 posts
1.5 Years
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:

@>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.