Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x,y,z = commands.getBlockPosition()
- local info = commands.getBlockInfo(x,y,z)
- local direct = 0
- local dir = "y"
- if info.metadata == 2 then
- direct = 5
- dir = "z"
- elseif info.metadata == 3 then
- direct = -5
- dir = "z"
- elseif info.metadata == 4 then
- direct = 5
- dir = "x"
- elseif info.metadata == 5 then
- direct = -5
- dir = "x"
- end
- local draw
- for i,v in pairs(peripheral.getNames()) do
- if peripheral.getType(v) == "openperipheral_selector" then
- draw = peripheral.wrap(v)
- break
- end
- end
- function discern(sSide,sDir)
- if sSide == "left" then
- if sDir == "x" then
- if direct == -5 and dir == "z" then
- return "~-1"
- elseif direct == 5 and dir == "z" then
- return "~1"
- elseif direct == -5 and dir == "x" then
- return "~-5"
- elseif direct == 5 and dir == "x" then
- return "~5"
- end
- elseif sDir == "z" then
- if direct == -5 and dir == "x" then
- return "~1"
- elseif direct == 5 and dir == "x" then
- return "~-1"
- elseif direct == -5 and dir == "z" then
- return "~-5"
- elseif direct == 5 and dir == "z" then
- return "~5"
- end
- end
- elseif sSide == "right" then
- if sDir == "x" then
- if direct == -5 and dir == "z" then
- return "~1"
- elseif direct == 5 and dir == "z" then
- return "~-1"
- elseif direct == -5 and dir == "x" then
- return "~-5"
- elseif direct == 5 and dir == "x" then
- return "~5"
- end
- elseif sDir == "z" then
- if direct == -5 and dir == "x" then
- return "~-1"
- elseif direct == 5 and dir == "x" then
- return "~1"
- elseif direct == -5 and dir == "z" then
- return "~-5"
- elseif direct == 5 and dir == "z" then
- return "~5"
- end
- end
- end
- end
- function middle(sDir)
- if sDir == "x" then
- if dir == "x" then
- if direct == -5 then
- return "~-5"
- elseif direct == 5 then
- return "~5"
- end
- else
- return "~"
- end
- elseif sDir == "z" then
- if dir == "z" then
- if direct == -5 then
- return "~-5"
- elseif direct == 5 then
- return "~5"
- end
- else
- return "~"
- end
- end
- end
- function drawSlot(nSlot)
- if nSlot == 1 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..discern("left","x").." ~1 "..discern("left","z").." "..data.id.." "..data.dmg)
- elseif nSlot == 2 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..middle("x").." ~1 "..middle("z").." "..data.id.." "..data.dmg)
- elseif nSlot == 3 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..discern("right","x").." ~1 "..discern("right","z").." "..data.id.." "..data.dmg)
- elseif nSlot == 4 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..discern("left","x").." ~ "..discern("left","z").." "..data.id.." "..data.dmg)
- elseif nSlot == 5 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..middle("x").." ~ "..middle("z").." "..data.id.." "..data.dmg)
- elseif nSlot == 6 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..discern("right","x").." ~ "..discern("right","z").." "..data.id.." "..data.dmg)
- elseif nSlot == 7 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..discern("left","x").." ~-1 "..discern("left","z").." "..data.id.." "..data.dmg)
- elseif nSlot == 8 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..middle("x").." ~-1 "..middle("z").." "..data.id.." "..data.dmg)
- elseif nSlot == 9 then
- local data = draw.getSlot(nSlot)
- if not data then data = {id = "minecraft:air", dmg = 0} end
- commands.exec("setblock "..discern("right","x").." ~-1 "..discern("right","z").." "..data.id.." "..data.dmg)
- end
- end
- while true do
- os.pullEvent("slot_click")
- for i=1,9 do
- drawSlot(i)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement