Posted 26 February 2013 - 08:52 AM
I ran into another snag while implementing soemthing really fun into my next program. It's supposed to be a nifty little dialogue between two unknown people. The problem is, I want static boxes running at the same time text does. When I try to do that, it will unfortunately not write the text in the proper place. It seems I might have to fanangle my own coroutines, but I have no idea how to use them. Can anyone help me?
Paint image here: http://pastebin.com/pk2Fz2p8
Code here:
Paint image here: http://pastebin.com/pk2Fz2p8
Code here:
local function unlock()
local codec = fWolf and loadImageFromServer("codec") or paintutils.loadImage("codec")
paintutils.drawImage(codec, 1, 3)
local talking = true
local function static()
while talking do
local staticColors = {
colors.white,
colors.gray,
colors.black,
colors.lightGray}
for i = 2, 11 do
for k = 3, 9 do
term.setCursorPos(i, k)
term.setBackgroundColor(staticColors[math.random(1,4)])
write(" ")
end
end
for i = 41, 50 do
for k = 3, 9 do
term.setCursorPos(i, k)
term.setBackgroundColor(staticColors[math.random(1,4)])
write(" ")
end
end
sleep(.01)
end
end
local function writeText()
local chatTab = {
{"Unknown voice 1: The user has found the",
" backdoor. Shall I terminate the connection",
" to the server?"},
{"Unknown voice 2: No. Their dilligence has paid",
" off. Give them more tests. Scatter them",
" throughout cyberspace. Let's see if they",
" canfind all of the clues."},
{"Unknown voice 1: Understood sir."}
}
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
for i = 1, #chatTab do
for k = 1, #chatTab[i] do
term.setCursorPos(4, 12 + k) --It's not writing on the line specified here
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
textutils.slowWrite(chatTab[i][k], 10)
end
sleep(2)
for v = 13, 17 do
paintutils.drawLine(3, v, 49, v, colors.black)
end
end
talking = false
end
parallel.waitForAll(static, writeText)
sleep(2)
background()
end
Bonus points go to those who can recognize what I'm trying to emulate.