Reply to Re: Checking globals from previous DMods?
If you don't have an account, just leave the password field blank.
Only through saved games. If you make_global_int() the same global in both D-Mods, then you can copy a savegame from the first D-Mod to the second, and when it's loaded, it'll have the same value as it had in the first game.
There is a pitfall with map data, though. Smashed barrels and such are also stored in the savegame data, and you don't want random sprites to be replaced by flat barrels or boxes, or have them not show up at all (which can happen if your quest-giving NPC just happens to have the same editor number on the same map number as a rock you exploded in the previous game).
Make sure to call clear_editor_info() whenever you load a saved game from another D-Mod. Also make sure to not call clear_editor_info() whenever you load a saved game from the same D-Mod, or else the rock you exploded in this game will show up again (and worse: that chest with the megapotion? Will have another megapotion).
Also, as Leprochaun warns, make sure the D-Mod is playable without having played the previous game. Also consider what happens if the player didn't level as much as you expect, or leveled way more than you expected. You don't want combat to be impossible, or too easy.
Hopefully, the following snippets of code will work. Beware: they are untested. Mess with savegames at your own risk
This relies on the fact that main.c gets re-run when you load a savegame. make_global_int() does nothing if the global already exists, and adds it with default value if it doesn't. Since &version does not exist in the previous D-Mod, it'll be given default value 0, which triggers the transfer code. &version does exist in this D-Mod, and is set to 1 at the start of the game, and also after importing the savegame.
There is a pitfall with map data, though. Smashed barrels and such are also stored in the savegame data, and you don't want random sprites to be replaced by flat barrels or boxes, or have them not show up at all (which can happen if your quest-giving NPC just happens to have the same editor number on the same map number as a rock you exploded in the previous game).
Make sure to call clear_editor_info() whenever you load a saved game from another D-Mod. Also make sure to not call clear_editor_info() whenever you load a saved game from the same D-Mod, or else the rock you exploded in this game will show up again (and worse: that chest with the megapotion? Will have another megapotion).
Also, as Leprochaun warns, make sure the D-Mod is playable without having played the previous game. Also consider what happens if the player didn't level as much as you expect, or leveled way more than you expected. You don't want combat to be impossible, or too easy.
Hopefully, the following snippets of code will work. Beware: they are untested. Mess with savegames at your own risk

// main.c in the "new" D-Mod. // Make sure you initialize &player_map as 0. // You set it to the starting screen in "start-1.c", or whatever script you have on the start button. make_global_int("&player_map",0); // Add this line to the list of globals. // Use a variable name that does not occur in any of the scripts of the "old" D-Mod. make_global_int("&version",0); // Add the following bit to the end: if (&player_map > 0) { // We're likely loading a game. if (&version == 0) { // This means we're loading an "old" D-Mod game. clear_editor_info(); // Do all other things here. // Resetting story-related variables if needed, removing items and spells, you name it. // Also, set this. This is important. &version = 1; } }
// In start-1.c, or whatever the script of the start button is. &player_map = 400; // The following says that we're in the "new" D-Mod. // Loading a game will see this value, and skip the transfer code. &version = 1;
This relies on the fact that main.c gets re-run when you load a savegame. make_global_int() does nothing if the global already exists, and adds it with default value if it doesn't. Since &version does not exist in the previous D-Mod, it'll be given default value 0, which triggers the transfer code. &version does exist in this D-Mod, and is set to 1 at the start of the game, and also after importing the savegame.