4 posts
Posted 15 August 2012 - 07:23 PM
I'm just a beginner and not quite familiar with the commands..Can any one show me a simple example for that?
Are there something like "infile.eof()" , "infile>>" in C++ available in lua?
THX~!
90 posts
Location
that's no moon...
Posted 15 August 2012 - 07:32 PM
4 posts
Posted 15 August 2012 - 08:37 PM
Thanks for your help.^ ^
I have another question,I wonder if you can help me with this too :(/>/> .I saw someone coded a movie by changing the "filmText" in the "alongtimeago" file which comes with the mod..so if I already have pictures transfered to words, how can I transfer them into the filmText?
local filmText='FramesHere'
local function iterator()
return coroutine.wrap( function()
for line in string.gmatch( filmText, "([^n]*)n") do
coroutine.yield(line)
end
return false
end )
end
term.clear()
local it = iterator()
sleep(3)
local bFinished = false
while not bFinished do
-- Read the frame header
local holdLine = it()
if not holdLine then
bFinished = true
break
end
-- Get this every frame incase the monitor resizes
local w,h = term.getSize()
local startX = math.floor( (w - 77) / 2 )
local startY = math.floor( (h - 33) / 2 )
-- Print the frame
term.clear()
for n=1,34 do
local line = it()
if line then
term.setCursorPos(startX, startY + n)
term.write( line )
else
bFinished = true
break
end
end
-- Hold the frame
local hold = tonumber(holdLine) or 1
local delay = (hold * 0.06) - 0.01
sleep(delay)
end
90 posts
Location
that's no moon...
Posted 15 August 2012 - 09:23 PM
Yes, of course, just at the end of each line put n
4 posts
Posted 16 August 2012 - 06:18 AM
Yes, of course, just at the end of each line put n
So how can I separate each frame? Just keep adding /n ?
It seems that there is a definition about how many lines make a frame in the code(maybe this? –>
for n=1,34 do local line = it() if…. if…..) what's the function iterator() ?
52 posts
Location
Void
Posted 16 August 2012 - 05:14 PM
Okay rename frames as 1.txt 2.txt and try this code
frames = 10 -- how many frames you got?
time = 1 -- Time that every frame displayed for
for i=1,frames,1 do
term.clear()
term.setCursorPos(1,1)
f = fs.open(i..".txt","r")
fra = f.readAll()
f.close()
print(fra)
sleep(time)
end
Happy coding!
4 posts
Posted 28 August 2012 - 07:26 AM
Sorry to reply so late.
Thank you very much!!.. :D/>/>
That's very easy to understand,nice code.. I love it :P/>/>