Hello everyone! I'm new here! :haha:
By the way, I was wondering if someone has already done or is working to a script that let the player share a map with the other players.
Well... I try to explain it better.
I'm creating a game (offline-MMORPG style, like .hack), and I want to create a map of the game where the player can create his own village (with events, Dynamic Maps System, no matter).
After that I'd like that the player has the possibility to Export this map in the Game Folder (such as a Save File, which saves only the switches/variables of that map) and can share (with internet) this file with others.
So the player 2 download this "Export file", put in his Game Folder (same game, of course), goes in that map - and an event open a System that load this "Export file" (it loads only the switches of this map), and can play that map created buy the player 1 (or, if he wants, he doesn't load that file and he creates his map himself).
Is it possible (or already done)?
I know it isn't something simple to create, but I also know it isn't impossible to do (but in scripting, I'm a n00b :^_^':), and this system would be something really great (the game would be longer, with players that shares all their maps...).
Someone want to help me, or give me feedback to let me understand how I can make it myself? Tnx! 8)
is it possible.... probably..
will someone make it(or explain it).... highly unlikely.
QuoteI know it isn't something simple to create
you are not even close....
Quote from: Jackolas on April 15, 2010, 07:07:30 am
is it possible.... probably..
will someone make it(or explain it).... highly unlikely.
QuoteI know it isn't something simple to create
you are not even close....
Mmh... I've found a script that, with my right edits, can do this. :p
Now, the problem is another one...
Is it possible to save in a Save File only a tot. of switches?
I explain what I mean...
In the Scene_Save script there is this command:
Marshal.dump($game_switches, file)
But this one saves all the switches of the game, but I need that saves only, for example, from $game_switches[1] to $game_switches[10]. Is it possible? :ninja:
might try Marshal.dump($game_switches[10], file)
No, it doesn't work this way... :'(
Yes it would work.
Saving:
Marshal.dump($game_switches[10], file)
Loading:
$game_switches[10] = Marshal.load(file)
Ok, I'll try once again.
And for a period of switches?
For example, from switch 10 to switch 100, what should I write?
i would try either
Marshal.dump($game_switches[10...100], file)
or
(10...100).each {|i| Marshal.dump($game_switches[i], file)}
Ok, tnx.
Now, I'm tryng to create Scene_Save2 and Scene_Load2, which allow to save/load only switches and/or variables...
But every time I save or load, it save me not only the switches and the variables, but also all the rest (system, player, ecc...).
I tried more, and I was able to make it save/load only switches and variables, but it loads all of them, not only one or another.
Hpw is it possible?
here this works allows to to use script calls save and load
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
def save
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open('Switches', "wb")
(10...100).each {|i| Marshal.dump($game_switches[i], file)}
file.close
return true
end
def load
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open('Switches', "rb")
(10...100).each {|i| $game_switches[i] = Marshal.load(file)}
file.close
return true
end
end
Sorry, I don't understand.
This class Interpreter, have I to insert that first of Main, after Scene_Debug, right?
But what does it do exactly?
It loads from the save files only the switches, or it does other?
(Sorry, I'm quite a noob :D)
EDIT: in other words, can someone create me a Scene_Save and Scene_Load script which only save and load switches and variables?
Those have nothing other to do, only save and load switches and variables (and self_switches).
Tnx! :)
Interpreter is what is used when you do any thing in an event so if you use the script i gave you when you put save using the script call it will make a file called switches and put what switches 10-100 are and if you call load it will load those switches and yea above main or all of Blizzards scripts
You said I've to usa a call script to make it work.
But what have I to write on that call script to make it work?
Because I've tryed to save and load, but it has not create any "Switch" file...
are you sure because when i used it worked just fine all i did was put the word save no capitalization to save it and load to load what was in the file switches
Ok, I tryed once more and it worked perfectly! Really tnx, man! ;)
Now, one more question.
I have saved with this class all switches from 10 to 100, right?
Than I put this "save file" in another (same) copy of my game, if I load this file, it will do the same job, and will put all the switches from 10 to 100 true or false, right?
No problem, no bugs, right?
However, I'm using those script (taken from the creationasylum.net "Export & Import System" and modified by me).
Can you control, guys, if I have wrote the script in the right way?
(I'm Italian, so you'll find some italian words)
Window_ExportFile#==============================================================================
# ** Window_SaveFile
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================
class Window_ExportFile < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :exportname # file name
attr_reader :selected # selected
#--------------------------------------------------------------------------
# * Object Initialization
# file_index : save file index (0-3)
# filename : file name
#--------------------------------------------------------------------------
def initialize(file_index, exportname)
super(0, 64 + file_index % 4 * 104, 640, 104)
self.contents = Bitmap.new(width - 32, height - 32)
@file_index = file_index
@exportname = "E#{@file_index + 1}.export"
@file_exist = FileTest.exist?(@exportname)
if @file_exist
export = File.open(@exportname, "r")
@characters = Marshal.load(export)
@frame_count = Marshal.load(export)
export.close
end
refresh
@selected = false
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Draw file number
self.contents.font.color = normal_color
name = "Export #{@file_index + 1}"
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
# If save file exists
if @file_exist
# Draw character
for i in 0...@characters.size
bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
cw = bitmap.rect.width / 4
ch = bitmap.rect.height / 4
src_rect = Rect.new(0, 0, cw, ch)
x = 300 - @characters.size * 32 + i * 64 - cw / 2
self.contents.blt(x, 68 - ch, bitmap, src_rect)
end
end
end
#--------------------------------------------------------------------------
# * Set Selected
# selected : new selected (true = selected, false = unselected)
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor_rect
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @selected
self.cursor_rect.set(0, 0, @name_width + 8, 32)
else
self.cursor_rect.empty
end
end
end
Scene_ExportFile#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This is a superclass for the save screen and load screen.
#==============================================================================
class Scene_ExportFile
#--------------------------------------------------------------------------
# * Object Initialization
# help_text : text string shown in the help window
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window
@help_window = Window_Help.new
@help_window.set_text(@help_text)
# Make save file window
@exportfile_windows = []
for i in 0..3
@exportfile_windows.push(Window_ExportFile.new(i, make_exportname(i)))
end
# Select last file to be operated
@file_index = $game_temp.last_file_index
@exportfile_windows[@file_index].selected = true
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
for i in @exportfile_windows
i.dispose
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
for i in @exportfile_windows
i.update
end
# If C button was pressed
if Input.trigger?(Input::C)
# Call method: on_decision (defined by the subclasses)
on_decision(make_exportname(@file_index))
$game_temp.last_file_index = @file_index
return
end
# If B button was pressed
if Input.trigger?(Input::B)
# Call method: on_cancel (defined by the subclasses)
on_cancel
return
end
# If the down directional button was pressed
if Input.repeat?(Input::DOWN)
# If the down directional button pressed down is not a repeat,
# or cursor position is more in front than 3
if Input.trigger?(Input::DOWN) or @file_index < 3
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Move cursor down
@exportfile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % 4
@exportfile_windows[@file_index].selected = true
return
end
end
# If the up directional button was pressed
if Input.repeat?(Input::UP)
# If the up directional button pressed down is not a repeat、
# or cursor position is more in back than 0
if Input.trigger?(Input::UP) or @file_index > 0
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# Move cursor up
@exportfile_windows[@file_index].selected = false
@file_index = (@file_index + 3) % 4
@exportfile_windows[@file_index].selected = true
return
end
end
end
#--------------------------------------------------------------------------
# * Make File Name
# file_index : save file index (0-3)
#--------------------------------------------------------------------------
def make_exportname(file_index)
return "E#{file_index + 1}.export"
end
end
Scene_Export (=Save)#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Export < Scene_ExportFile
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super("Quale file vuoi esportare?")
end
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision(exportname)
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
export = File.open(exportname, "wb")
write_save_data(export)
export.close
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(export)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# Write character data for drawing save file
Marshal.dump(characters, export)
# Increase save count by 1
$game_system.export_count += 1
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
(10...100).each {|i| Marshal.dump($game_switches[i], export)}
Marshal.dump($game_self_switches, export)
end
end
Scene_Import (=Load)#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Import < Scene_ExportFile
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Remake temporary object
$game_temp = Game_Temp.new
# Timestamp selects new file
$game_temp.last_file_index = 0
for i in 0..3
exportname = make_exportname(i)
if FileTest.exist?(exportname)
export = File.open(exportname, "r")
export.close
end
end
super("Quale file vuoi importare?")
end
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision(exportname)
# If file doesn't exist
unless FileTest.exist?(exportname)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play load SE
$game_system.se_play($data_system.load_se)
# Read save data
export = File.open(exportname, "rb")
read_save_data(export)
export.close
# Restore BGM and BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to title screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(export)
# Read character data for drawing save file
characters = Marshal.load(export)
# Read each type of game object
(10...100).each {|i| $game_switches[i] = Marshal.load(export)}
$game_self_switches = Marshal.load(export)
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
# Load map
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# Refresh party members
$game_party.refresh
end
end
are you trying to load the switches automatically because if you are not you can just have them use load toget it
I'm tryng to load the switches using a menu similar to the Save & Load one.
Your Interpreter class is really good, no doubt about it, but I'm tryng to load file using a more simple menu.
Maybe can you help me? ;)
do you have a menu made if you do you can just add those that script to it
or you can post/pm the menu and i can add it for you