output = File.new("Saves.yaml", "w") do |file|
聽聽YAML.dump
end
output.write YAML.dump(@characters) # Wie sichert man mehrere
Sachen???
output.close
and to load:
require "yaml"
output = File.new("Saves.yaml", "r")
p YAML.load(output.read)
output.close
How can I save multiple array etc.?
It works but I want to save more than one hash, I want to save e.g. all
of them, but with that I can save just one or if I manage it to save all
three I can just load the first one.
So it would be nice if someone could help me. Thanks
output = File.new("Saves.yaml", "w") do |file|
YAML.dump
end
output.write YAML.dump(@characters) # Wie sichert man mehrere
Sachen???
output.close
and to load:
require "yaml"
output = File.new("Saves.yaml", "r")
p YAML.load(output.read)
output.close
How can I save multiple array etc.?
It works but I want to save more than one hash, I want to save e.g. all
of them, but with that I can save just one or if I manage it to save all
three I can just load the first one.
So it would be nice if someone could help me. Thanks
For example:
File.open("Saves.yaml", "w") do |file|
file.write(YAML.dump(@characters))
file.write(YAML.dump(@saves))
file.write(YAML.dump(@settings))
end
or
File.open("Saves.yaml", "w") do |file|
[@characters,@saves,@settings].each do |item|
file.write(YAML.dump(item))
end
end
or even better:
File.open("Saves.yaml", "w") do |file|
file.write(YAML.dump([@characters,@saves,@settings]))
end
YAML.load File.read "Saves.yaml"
# => [["Molly", "Trade"], {:location=>"Southeaster", :hunger=>10,
:life=>76}, {:display=>"1360*960", :render=>"high", :saves=>"manual"}]
路路路
On 8/6/13 5:41 PM, Green Eco wrote:
Hi,
I have a question. I have already found a lot in the web but that
does not really helped me. This far my code looks like this: