EvilMana.com - PSP Lua Tutorials - Reading And Writing Files
Google's your best friend.
I know this is for a psp, but it can easily be applied to WoW.
Here is an example, a npc that saves to a text file what you write:
Code:
local current_comment = ""
function Comment_Gossip(unit, event, player)
unit:GossipCreateMenu(710, player, 0)
unit:GossipMenuAddItem(0, "I would like to type something.", 1, 1)
unit:GossipMenuAddItem(0, "Nevermind.", 2, 0)
unit:GossipSendMenu(player)
end
function Comment_Select(unit, event, player, id, intid, Code)
if Code ~= nil then
comment(Code, Code)
end
if (intid == 2) then
player:GossipComplete()
end
end
function comment(codeid, txt)
if txt == nil then
return
end
if codeid == nil then
return
end
local f = assert(io.open("server_comments.txt", "w"))
current_comment = ""..current_comment.."\n\n"..codeid..""
f:write(current_comment)
f:close()
end
RegisterUnitGossipEvent(55555, 1, "Comment_Gossip")
RegisterUnitGossipEvent(55555, 2, "Comment_Select")