The API is: (Name: DesignAPI)
local x, y = term.getSize()
function loadTheme(path)
if type(path) ~= "string" then error("arg1 must be a string!") end
local file = fs.open(path,"r")
local data = file.readAll()
file:close()
return textutils.unserialize(data)
end
function addTitle(theme, title, align)
if theme.title.bgColor ~= nil then term.setBackgroundColor(theme.title.bgColor) end
if theme.title.txColor ~= nil then term.setTextColor(theme.title.txColor) end
if align == "center" then local textX = (#title-x)/2 end
if align == "left" or align == nil then local textX = 2 end
if align == "right" then local textX = x-#title end
if theme.title.height == 1 or theme.title.height == 2 then textY = 1 end
if theme.title.height == 3 then textY = 2 end
term.setCursorPos(textX, textY)
term.write(title)
end
The program is
os.loadAPI("design")
theme = design.loadTheme("themes//default")
design.addTitle(theme,"Test Title")
The theme 'default' (located at themes/default) is:
{
title = {
bgColor = colors.lightBlue,
txColor = colors.blue,
height = 3,
testText = "Hi"
}
}
So, the problem is, that when I try to do design.addTitle it says "Attempt to index" at line 12, when trying to get info of the table.
Am I not saving the table correctly? Oh, and I'm manually doing the config.