no_get_name prevents multiple save files

Moderator: Moderator

Post Reply
Message
Author
edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

no_get_name prevents multiple save files

#1 Post by edge2054 »

The no_get_name option defaults NewGame.lua to this.

Code: Select all

Module:instanciate(mod, "player", true, false)
Which prevents multiple save files.

Could no_get_name instead have the player define a save_game_name that they can use instead? This way the module maker can still set the characters name to what it needs to be for the game while allowing the player to have multiple save games if they want to keep more than one character around at a time.

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: no_get_name prevents multiple save files

#2 Post by edge2054 »

Here's a work around for this. Since it's not really a bug per say but if you don't want a name set for your module you'll need another way to define the save game name.

Add this function to your newGame() function in game.lua. I did it inside local birth = Birther.new(nil, self.player, {"base", "role"}, function()

Code: Select all

function _M:registerBirthProfile()
	local birth_profile = game:registerDialog(require('engine.dialogs.GetText').new("Please enter a name for this save profile", "Save Profile", 2, 25, function(text)
		local savename = text:gsub("[^a-zA-Z0-9_-.]", "_")
		if fs.exists(("/%s/save/%s/game.teag"):format(self.__mod_info.short_name, savename)) then
			Dialog:yesnoPopup("Overwrite profile?", "There is already a game saved with this profile name, do you want to overwrite it?", function(ret)
				if not ret then
					self:setPlayerName(text)
				else 
					return self:registerBirthProfile()
				end
			end, "No", "Yes")
		else
			self:setPlayerName(text)
		end
	end))
end

Post Reply