Im making a program that will be able to run loads of coroutines and save whatever they draw into a table
Im doing this by having a table of coroutines each with their own screen, the coroutines just run files and term.write is rewritten so it uses shell.getRunningProgram to find what program term.whatever is being called from and puts it into the correct screen table
My problem is that nothing is drawn to the screen, it waits for some time then turns off, and when i use my logging program, term.setCursorPos is called hundreds of times but only one function uses it called drawScreen which is only called once and has no while true do loop in it

My code:
Spoiler

--startupa was run
--[[[Info] = Information gathered while program was running
runtime = 0 days, 0 hours, 0 minutes, 0 seconds
times run = 4
]]
--[[[Properties] = File properties
Save Log=true
Exclude From Save Log=
Save running data=true
]]
--Code:
function test( )
shell.run( "hello" )
end
processList = { }
function getIndexOfName( sName, t )
local i = 1
for k,v in pairs( t ) do
  if k == sName then return i end
  local i = i+1
end
return false
end
function genScreen( x, y, item )
screen = { }
for i = 1,y do
  screen[i] = {}
  for m = 1,x do
   screen[i][m] = item
  end
end
return screen
end
function addProcess( sName, fName )
local co = coroutine.create( fName )
processList[sName] = { }
processList[sName].co = co
processList[sName].screen = genScreen( 51, 19, { " ", colours.black, colours.white } )
processList[sName].x = 1
processList[sName].y = 1
end
function resumeProgramCoroutines( )
if processList ~= { } then
  for k,v in pairs( processList ) do
   if processList[k] and processList[k].co then
	if coroutine.status( processList[k].co ) == "dead" then
	 m = getIndexOfName( k, processList )
	 if m then
	  table.remove( processList, m )
	 end
	else
	 coroutine.resume( processList[k].co )
	end
   end
  end
end
end
oldTerm = { }
for k,v in pairs( term ) do
oldTerm[k] = v
end
term.write = function( arg )
local prog = processList[shell.getRunningProgram( )]
if not prog then
  return
end
local m = {}
for i = 1,string.len( arg ) do
  table.insert( m, string.sub( arg, i, i ) )
end
for i = 1,51-prog.x do
  prog.screen[prog.y][prog.x+i] = { m[i], prog.bc, prog.tc }
end
drawScreens( )
end
--[[term.setCursorPos = function( x, y )
local prog = processList[shell.getRunningProgram()]
prog.x = x
prog.y = y
end
term.setBackgroundColour = function( col )
local prog = processList[shell.getRunningProgram()]
prog.bc = col
end
term.setTextColour = function( col )
local prog = processList[shell.getRunningProgram()]
prog.tc = col
end]]
--[[term.clear = function( )
local prog = processList[shell.getRunningProgram()]
prog.screen = genScreen( 51, 19, { " ", colours.black, colours.white } )
end]]
function drawScreens( )
for l,v in pairs( processList ) do
  local screen = processList[l].screen
  for i = 1,#screen do
   for k = 1,#screen[i] do
	if screen[i][k][1] then
	 if type( screen[i][k][1] ) == "string" then
	  oldTerm["setBackgroundColour"]( screen[i][k][2] )
	  oldTerm["setTextColour"]( screen[i][k][3] )
	  oldTerm["setCursorPos"]( k, i )
	  oldTerm["write"]( string.sub( screen[i][k][1], 1, 1 ) )
	 end
	end
   end
  end
end
end
addProcess( "hello", test )
fjk = 0
while fjk<10 do
fjk = fjk+1
resumeProgramCoroutines( )
sleep( 0 )
end
drawScreens( )
term = term.native
--[[[Program Log] = Welcome to the program log
System - rewriting term library
System - Running program
Trying - shell.run with args: startupa
Screen - Set cursor pos to 1 1 --this goes on over 1000 times
Error - with function: shell.run with args: startupa
System - Saving Event Log
]]
if you want me to note it please say