@everyone: is there any way to get lua to read from a text file?
if not then, @Shine: have you put any thought into I/O text file reading for LUA yet?
File Reading
Moderators: Shine, Insert_witty_name
yes, it is fully possible to both read and write from files.
Examples:
function ReadSystemSettings()
file = io.open("settings.cfg", "r")
Pointer.x_pos = file:read("*l")
Pointer.y_pos = file:read("*l")
file:close()
end
function SaveSystemSettings()
ToggleUSB(false)
file = io.open("settings.cfg", "w")
file:write(Pointer.x_pos .. "\n")
file:write(Pointer.y_pos)
file:close()
end
Examples:
function ReadSystemSettings()
file = io.open("settings.cfg", "r")
Pointer.x_pos = file:read("*l")
Pointer.y_pos = file:read("*l")
file:close()
end
function SaveSystemSettings()
ToggleUSB(false)
file = io.open("settings.cfg", "w")
file:write(Pointer.x_pos .. "\n")
file:write(Pointer.y_pos)
file:close()
end
EU PSP 1.52 -> 2.0 -> 1.50
Untold Legends
32MB + 1GB Memory Sticks
Untold Legends
32MB + 1GB Memory Sticks
so, what i want to read and write a file for is for a sorta of save state in my game, say you buy a object, then the script will write to the file "object1 = BOUGHT" and then when you turn the game off, and start it again, the object will already be purchased. stuff like that, so it is possible to read variables and stuff from a text file? or is it just basic read/write simple text so far?
You can read/write text, but arbitrary variable structures are possible, too. See http://www.lua.org/pil/index.html#12 for an advanced method or http://www.luaplayer.org/gallery/snake.lua.txt for a quick and dirty hack :-)Koba wrote:so, what i want to read and write a file for is for a sorta of save state in my game, say you buy a object, then the script will write to the file "object1 = BOUGHT" and then when you turn the game off, and start it again, the object will already be purchased. stuff like that, so it is possible to read variables and stuff from a text file? or is it just basic read/write simple text so far?
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am