Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("left")
- mon = peripheral.wrap("back")
- rs.setOutput("right", false)
- term.setBackgroundColor(32768)
- term.setCursorPos(1,1)
- term.clear()
- function calc_color(color)
- return math.pow(2, color - 1)
- end
- function msg(gap, line, color, groundb, text)
- mon.setBackgroundColor(calc_color(groundb))
- mon.setCursorPos(gap,line)
- mon.setTextColor(calc_color(color))
- text = mon.write(text)
- end
- local file = fs.open("Shards", "w")
- file.write(0)
- file.close()
- msg(05,03,05,16,"Trade Goldblocks to Ironblocks")
- msg(05,04,01,16,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
- function clear()
- for yPos = 5, 22 do
- msg(01,yPos,16,16," ")
- end
- end
- function LangSelect()
- clear()
- for yPos = 7, 11 do
- for xPos = 3, 15 do
- msg(xPos,yPos,01,06," ")
- end
- end
- msg(06,09,01,06,"Deutsch")
- for yPos = 7, 11 do
- for xPos = 24, 36 do
- msg(xPos,yPos,01,06," ")
- end
- end
- msg(27,09,01,06,"English")
- event, side, x, y = os.pullEvent("monitor_touch")
- if x >= 03 and x <= 15 and y >= 07 and y <= 11 then
- local file = fs.open("Language", "w")
- file.write("2")
- file.close()
- elseif x >= 24 and x <= 36 and y >= 07 and y <= 11 then
- local file = fs.open("Language", "w")
- file.write("1")
- file.close()
- else
- LangSelect()
- end
- ShardDetection()
- end
- function ShardDetection()
- clear()
- local file = fs.open("Language", "r")
- Lang = file.readLine()
- file.close()
- for yPos = 13, 15 do
- for xPos = 3, 15 do
- msg(xPos,yPos,01,06," ")
- end
- end
- for yPos = 13, 15 do
- for xPos = 20, 29 do
- msg(xPos,yPos,01,15," ")
- end
- end
- if Lang == "1" then
- msg(02,07,01,16,"Insert all your Shard of Minium")
- msg(02,08,01,16,"and Gold Blocks in the left ME System.")
- msg(02,11,01,16,"Then confirm with the button below!")
- msg(06,14,01,06,"confirm")
- msg(22,14,01,15," back ")
- elseif Lang == "2" then
- msg(02,07,01,16,"Werfe alle deine Shards und")
- msg(02,08,01,16,"Eisenblöcke in das linke ME-System.")
- msg(02,11,01,16,"Dann bestätige mit dem grünen Knopf!")
- msg(06,14,01,06," start ")
- msg(22,14,01,15,"zurück")
- end
- event, side, x, y = os.pullEvent("monitor_touch")
- if x >= 03 and x <= 15 and y >= 13 and y <= 15 then --Confirm
- StartCraftingScreen()
- elseif x >= 20 and x <= 29 and y >= 13 and y <= 15 then --back
- os.reboot()
- else
- ShardDetection()
- end
- end
- function StartCraftingScreen()
- s = sen.getTargets()
- function getS()
- for v, k in pairs(s) do
- if k.Name == "ME Wireless Access Point" then
- target = v
- end
- end
- sleep(0.5)
- return target
- end
- f = getS()
- s1 = sen.getTargetDetails(target)
- for v, k in pairs(s1.Items) do
- if k.Name == "Shard of Minium" then
- Shard_Of_Minium_Amount = k.Size
- print("Shards Detected: "..Shard_Of_Minium_Amount)
- local file = fs.open("Shards", "w")
- file.write(Shard_Of_Minium_Amount)
- file.close()
- end
- end
- local file = fs.open("Shards", "r")
- Shard_Of_Minium_Amount = file.readLine()
- file.close()
- Shard_Of_Minium_Amount = tonumber(Shard_Of_Minium_Amount)
- Insert_Gold_Blocks = Shard_Of_Minium_Amount * 40
- clear()
- for yPos = 14, 16 do
- for xPos = 3, 15 do
- msg(xPos,yPos,01,06," ")
- end
- end
- for yPos = 14, 16 do
- for xPos = 20, 31 do
- msg(xPos,yPos,01,15," ")
- end
- end
- if Lang == "1" then
- msg(02,07,01,16,"Detected Shards: "..Shard_Of_Minium_Amount)
- msg(02,09,01,16,""..Insert_Gold_Blocks .." Goldblocks can be processed")
- msg(02,10,01,16,"and should be in the left ME-System.")
- msg(02,12,01,16,"-> confirm with green button to start")
- msg(06,15,01,06,"confirm")
- msg(23,15,01,15,"cancel")
- elseif Lang == "2" then
- msg(02,07,01,16,"Erkannte Shards: "..Shard_Of_Minium_Amount)
- msg(02,09,01,16,""..Insert_Gold_Blocks .." Goldblöcke können vercraftet")
- msg(02,10,01,16,"werden und sollten im linken ME liegen.")
- msg(02,12,01,16,"-> dann mit Start bestätigen ")
- msg(06,15,01,06," start ")
- msg(23,15,01,15,"zurück")
- end
- event, side, x, y = os.pullEvent("monitor_touch")
- if x >= 03 and x <= 14 and y >= 14 and y <= 16 and Shard_Of_Minium_Amount >= 1 then --start crafting
- CraftingScreen()
- elseif x >= 20 and x <= 31 and y >= 14 and y <= 16 then --cancel
- Shard_Of_Minium_Amount = 0
- local file = fs.open("Shards", "w")
- file.write(0)
- file.close()
- ShardDetection()
- else
- StartCraftingScreen()
- end
- end
- function CraftingScreen()
- clear()
- for yPos = 15, 17 do --Restart
- for xPos = 3, 24 do
- msg(xPos,yPos,01,06," ")
- end
- end
- for yPos = 15, 17 do --cancel
- for xPos = 28, 37 do
- msg(xPos,yPos,01,15," ")
- end
- end
- if Lang == "1" then
- rs.setOutput("right", true)
- msg(02,07,01,16,"Crafting in process...")
- msg(02,08,01,16,"Iron Block Output in Right ME-System")
- msg(02,10,01,16,"You can stop the Craftingprocess by")
- msg(02,11,01,16,"pressing the cancel button.")
- msg(02,12,01,16,"You get everything back that")
- msg(02,13,01,16,"hasn't been crafted yet.")
- msg(06,16,01,06,"restart if ready")
- msg(30,16,01,15,"cancel")
- elseif Lang == "2" then
- rs.setOutput("right", true)
- msg(02,07,01,16,"Craftingprozess läuft...")
- msg(02,08,01,16,"Eisenblock-Ausgabe im rechten ME")
- msg(02,10,01,16,"Du kannst das Crafting stoppen in dem")
- msg(02,11,01,16,"du den zurück Knopf drückst.")
- msg(02,12,01,16,"Du bekommst alles wieder, das noch")
- msg(02,13,01,16,"nicht vercraftet wurde.")
- msg(04,16,01,06,"Neustart wenn fertig")
- msg(30,16,01,15,"zurück")
- end
- event, side, x, y = os.pullEvent("monitor_touch")
- if x >= 03 and x <= 24 and y >= 15 and y <= 17 then
- os.reboot()
- elseif x >= 28 and x <= 37 and y >= 15 and y <= 17 then
- os.reboot()
- else
- CraftingScreen()
- end
- end
- --Program Start
- LangSelect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement