file = io.open("./saved_data/position.txt", "w")
file:write(place)
file:write(playerx .. " " .. playery)
for bgs = 1 , 10 do 
	file:write("     " .. BG[bgs].x .. " " .. BG[bgs].y)
end


file:close() 
for pokeman = 1, 6 do
file = io.open("./saved_data/pokemon/pokemon" .. pokeman .."/pokemonname.txt", "w")
file:write(pokemon[pokeman].name)
file:close()
file = io.open("./saved_data/pokemon/pokemon" .. pokeman .."/pokemonstats.txt", "w")
file:write(pokemon[pokeman].lv .. " " .. pokemon[pokeman].STR .. " " .. pokemon[pokeman].DEF .. " " .. pokemon[pokeman].AGI .. " " .. pokemon[pokeman].SPA .. " " .. pokemon[pokeman].SPD .. " " .. pokemon[pokeman].MAX_HP .. " " .. pokemon[pokeman].C_HP .. " " .. pokemon[pokeman].exp)
file:close()
end

-- 1,1
file = io.open("./saved_data/pokemon/pokemon1/attacks/" .. 1 .. ".txt", "w")
file:write(p_attacks[101].name)
file:close()
-- 1,2
file = io.open("./saved_data/pokemon/pokemon1/attacks/" .. 2 .. ".txt", "w")
file:write(p_attacks[102].name)
file:close()
-- 1, 3
file = io.open("./saved_data/pokemon/pokemon1/attacks/" .. 3 .. ".txt", "w")
file:write(p_attacks[103].name)
file:close()
-- 1, 4
file = io.open("./saved_data/pokemon/pokemon1/attacks/" .. 4 .. ".txt", "w")
file:write(p_attacks[104].name)
file:close()



file = io.open("./saved_data/pokemon/pokemon2/attacks/" .. 1 .. ".txt", "w")
file:write(p_attacks[201].name)
file:close()
file = io.open("./saved_data/pokemon/pokemon2/attacks/" .. 2 .. ".txt", "w")
file:write(p_attacks[202].name)
file:close()
file = io.open("./saved_data/pokemon/pokemon2/attacks/" .. 3 .. ".txt", "w")
file:write(p_attacks[203].name)
file:close()
file = io.open("./saved_data/pokemon/pokemon2/attacks/" .. 4 .. ".txt", "w")
file:write(p_attacks[204].name)
file:close()


file = io.open("./saved_data/items.txt", "w")
file:write(items[1].amount .. " " .. pokeballs[1].amount)
file:close()
file = io.open("./saved_data/gender.txt", "w")
file:write(gender)
file:close()