Posted 24 August 2012 - 10:35 PM
I'm currently working on a simple program which reads from a file and displays the text on a monitor, but I have run into a problem: The script crashes when it tries to run the second time and this error message pops up: "bios:25: bad argument: double expected, got nil".
I have tried to fix this problem myself, but whatever I do the same problem occurs.
Code - http://pastebin.com/bt9yvgKT:
Hope you guys are able to help a clueless LUA noob out here…
I have tried to fix this problem myself, but whatever I do the same problem occurs.
Code - http://pastebin.com/bt9yvgKT:
Side="top"
Document="info.txt" --Name of the file.
Speed=10 --Typing speed multiplier
Runtimes=0 --use 0 to run the text forever.
Triggerbyredstone="none" --Change to the side you wish to use if you want to use a redstone signal.
Runlimited=false
if Triggerbyredstone~="none" then
while rs.getInput(Triggerbyredstone)==false do
sleep(0.1)
end
end
if Runtimes<0 then
Runlimited=true
else
Runtimes=1
end
file = io.open(Document, "r")
if file==nil then
print("Do document was found!")
print("The program was unable to read from the file")
else
while Runtimes>0 do
file = io.open(Document, "r")
A = file:read()
Linecount=tonumber(A)
Linecount=Linecount-1
while Linecount>0 do
A = file:read()
mon = peripheral.wrap(Side)term.redirect(mon)
textutils.slowPrint(A,Speed)
Linecount=Linecount-1
end
term.restore()
if Runlimited==true then
Runtimes=Runtimes-1
end
Sleeptime=30/Speed
file:close()
sleep()
term.clear(Sleeptime)
term.setCursorPos(1,1)
end
end
Hope you guys are able to help a clueless LUA noob out here…