Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p = peripheral.wrap("left")
- p.clear()
- variables = {
- ["width"] = 200,
- ["height"] = 100,
- ["lineTransparency"] = 1,
- ["innerTransparency"] = 1,
- ["lineColour"] = 0x000000,
- ["middleColour"] = 0xFFFFFF,
- ["lineTransparency2"] = 1,
- ["innerTransparency2"] = 0,
- ["lineColour2"] = 0x000000,
- ["middleColour2"] = 0xFFFFFF
- }
- groups = {
- ["left_transparency"] = {
- [1] = {x=2, y=11, width=1, height="height+00",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [2] = {x=3, y=08, width=1, height="height+06",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [3] = {x=4, y=06, width=1, height="height+10",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [4] = {x=5, y=05, width=1, height="height+12",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [5] = {x=6, y=04, width=2, height="height+14",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [6] = {x=8, y=03, width=3, height="height+16",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["middle_transparency"] = {
- [1] = {x=11,y=2,width="width+0",height="height+18",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["right_transparency"] = {
- [1] = {x="width+11", y=03, width=3, height="height+16",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [2] = {x="width+14", y=04, width=2, height="height+14",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [3] = {x="width+16", y=05, width=1, height="height+12",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [4] = {x="width+17", y=06, width=1, height="height+10",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [5] = {x="width+18", y=08, width=1, height="height+06",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [6] = {x="width+19", y=11, width=1, height="height+00",colour="middleColour+0",transparency="innerTransparency+0",colour2="middleColour2+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["top_left"] = {
- [1] = {x=8,y=2,width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [2] = {x=6,y=3,width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [3] = {x=4,y=5,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [4] = {x=5,y=4,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [5] = {x=3,y=6,width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [6] = {x=2,y=8,width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["top"] = {
- [1] = {x=11,y=1,width="width+0",height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["top_right"] = {
- [1] = {x="width+11",y=2,width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [2] = {x="width+14",y=3,width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [3] = {x="width+16",y=4,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [4] = {x="width+17",y=5,width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [5] = {x="width+18",y=6,width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [6] = {x="width+19",y=8,width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["left"] = {
- [1] = {x=1,y=11,width=1,height="height+0",colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["right"] = {
- [1] = {x="width+20",y=11,width=1,height="height+0",colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["bottom_left"] = {
- [1] = {x=2,y="height+11",width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [2] = {x=3,y="height+14",width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [3] = {x=4,y="height+16",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [4] = {x=5,y="height+17",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [5] = {x=6,y="height+18",width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [6] = {x=8,y="height+19",width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["bottom"] = {
- [1] = {x=11,y="height+20",width="width+0",height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- },
- ["bottom_right"] = {
- [1] = {x="width+19",y="height+11",width=1,height=3,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [2] = {x="width+18",y="height+14",width=1,height=2,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [3] = {x="width+17",y="height+16",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [4] = {x="width+16",y="height+17",width=1,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [5] = {x="width+14",y="height+18",width=2,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)},
- [6] = {x="width+11",y="height+19",width=3,height=1,colour="lineColour+0",transparency="lineTransparency+0",colour2="lineColour+0",transparency2="innerTransparency2+0",obj=p.addBox(0,0,0,0,0,0)}
- }
- }
- function renderGroup(groupName)
- group = groups[groupName]
- for key, object in pairs(group) do
- if type(object["x"]) == "number" then
- object["obj"].setX(object["x"])
- elseif type(object["x"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["x"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setX(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- if type(object["y"]) == "number" then
- object["obj"].setY(object["y"])
- elseif type(object["y"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["y"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setY(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- if type(object["width"]) == "number" then
- object["obj"].setWidth(object["width"])
- elseif type(object["width"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["width"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setWidth(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- if type(object["height"]) == "number" then
- object["obj"].setHeight(object["height"])
- elseif type(object["height"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["height"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setHeight(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- if type(object["colour"]) == "number" then
- object["obj"].setColor(object["colour"])
- elseif type(object["colour"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["colour"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setColor(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- if type(object["transparency"]) == "number" then
- object["obj"].setOpacity(object["transparency"])
- elseif type(object["transparency"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["transparency"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setOpacity(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- if type(object["colour2"]) == "number" then
- object["obj"].setColor2(object["colour"])
- elseif type(object["colour2"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["colour2"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setColor2(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- if type(object["transparency2"]) == "number" then
- object["obj"].setOpacity2(object["transparency"])
- elseif type(object["transparency2"]) == "string" then
- t = {}
- for k, v in string.gmatch(object["transparency"], "(%w+)+(%w+)") do
- t[1] = k
- t[2] = v
- end
- object["obj"].setOpacity2(tonumber(variables[t[1]])+tonumber(t[2]))
- end
- end
- end
- function redraw()
- for key,value in pairs(groups) do
- renderGroup(key)
- end
- end
- redraw()
- while true do
- evt,command = os.pullEvent("chat_command")
- words = {}
- i = 0
- for word in string.gmatch(command, "%S+") do
- words[i] = word
- i = i + 1
- end
- if string.lower(words[0]) == "width" then
- variables["width"] = tonumber(words[1])
- redraw()
- elseif string.lower(words[0]) == "height" then
- variables["height"] = tonumber(words[1])
- redraw()
- elseif string.lower(words[0]) == "linecolour" then
- variables["lineColour"] = tonumber(words[1])
- redraw()
- elseif string.lower(words[0]) == "middlecolour" then
- variables["middleColour"] = tonumber(words[1])
- redraw()
- elseif string.lower(words[0]) == "linetransparency" then
- variables["lineTransparency"] = tonumber(words[1])
- redraw()
- elseif string.lower(words[0]) == "middletransparency" then
- variables["innerTransparency"] = tonumber(words[1])
- redraw()
- elseif string.lower(words[0]) == "stop" then
- p.clear()
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement