Forum

> > CS2D > Scripts > Load/save script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Load/save script

1 reply
To the start Previous 1 Next To the start

old Load/save script

Syph
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function load_user(id)
local file = io.open(pd..""..player(id,"usgn")..".txt","r")
	if (file~=nil) then
 		for line in io.lines("sys/lua/data/"..player(id,"usgn")".txt","r") do
			local parses = totable(line)
			if (tonumber(parses[1])~=0 or tonumber(parses[1])~=nil) then
				s_iid = tonumber(parses[1])
			end
			if (tonumber(parses[2])~=0 or tonumber(parses[2])~=nil) then
				s_iid = tonumber(parses[2])
			end
		end
	end
end
pd="sys/lua/data/"
How i make it load line 2 could you give an example ?

1
2
3
4
5
if (player(id, "usgn") > 0) then
		save_data = points[id].." "..level[id]
		file = assert(io.open("sys/lua/data/"..usgn..".txt","w"))
		file:write(save_data)
		file:close()
how i make it save on line 2 , could you give an example ? please

old Re: Load/save script

Starkkz
Moderator Off Offline

Quote
To read a line
1
file:read("*l")

To write a line
1
file:write("your content here\n")

the character "\n" means that there is a new line.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview