Como armazenar informações na memória secundária?

sabrina9292
em Resolvidos

sabrina9292

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 02/02/08Posts: 29

Olá pessoal...

 

Gostaria de saber se é possível armazenar informações na memória secundária, igual Arquivos na linguagem C, acho que é possível, pois existe aquele sisteminha de Logs que armazena os comando utilizados na memória secundária...

 

Andei dando uma pesquisada e encontrei *algo:

 

--Manipulação arquivos
nomeArquivo = "Aula3.txt"
arquivo = assert(io.open(nomeArquivo, "w"), "Arquivo não pode ser criado") --Modos: r, Leitura; a, anexo; w escrita; r+,a+,w+, preservam os dados anteriores
arquivo:write("Arquivo da Aula 3 de Lua!\n")
arquivo:flush();
io.close(arquivo)
arquivo = assert(io.open(nomeArquivo, "a+"), "Arquivo não pode ser criado") --Abre arquivo no modo de anexo
arquivo:write("Segunda Linha\n")
arquivo:flush();
io.close(arquivo)
arquivo = assert(io.open(nomeArquivo, "r"), "Arquivo não pode ser criado") --Abre no modo de leitura
arquivo:seek('set')--Busca o inicio do arquivos
io.write(arquivo:read("*line"), "\n") --Le uma linha e pula para a próxima
io.write(arquivo:read("*line"), "\n")

 

mas não consigo fazer funcionar em OT server...

Alguém pode me dar uma ajudinha por favor?

 

*Isto é o que encontrei:

 

 

 

Desde já...

Obrigada...

AlexandreKG

Estudante de TI
avatar
Marquês
Marquês

INFOS

Grupo: MarquêsRegistrado: 30/10/11Posts: 1153Gênero: Masculino

Reportado area incorreta!

 

Mais atenção da proxima ves,leia as regras de cada seção antes de postar !

Stigal

don't ever stop...
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 28/11/10Posts: 3402Gênero: Masculino

Movido!

VI6MDIG.png

 

"O fracasso é a oportunidade de se começar de novo inteligentemente"

Minhas Redes Sociais: Youtube | Página & Grupo | Steam  | Discord Xtibia | Skype: @mrooger

 

OTpanel

Slicer

Insanity
avatar
Príncipe
Príncipe

INFOS

Grupo: PríncipeRegistrado: 19/08/10Posts: 4014Gênero: Masculino
function onSay(cid, words, param, channel)

local str = "pokes = {"
local file = io.open('data/writeTable.txt', 'w')
if (not file) then
  sendMsgToPlayer(cid, 20, "File: data/writeTable.txt, not found...")
  return true
end
for i, table in ipairs(oldpokedex) do
   local t = pokes[table[1]]
   str = str.. '\n\n["'..table[1]..'"] = {offense = '..t.offense..', defense = '..t.defense..', specialattack = '..t.specialattack..', vitality = '..t.vitality..', agility = '..t.agility..', exp = '..t.exp..', level = '..t.level..', wildLvl = '..t.level..', type = "'..t.type..'", type2 = "'..t.type2..'"},'
end
str = str.."\n}"
file:write(str)
file:close()
sendMsgToPlayer(cid, 20, "Table add in file 'data/writeTable.txt'...")
return true
end

"Só a beira do abismo que os seres humanos acham forças para mudar."... E isso me da nojo... ¬¬

"Insanity is doing the exact... same fucking thing... over and over again expecting... shit to change... That. Is. Crazy." -Vass/Einstein

 

sabrina9292

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 02/02/08Posts: 29

function onSay(cid, words, param, channel)

local str = "pokes = {"
local file = io.open('data/writeTable.txt', 'w')
if (not file) then
  sendMsgToPlayer(cid, 20, "File: data/writeTable.txt, not found...")
  return true
end
for i, table in ipairs(oldpokedex) do
local t = pokes[table[1]]
str = str.. '\n\n["'..table[1]..'"] = {offense = '..t.offense..', defense = '..t.defense..', specialattack = '..t.specialattack..', vitality = '..t.vitality..', agility = '..t.agility..', exp = '..t.exp..', level = '..t.level..', wildLvl = '..t.level..', type = "'..t.type..'", type2 = "'..t.type2..'"},'
end
str = str.."\n}"
file:write(str)
file:close()
sendMsgToPlayer(cid, 20, "Table add in file 'data/writeTable.txt'...")
return true
end

 

Muito obrigada...

Vou estudar seu código...

Com certeza ajudará =)

Levou meu rep++

Muito obrigada mesmo...