One of the scenes is disposed immediately. Is this because we only have reference to one of the maps (eg: $game_map) and so the other is eliminated? I'm not sure if there are actually two instances of SceneManager or just one. We might have to make it so that there are two.
For global variables, I was thinking maybe we can do something like
1: change DataManager to a class, and have each instance create their own DataManager
2: replace all references to $game_... and change them to DataManager method calls, such as DataManager.player.____
DataManager holds references to @game_player, @game_map, etc. which is basically the same as what $game_player and $game_map were for and then we don't need to duplicate code at all.
We would still keep certain global variables, but they have to be updated to be thread-safe. For example, $game_actors might be shared between both instances. You can't have duplicate actors, but each player can choose who they want in their party.
I don't mind breaking compatibility with every script if we have to; I just don't want duplicate code, nor do I want to hardcode anything like indices. DataManager and SceneManager should handle all instance-specific details internally.
....
Another (very hack-ish, might not be possible) way is to possibly change object access.
For example, suppose I define
Code:
class Game_Players
def initialize
@data = [Game_Player.new, Game_Player.new]
end
def .
return @data[SceneManager.id]
end
end
This means that everytime we say
It actually is an array access and returning a specific Game_Player object.
LOL that would be so bad, but it would make testing really simple...
....
For sprites, they are just specified using their x,y coordinates and is based on the viewport they are drawn in. Which means you basically don't have to touch them! An example is the sprites on the map (Sprite_Character)
As for VX...
Code:
def initialize(actor)
super(0, 0, 544, 416) # lol
@actor = actor
refresh
end
EDIT:
lol how about this for some quick testing
Code:
class Game_Players
def initialize
@data = [Game_Player.new, Game_Player.new]
end
def method_missing(method)
@data[SceneManager.id].send(method)
end
end
$game_player = Game_Players.new
$game_player.do_something
# no method exception? Find the correct player to call the method on
I thought it was pretty amusing since our wrapper classes can just contain no real method definitions and so method_missing will almost always be invoked......
Note that this is not a serious solution. The fact that we're relying on exceptions to get things to work is just silly. However if it helps eliminate the global variable problem so that we can get on with the rest of the script it's not too bad...