Illusion
RMXP game maker
- 155
- Posts
- 20
- Years
- Seen Oct 17, 2011
Create a new script and name it Module_SaveData
Then in Main add this(Just before Graphics.freeze):
This will make other users able to change the game font if their computer does'nt have the desired font.
To change the default font or size change these lines:
If Font index equals 0 then the default font will be Tahoma.This is because Tahoma is the first name in the variable Fonts.
To save the game at any stage do SaveData.autosave and to save SaveData.autoload.
Illusion
Code:
#-----------------------------------------------------------------------------
#¸.•'´¯)¸,ø¤``¤ø,¸ (´¨`··•·SaveData module ; Illusion·•·´¨`) ¸,ø¤``¤ø,¸(¯`'•.¸· ·
# ∂Ħ∫ДΔ|}-{_') (Version 0.5) ('_}-{|ΔД∫Ħ∂
#-----------------------------------------------------------------------------
module SaveData
Fonts = ['Tahoma', 'Pokemon RS', 'Curlz MT', 'Bradley Hand ITC', 'Comic Sans MS']
Sizes = [16, 18, 20, 22, 24, 26]
Font_index = 4
Size_index = 3
module_function
#-----------------------------------------------------------------------------
#¸.•'´¯)¸,ø¤``¤ø,¸ (´¨`··•·Save Font·•·´¨`) ¸,ø¤``¤ø,¸(¯`'•.¸· ·
#-----------------------------------------------------------------------------
def savefont
file = File.open("Font.txt", "wb")
file.write("Font Name: #{$fontname}\nFont Size: #{$fontsize}\nIf you have problems with the font change these lines.")
file.close
end
#-----------------------------------------------------------------------------
#¸.•'´¯)¸,ø¤``¤ø,¸ (´¨`··•·Load Font·•·´¨`) ¸,ø¤``¤ø,¸(¯`'•.¸· ·
#-----------------------------------------------------------------------------
def loadfont
if FileTest.exist?("Font.txt")
data = IO.readlines("Font.txt")
data[0] = data[0].chomp("\n")
data[1] = data[1].delete("Font Size: ").to_i
data[0][0...11] = ""
$defaultfonttype = $fontface = $fontname = Font.default_name = data[0]
$fontsize = $defaultfontsize = $fontsize = Font.default_size data[1]
end
end
#-----------------------------------------------------------------------------
#¸.•'´¯)¸,ø¤``¤ø,¸ (´¨`··•·Auto Save·•·´¨`) ¸,ø¤``¤ø,¸(¯`'•.¸· ·
#-----------------------------------------------------------------------------
def autosave
file = File.open("autosave.rxdata", "wb")
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($pkmn, file)
@bgm = $game_system.playing_bgm
Marshal.dump(@bgm, file)
file.close
end
#-----------------------------------------------------------------------------
#¸.•'´¯)¸,ø¤``¤ø,¸ (´¨`··•·Auto Load·•·´¨`) ¸,ø¤``¤ø,¸(¯`'•.¸· ·
#-----------------------------------------------------------------------------
def autoload(map = 0)
if FileTest.exist?("autosave.rxdata")
file = File.open("autosave.rxdata", "rb")
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$pkmn = Marshal.load(file)
@bgm = Marshal.load(file)
$game_party.refresh
$game_map.update
if map == 1
$game_party.refresh
$game_map.update
$game_system.bgm_play(@bgm)
$scene = Scene_Map.new()
elsif map == 2
Graphics.freeze
$scene = Info.new('Loaded from autosave file.', @bgm)
end
file.close
end
end
#-----------------------------------------------------------------------------
#¸.•'´¯)¸,ø¤``¤ø,¸ (´¨`··•·Save·•·´¨`) ¸,ø¤``¤ø,¸(¯`'•.¸· ·
#-----------------------------------------------------------------------------
def save(filename = 'Save1.rxdata', vars = ['$game_system', '$game_switches',
'$game_variables', '$game_self_switches', '$game_screen', '$game_actors',
'$game_party', '$game_troop', '$game_map', '$game_player'])
file = File.open(filename, "wb")
for i in 0...vars.length
eval('Marshal.dump('+vars[i]+', file)')
end
file.close
end
#-----------------------------------------------------------------------------
#¸.•'´¯)¸,ø¤``¤ø,¸ (´¨`··•·Load·•·´¨`) ¸,ø¤``¤ø,¸(¯`'•.¸· ·
#-----------------------------------------------------------------------------
def load(filename = 'Save1.rxdata', vars = ['$game_system', '$game_switches',
'$game_variables', '$game_self_switches', '$game_screen', '$game_actors',
'$game_party', '$game_troop', '$game_map', '$game_player'])
if FileTest.exist?("Font.txt")
file = File.open("Font.txt", "rb")
for i in 0...vars.length
eval(vars[i]+'= Marshal.load(file)')
end
file.close
end
end
end
Code:
unless FileTest.exist?('Font.txt')
$defaultfonttype = $fontface = $fontname = SaveData::Fonts[SaveData::Font_index]
$fontsize = $defaultfontsize = $fontsize = SaveData::Sizes[SaveData::Size_index]
else
SaveData.loadfont
end
SaveData.savefont
To change the default font or size change these lines:
Code:
Fonts = ['Tahoma', 'Pokemon RS', 'Curlz MT', 'Bradley Hand ITC', 'Comic Sans MS']
Sizes = [16, 18, 20, 22, 24, 26]
Font_index = 4
Size_index = 3
To save the game at any stage do SaveData.autosave and to save SaveData.autoload.
Illusion