Andy73

dock

May 8th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. DockContainer={
  2.     Position={
  3.         x=1,
  4.         y=1,
  5.         z=1,
  6.     },
  7.     Content={
  8.        
  9.     },
  10.     Draw=function(this,x,y)
  11.         if x then this.Position.x=x end
  12.         if y then this.Position.y=y end
  13.         --print("Start of Draw procedure")
  14.         for i,v in pairs(this.Content) do
  15.             --print("loaded "..i..textutils.serialize(v))
  16.             term.setCursorBlink(true)
  17.             this.Content[i].position.x=this.Content[i].position.x+this.Position.x
  18.             this.Content[i].position.y=this.Content[i].position.y+this.Position.y
  19.             this.Content[i]:draw()
  20.             --sleep(0.5)
  21.         end
  22.     end,
  23.     --[[draw=function(this,x,y)
  24.         this.draw(this,x,y)
  25.     end,]]
  26.     New=function(this,...)
  27.         object = {}
  28.         setmetatable(object,this)
  29.         this.__index=this
  30.         return object
  31.     end,
  32.     --[[new=function(this,...)
  33.         return this.new(this,...)
  34.     end,]]
  35.     RegisterElement=function(this,el)
  36.         local names=1
  37.         --print("for")
  38.         for reps=0,#this.Content do
  39.             --print("repeats="..reps)
  40.             for k,v in pairs(this.Content) do
  41.                 --print("k,v,reps="..k..","..textutils.serialize(v)..","..reps)
  42.                 if tostring(k)==el.name..reps+1 then --[[print("yes")]] names=names+1 end
  43.             end
  44.         end
  45.         --[[if el.name and not this.Content[el.name] then
  46.             this.Content[el.name]=el
  47.         else]]
  48.             this.Content[el.name..names]=el
  49.         --end
  50.         --table.insert(this.Content,el)
  51.     end,
  52.     Organise=function(this)
  53.         local newIndex=1
  54.         for k,v in ipairs(this.Content) do
  55.            
  56.         end
  57.     end,
  58. }
  59. dofile(shell.resolve(".").."/label.lua")
  60. term.setBackgroundColor(0)
  61. shell.run("clear")
  62. x=DockContainer:New()
  63. x.Position={x=10,y=10}
  64. lab1=label:new()
  65. lab2=label:new()
  66. --print(textutils.serialize(x.Content))
  67. x:RegisterElement(lab1)
  68. --print(textutils.serialize(x.Content))
  69. x:RegisterElement(lab2)
  70. x.Content["label1"].position.y=4
  71. x.Content["label2"].position.y=1
  72. x:Draw()
  73. --print(textutils.serialize(x.Content["label1"]))
Advertisement
Add Comment
Please, Sign In to add comment