Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --defaults
- local color = true
- local size_x = 51
- local size_y = 19
- local cur_x = 1
- local cur_y = 1
- local history = {}
- local spill_t = {}
- function write(text) table.insert(history,{"write",text}) return end
- function clear() table.insert(history,{"clear"}) return end
- function clearLine() table.insert(history,{"clearLine"}) return end
- function getCursorPos() return cur_x,cur_y end
- function setCursorPos(x,y) cur_x = x cur_y = y table.insert(history,{"setCursorPos",x,y}) return end
- function setCursorBlink(b) table.insert(history,{"setCursorBlink",b}) return end
- function isColor() return color end
- isColour = isColor
- function getSize() return size_x,size_y end
- function scroll(n) table.insert(history,{"scroll",n}) return end
- function setTextColor(color) table.insert(history,{"setTextColor",color}) return end
- setTextColour = setTextColor
- function setBackgroundColor(color) table.insert(history,{"setBackgroundColor",color}) return end
- setBackgroundColour = setBackgroundColor
- function setTextScale(scale) table.insert(history,{"setTextScale",scale}) return end
- function newFakeTerm(col,sx,sy,cx,cy)
- local ft = {}
- local ft_sp = {}
- --spill
- ft_sp["color"] = color
- ft_sp["size_x"] = size_x
- ft_sp["size_y"] = size_y
- ft_sp["cur_x"] = cur_x
- ft_sp["cur_y"] = cur_y
- ft_sp["history"] = {} for _,v in ipairs(history) do table.insert(ft_sp["history"],v) end
- history = {}
- spill_t[ft] = ft_sp
- --set new vals
- if col == nil then color = true else color = col end
- if sx == nil then size_x = 51 else color = sx end
- if sy == nil then size_y = 19 else color = sy end
- if cx == nil then cur_x = 1 else color = cx end
- if cy == nil then cur_y = 1 else color = cy end
- return ft
- end
- function deleteFakeTerm(ft)
- local ft_sp = spill_t[ft]
- if ft_sp == nil then return end
- color = ft_sp["color"]
- size_x = ft_sp["size_x"]
- size_y = ft_sp["size_y"]
- cur_x = ft_sp["cur_x"]
- cur_y = ft_sp["cur_y"]
- history = {} for _,v in ipairs(ft_sp["history"]) do table.insert(history,v) end
- table.remove(spill_t,loadstring([[function (t,val) for i, v in ipairs(t) do if v == val then return i end end return 0 end]])(spill_t,ft)) --how's that for unreadable?
- end
- function clearHistory(ft) history = {} end
- function historyCopy(ft) local rval = {} for _,v in ipairs(history) do table.insert(rval, v) end return rval end
- function replayHistory(historyTable, termObject)
- if termObject == nil then termObject = term.current() end
- for i,v in pairs(historyTable) do
- if v[1] == "write" then termObject.write(v[2]) end
- if v[1] == "clear" then termObject.clear() end
- if v[1] == "clearLine" then termObject.clearLine() end
- if v[1] == "setCursorPos" then termObject.setCursorPos(v[2],v[3]) end
- if v[1] == "setCursorBlink" then termObject.setCursorBlink(v[2]) end
- if v[1] == "scroll" then termObject.scroll(v[2]) end
- if v[1] == "setTextColor" then termObject.setTextColor(v[2]) end
- if v[1] == "setBackgroundColor" then termObject.setBackgroundColor(v[2]) end
- if v[1] == "setTextScale" then termObject.setTextScale(v[2]) end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement