Posted 14 April 2012 - 09:59 PM
Hello! I am trying to write a game for a computer. I am trying to make it so that not only will it display on the terminal, but also a monitor. My issue is that my program here just exits when run with monitor=true, but draws the screen when monitor=false.
Most of the print lines in there are meant to show when it stops running. It stops running during the draw.
Please help, and thanks in advance.
scale=1
monitor=true
side="left"
disp=nil
w,h=0
screenArr={}
function draw()
for dY=0,h do
disp.setCursorPos(1,dY+1)
for dX=0,w do
disp.write(screenArr[dX+(dY*w)])
end
end
end
function tsleep(length)
os.setAlarm(os.time()+length/1000)
local tExit=true
while tExit do
local event=os.pullEvent()
if event=="alarm" then
tExit=false
end
end
end
if monitor then
disp=peripheral.wrap(side)
disp.setTextScale(scale)
else
disp=term
end
print(disp)
disp.clear()
w,h=disp.getSize()
for i=1,w+(h*w) do
screenArr[i]="#"
end
for loc=1,w+(h*w) do
print("Starting!")
screenArr[loc]="/"
print("Start drawing!")
draw()
print("Done drawing!")
tsleep(1)
print("Ending!")
end
print("Done!")
Most of the print lines in there are meant to show when it stops running. It stops running during the draw.
Please help, and thanks in advance.