This is a developer release so if you're a server owner and not a scripter, you won't need this file.
This is a script all about making File IO easier. Nowadays reading and writing to files is too complicated making newbies (noobs) avoid it in their scripts. With this patch, they all become clearer. You have 6 'commands' (functions) you can use:
readfile(filepath)
savefile(text, filepath)
readlinefile(file, line)
copyfile(original, clone)
writefile(text, file, mode)
logdata(text, file)
Too complicated for you? Get the Lite version for starters by clicking here
These are making the entire IO System much easier. Let me give you an example.
File Reading
Before:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
if(io.open("test.txt")~=nil) then for p in io.lines("test.txt") do l = p if(l~=nil)then --You got it end end end
1
l = readfile("test.txt") --You got it!
File Writting:
Before:
1
2
3
2
3
io.output(io.open("test.txt", "w+")) io.write("HELLO WORLD") io.close()
1
savefile("HELLO WORLD", "test.lua")
Explanation of commands:
-readlinefile(file, line)
This command will return the text of the file of a specific file you need, example is line 2 of test.txt
-copyfile(original, clone)
This command will make a copy of a file (for backup?), example is copying moneysaves.txt to another folder an naming them moneysaves_backup.txt
-writefile(text, file, mode)
Same as savefile but you can write in a specific mode (w+, a etc), example is writing hi on file test.txt in the end of the file.
-logdata(text, file)
Logs some data to a file so you can keep logs of everything happened. Example is logging all bomb defuses to bombs.txt. Please note that this command adds in front of text full date + time of the server.
To use these functions, place easyio.lua to your scripts folder and use the following code to the TOP of the script that runs FIRST!
1
dofile("sys/lua/easyio.lua")--ByDaKnOb :P
I will add more as you suggest, keep the good ratings and the comments
Approved by Yates
Download
2 kb, 476 Downloads