Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is the very basic libHLTI API. 2 functions, but they work!
- --Since HLTI is actually just many Lua tables, we can use it like this:
- local libHLTI = {}
- libHLTI.GetValues = function(file)
- if not fs.exists(file) then
- error("HLTI file doesn't exist.")
- end
- local file = fs.open(file,'r')
- local values = textutils.unserialize(file.readAll())
- if not values then
- error("HLTI image is misconfigured/corrupted.")
- end
- file.close()
- return values
- end
- libHLTI.SetValue = function(file, key, value)
- if not fs.exists(file) then
- error("HLTI file doesn't exist.")
- end
- local currentValues = libHLTI.GetValues(file)
- currentValues[key] = value
- local file = fs.open(file, 'w')
- file.write(textutils.serialize(currentValues))
- file.close()
- end
- --Actual program
- local function HLTI_Render(file)
- local hlti = libHLTI.GetValues(file)
- local hltiver = hlti["HLTIVer"]
- local width = hlti["Width"]
- local height = hlti["Height"]
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- write("HLTI Version: " .. hltiver .. " | ")
- print(width .. "x" .. height)
- local yOffset = 2
- local sectionCount = 0
- --Really bad rendering method. Sorry! :D
- while sectionCount < hlti["Sections"] do
- local v = hlti["Section" .. sectionCount]
- if v.Type == "Color" then
- if not v.BackgroundColor then v.BackgroundColor = colors.black end
- term.setCursorPos(v.X, v.Y + yOffset)
- term.setBackgroundColor(v.BackgroundColor)
- write(" ")
- end
- term.setCursorPos(1,2)
- term.setBackgroundColor(colors.black)
- write("Sector "..sectionCount .. "/" .. hlti["Sections"] .. " | X" .. v.X .. " Y" .. v.Y .. " ") --spaces because of ghosting
- sectionCount = sectionCount + 1
- sleep(0)
- end
- return;
- end
- local tArgs = {...}
- local ok, err = pcall(function()
- HLTI_Render(tArgs[1]) --Kinda wanted to do this, I'll come up with something better soon.
- end)
- if not ok then
- printError("Something happened: " .. err)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement