Forum

> > CS2D > Scripts > Input Output (io)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Input Output (io)

2 replies
To the start Previous 1 Next To the start

old Input Output (io)

KaBooMa
User Off Offline

Quote
Alright! I think the one thing ive yet to learn is input and output. I learned most it now but i have one question. Im adding a level and exp to a script im writing. How do i make it save text on the second line? also, how do i load it? i got it to save the level and load it. Now i need it to save and load the exp. any ideas?

old Re: Input Output (io)

Yasday
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
local f = io.open("savefile.txt", "w")
f:write(level.."\n"..exp)
f:close()

function line(s, b)
local a = 0
for l in io.lines(s) do
a = a + 1
if a == b then
return l
end
end
end

level = line("savefile.txt", 1)
exp = line("savefile.txt", 2)
A little example, not tabbed because I'm on iPod.

old Re: Input Output (io)

KaBooMa
User Off Offline

Quote
thanks!

Ill have to switch over the code here soon. I decided to make a save called (usgn) Level.txt and (usgn) Exp.txt

it works too just uses more space i guess. Thanks alot

Also, I didnt save that to put you down. Incase you figure that.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview