First of all XD
Im doing this...most likely to learn something about File, IO and Dir classes...and I already did this(without txt file) inside the script
Now I wanted to 'change' that information into .txt folder and then use rgss to take all that, string and integers...
Im going to try to use what u said.
One more time, thanks a lot for the help ^^
@Edit:
I failed using what u said there XD
Im going to explain my previous code..
Without .txt file, I could just do a class with this type of conditions:
if $old_map_id == 1
$game_temp.player_new_map_id = 2
$game_temp.player_new_x = 10
$game_temp.player_new_y = 20
$game_temp.player_new_direction = 6
$game_player.refresh
$game_map.update
$scene = Scene_Map.new
end
With txtfile ->
First of all, I though about creating some arrays, what would store the values of .txt document.
@map_name = []
@respawn_map =[]
@respawn_x = []
@respawn_y = []
@respawn_dir = []
Then, I thought about using regexp to take the lines that follow it:
data = load_data("Data/MapInfos.rxdata")
return if !File.exists?("Data")
file = File.open("Data.txt", "rb")
file.each_line do |line|
case line
when /(\".*\")\s\=\>\s(\".*\")\,\s(\d+)\,\s(\d+)\,\s(\d+)\,\s(\d+)\./i
@map_name.push = $1
@respawn_map.push = $2
@respawn_x.push = $3.to_i
@respawn_y .push = $4.to_i
@respawn_dir.push = $5.to_i
end
end
file.close
Each of these variables, will store the correspondent $'s.
After this, I needed to check the name of the maps(map where actor dies, and where it respawns) and then convert it to id:
for i in 1...data.size
if data[i].name != nil
actual_name = data[i].name
respawn_name = data[i].name
end
if actual_name == @map_name
actual_id = i
break
end
if respawn_name == @respawn_map
respawn_id = i
break
end
end
Finally, as each array have the same size, I only needed to use the size of one to make all necessary conditions...
for j in 0...@map_name.size
return if @map_name.nil?
if $old_map_id == actual_id
$game_temp.player_new_map_id = respawn_id
$game_temp.player_new_x = @respawn_x[j]
$game_temp.player_new_y = @respawn_y[j]
$game_temp.player_new_direction = @respawn_dir[j]
$game_player.refresh
$game_map.update
$scene = Scene_Map.new
end
end
This latter code, with .txt logic it is freezing the screen all the time I call it xD
Someone help please?