Posted 16 January 2015 - 03:11 AM
I've been messing around with the window api lately. My program worked fine but it was a bit messy so I tried to split it up into my own personal little APIs. My problem is that I can't get the APIs to recognize the initial windows I created in the original program.
I created the window named bPage and loaded the box API
Later I try to create a box
Here is the box api
Also the error I get is:
box:3: attempt to index ? (a nill value)
I created the window named bPage and loaded the box API
screenWidth, screenHeight = term.getSize()
bPage = window.create(term.current(), 1, 2, screenWidth, screenHeight - 1)
os.loadAPI("/Applications/BowserBrowser/api/box")
Later I try to create a box
if line == "BOX" then
local x = page.readLine()
local y = page.readLine()
local width = page.readLine()
local height = page.readLine()
color = page.readLine()
box.create(x,y,width,height,color)
end
Here is the box api
function create(xPos,yPos,boxWidth,boxHeight,boxColor) -- creates box at x/y and width/height/color
boxColor = boxColor - 0 -- convert string to number
bPage.setBackgroundColor(boxColor)
for i = 1, boxHeight do -- creates box height
bPage.setCursorPos(xPos,yPos)
for j = 1, boxWidth do -- creates box width
bPage.write(" ")
end
yPos = yPos + 1 -- sets width to next line
end
end
Also the error I get is:
box:3: attempt to index ? (a nill value)