term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
and i works fine, as expected. but! when i run this SAME CODE in another program i get the fallowing error
window:140: bios.lua:80: bad argument: string expected, got nil.
So, here is the program that it errors on,
Spoiler
--==> WinPOP v1.0, 2/16/16 <==-
-- ](c)Lewisk3-Corpz - 2016 [--
function init()
--==> Hiding POPWindows table
popwindows = {}
selectedwindow = ''
end
function getWindowByID(id)
for _, v in pairs(popwindows) do
if(v.id == id)then
return v
end
end
end
function setContentPos(winid,xx,yy)
local startX = getWindowByID(winid).x
local startY = getWindowByID(winid).y
term.setCursorPos(startX + xx, startY + yy)
end
getContentPos = term.getCursorPos
function getWindowPos(winid)
return getWindowByID(winid).x, getWindowByID(winid).y
end
function newWindow(idenity,size,colors,requestfocus)
local win = {
x = size[1],
y = size[2],
px = 0,
py = 0,
mx = size[3],
my = size[4],
tc = colors[1],
bc = colors[2],
tbc = colors[3],
ttc = colors[4],
id = idenity,
drawn = false,
title="New Window",
contents = {},
dragable = true,
draging = false,
draw=function(self)
if(self.x ~= self.px or self.y ~= self.py)then
term.current().setVisible(false)
-->>>>>>>>>> HERE IT ERRORS <<<<<<<<<--
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
------------------------------------------------------------------
term.setCursorPos(self.x,self.y)
term.setBackgroundColor(self.tbc)
term.write(string.rep(" ",self.mx))
term.setCursorPos(self.x+1, self.y)
term.setTextColor(self.ttc)
term.write(self.title)
term.setCursorPos((self.mx+self.x),self.y)
--term.setBackgroundColor(colors.red)
--term.setTextColor(colors.white)
write("X")
paintutils.drawFilledBox(self.x,self.y+1,(self.mx)+self.x,(self.my)+self.y,self.bc)
self.px = self.x
self.y = self.py
term.current().setVisible(true)
end
end,
update=function(self, ev)
if(selectedwindow ~= self.id and #popwindows <= 1)then
selectedwindow = self.id
end
if(selectedwindow == self.id)then
for _,v in pairs(self.contents) do
v.content(ev)
end
-- draging and closing
if(self.dragable)then
if(ev[1] == "mouse_drag" and not self.draging)then
if(ev[3] >= self.x and ev[3] <= self.x+self.mx)then
self.x = ev[3]
self.y = ev[4]
self.draging = true
end
elseif(self.draging and ev[1] == "mouse_up")then
self.draging = false
end
if(self.draging)then
self.x = ev[3]
self.y = ev[4]
end
end
if(ev[1] == "mouse_click")then
if(ev[3] == self.x+self.mx )then
self:Dispose()
end
end
self:draw()
end
end,
Dispose=function(self)
local loops = 0
for _, v in pairs(popwindows) do
if(v.id == self.id)then
term.current().setVisible(false)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
popwindows[loops] = nil
term.current().setVisible(true)
end
loops = loops + 1
end
end,
setTitle=function(self,ntitle)
self.title=ntitle
end,
clearContents = function(self)
self.contents = {}
end,
addContent=function(self,CONTENT)
self.contents[#self.contents+1] = {}
self.contents[#self.contents+1].content = CONTENT
end,
setDragable=function(self,ndragable)
dragable = ndragable
end,
render=function(self)
for _, v in pairs(popwindows) do
if(v.id == self.id)then
error("Window already rendered.")
end
end
popwindows[#popwindows+1] = self
end,
}
if(requestfocus)then selectedwindow = win.id end
return win
end
Any help is very much appreciated, thank you.