Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get Bq3kqiSa startup
- -- -------------------------------------------
- -- 2x2 transformer door -Sinkir-
- -- Version 1
- -- setup :
- -- Computer with 3 repater on 3 side
- -- and restone signal in front.
- -- 3 input rednet cable (3 colors)
- -- view from top
- -- r r r
- -- r R r
- -- rRCRr
- -- I
- -- r = rednet cable
- -- R = repeater
- -- C = Computer
- -- I = Input (redstone)
- -- -------------------------------------------
- --
- -- P
- -- S S
- -- ob oS
- -- S OOb P
- -- P bOO S
- -- So bo
- -- S S
- -- P
- -- 2x2 door
- -- S = Sticky piston
- -- P = Piston
- -- O = block of the door 1
- -- o = block of the door 2
- -- b = block of deco (like your walls)
- -- " " space are air block
- function split(str, pat)
- -- source of the function :
- -- http://lua-users.org/wiki/SplitJoin
- -- Compatibility: Lua-5.1
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- function fileGet(path)
- if(fs.exists(path))then
- tabFile = fs.open(path, "r")
- text = tabFile.readAll()
- tabFile.close()
- return text
- else
- print("fileGet() File not found.")
- print(path)
- return false
- end
- end
- function fileSet(path, text)
- if(fs.isReadOnly(path))then
- print("fileSet() File is read only.")
- print(path)
- return false
- else
- tabFile = fs.open(path, "w")
- tabFile.write(text)
- tabFile.close()
- return true
- end
- end
- function savedata()
- fileSet("data", a ..",".. b)
- end
- function dealer()
- redstone.setOutput("back", true)
- sleep(0.1)
- redstone.setOutput("back", false)
- end
- function swaper()
- redstone.setOutput("left", true)
- sleep(0.1)
- redstone.setOutput("left", false)
- end
- function pusher()
- redstone.setOutput("right", true)
- sleep(0.1)
- redstone.setOutput("right", false)
- end
- if(fs.exists("data")==true)then
- --Shaundi()
- else
- fileSet("data", "0,0")
- end
- tab = split(fileGet("data"), ",")
- a = tostring(tab[1])
- b = tostring(tab[2])
- flag = false
- while(2)do
- if(redstone.getInput("front") == true and flag == false)then
- --
- if(a == "0")then
- dealer()
- a = "1"
- elseif(a == "1")then
- if(b == "0")then
- dealer()
- sleep(0.1)
- swaper()
- sleep(0.1)
- dealer()
- sleep(0.1)
- dealer()
- sleep(0.1)
- b = "1"
- elseif(b == "1")then
- pusher()
- sleep(0.1)
- dealer()
- sleep(0.1)
- dealer()
- sleep(0.1)
- b = "2"
- elseif(b == "2")then
- pusher()
- sleep(0.1)
- swaper()
- sleep(0.1)
- b = "0"
- end
- a = "0"
- end
- savedata()
- flag = true
- end
- if(redstone.getInput("front") == false)then
- flag = false
- end
- sleep(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement