Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("tpex")
- mon = peripheral.find("monitor")
- chest = peripheral.wrap("container_chest_4")
- chest1 = peripheral.wrap("container_chest_0")
- chest2 = peripheral.wrap("container_chest_5")
- chest3 = peripheral.wrap("container_chest_6")
- chest4 = peripheral.wrap("container_chest_7")
- chest5 = peripheral.wrap("container_chest_8")
- chest6 = peripheral.wrap("container_chest_9")
- act1 = peripheral.wrap("tile_thermalexpansion_device_activator_name_0")
- act2 = peripheral.wrap("tile_thermalexpansion_device_activator_name_1")
- act3 = peripheral.wrap("tile_thermalexpansion_device_activator_name_2")
- act4 = peripheral.wrap("tile_thermalexpansion_device_activator_name_3")
- local mont = "monitor_23"
- local price = 2
- local credit = 0
- local token = "Yellorium Ingot"
- local paid = false
- local mode = 1
- local transcolor1 = colors.white
- local transcolor2 = colors.blue
- local screen1 = tpex.new("monitor_23") --Main Screen
- local screen2 = tpex.new("monitor_23") --White Frequency
- local screen3 = tpex.new("monitor_23") --Blue Frequency
- local set1 = {}
- local colorword = {}
- set1[colors.white] = 1
- set1[colors.black] = 2
- set1[colors.red] = 3
- set1[colors.green] = 4
- set1[colors.brown] = 5
- set1[colors.blue] = 6
- set1[colors.purple] = 7
- set1[colors.cyan] = 8
- set1[colors.lightGray] = 9
- set1[colors.gray] = 10
- set1[colors.pink] = 11
- set1[colors.lime] = 12
- set1[colors.yellow] = 13
- set1[colors.lightBlue] = 14
- set1[colors.magenta] = 15
- set1[colors.orange] = 16
- colorword[colors.white] = "White"
- colorword[colors.black] = "Black"
- colorword[colors.red] = "Red"
- colorword[colors.green] = "Green"
- colorword[colors.brown] = "Brown"
- colorword[colors.blue] = "Blue"
- colorword[colors.purple] = "Purple"
- colorword[colors.cyan] = "Cyan"
- colorword[colors.lightGray] = "Light Gray"
- colorword[colors.gray] = "Gray"
- colorword[colors.pink] = "Pink"
- colorword[colors.lime] = "Lime"
- colorword[colors.yellow] = "Yellow"
- colorword[colors.lightBlue] = "Light Blue"
- colorword[colors.magenta] = "Magenta"
- colorword[colors.orange] = "Orange"
- --clear activators
- chest2.pullItem("down",1)
- chest3.pullItem("down",1)
- --Setup button screens
- function ButtonCreate()
- screen1:add("Color1",Cs1,"",7,8,14,12,colors.white,colors.lime,colors.blue)
- screen1:add("Color2",Cs2,"",26,8,33,12,colors.blue,colors.lime)
- screen1:add("Return",Rtn,"",28,3,35,5,colors.red,colors.lightGray)
- screen1:add("Apply Changes and Watch",apply,"",1,15,39,19,colors.green,colors.lightGray)
- screen1:add("1",setWhite,"",36,1,37,2,colors.gray,colors.gray,colors.gray,colors.lightGray)
- screen2:add("Return",goBack,"",29,2,38,4,colors.yellow,colors.yellow)
- screen2:add("1+", C,"white" ,6 ,6 ,9 ,8 ,colors.white ,colors.lightGray,colors.white,colors.lightGray)
- screen2:add("2+", C,"orange" ,11,6 ,14,8 ,colors.orange ,colors.white ,colors.orange)
- screen2:add("3+", C,"magenta" ,16,6 ,19,8 ,colors.magenta ,colors.white ,colors.magenta)
- screen2:add("4+", C,"lightBlue",21,6 ,24,8 ,colors.lightBlue,colors.white ,colors.lightBlue)
- screen2:add("5+", C,"yellow" ,26,6 ,29,8 ,colors.yellow ,colors.white ,colors.yellow)
- screen2:add("6+", C,"lime" ,31,6 ,34,8 ,colors.lime ,colors.white ,colors.lime)
- screen2:add("7+", C,"pink" ,6 ,11,9 ,13,colors.pink ,colors.white ,colors.pink)
- screen2:add("8+", C,"gray" ,11,11,14,13,colors.gray ,colors.white ,colors.gray)
- screen2:add("9+", C,"lightGray",16,11,19,13,colors.lightGray,colors.white ,colors.lightGray)
- screen2:add("10", C,"cyan" ,21,11,24,13,colors.cyan ,colors.white ,colors.cyan)
- screen2:add("11", C,"purple" ,26,11,29,13,colors.purple ,colors.white ,colors.purple)
- screen2:add("12", C,"blue" ,31,11,34,13,colors.blue ,colors.white ,colors.blue)
- screen2:add("13", C,"brown" ,11,16,14,18,colors.brown ,colors.white ,colors.brown)
- screen2:add("14", C,"green" ,16,16,19,18,colors.green ,colors.white ,colors.green)
- screen2:add("15", C,"red" ,21,16,24,18,colors.red ,colors.white ,colors.red)
- screen2:add("16", C,"black" ,26,16,29,18,colors.black ,colors.white ,colors.black)
- screen3:add("Return",goBack,"",29,2,38,4,colors.yellow,colors.yellow)
- screen3:add("1+", C2,"white" ,6 ,6 ,9 ,8 ,colors.white ,colors.blue ,colors.white ,colors.blue)
- screen3:add("2+", C2,"orange" ,11,6 ,14,8 ,colors.orange ,colors.blue ,colors.orange ,colors.blue)
- screen3:add("3+", C2,"magenta" ,16,6 ,19,8 ,colors.magenta ,colors.blue ,colors.magenta ,colors.blue)
- screen3:add("4+", C2,"lightBlue",21,6 ,24,8 ,colors.lightBlue,colors.blue ,colors.lightBlue,colors.blue)
- screen3:add("5+", C2,"yellow" ,26,6 ,29,8 ,colors.yellow ,colors.blue ,colors.yellow ,colors.blue)
- screen3:add("6+", C2,"lime" ,31,6 ,34,8 ,colors.lime ,colors.blue ,colors.lime ,colors.blue)
- screen3:add("7+", C2,"pink" ,6 ,11,9 ,13,colors.pink ,colors.blue ,colors.pink ,colors.blue)
- screen3:add("8+", C2,"gray" ,11,11,14,13,colors.gray ,colors.blue ,colors.gray ,colors.blue)
- screen3:add("9+", C2,"lightGray",16,11,19,13,colors.lightGray,colors.blue ,colors.lightGray,colors.blue)
- screen3:add("10", C2,"cyan" ,21,11,24,13,colors.cyan ,colors.blue ,colors.cyan ,colors.blue)
- screen3:add("11", C2,"purple" ,26,11,29,13,colors.purple ,colors.blue ,colors.purple ,colors.blue)
- screen3:add("12", C2,"blue" ,31,11,34,13,colors.blue ,colors.lightBlue,colors.blue ,colors.lightBlue)
- screen3:add("13", C2,"brown" ,11,16,14,18,colors.brown ,colors.blue ,colors.brown ,colors.blue)
- screen3:add("14", C2,"green" ,16,16,19,18,colors.green ,colors.blue ,colors.green ,colors.blue)
- screen3:add("15", C2,"red" ,21,16,24,18,colors.red ,colors.blue ,colors.red ,colors.blue)
- screen3:add("16", C2,"black" ,26,16,29,18,colors.black ,colors.blue ,colors.black ,colors.blue)
- end
- function setWhite()
- transcolor1 = colors.white
- transcolor2 = colors.white
- setColor()
- end
- function C (color)
- transcolor1 = colors[color]
- end
- function C2 (color)
- transcolor2 = colors[color]
- end
- function Cs1()
- mode = 2
- end
- function Cs2()
- mode = 3
- end
- function goBack()
- mode = 1
- end
- function Rtn()
- for i = 1,27 do
- chest.pushItem("down",i)
- end
- Credit = 0
- end
- function fillin(x,y,color)
- mon.setCursorPos(x,y)
- mon.setBackgroundColor(color)
- mon.setTextColor(color)
- for i = 1,5 do
- for j = 1,6 do
- mon.write(" ")
- end
- mon.setCursorPos(x,y+i)
- end
- end
- function ReadChest()
- credit = 0
- inv = chest.getAllStacks()
- if #inv > 0 then
- for i = 1,#inv do
- slot = chest.getStackInSlot(i)
- if (slot.display_name == token) then
- credit = credit + slot.qty
- else
- chest.pushItem("down",i)
- end
- end
- end
- end
- function setColor()
- chest1.pushItem("south",set1[transcolor1],1,1)
- chest1.pushItem("north",set1[transcolor2],1,1)
- chest4.pushItem("south",set1[transcolor1],1,1)
- chest4.pushItem("north",set1[transcolor2],1,1)
- SetColors(colors.green,colors.lightGray)
- for i = 1,30 do
- mon.setCursorPos(10,10)
- if (i%2 == 0) then
- mon.write("Applying Changes...\\")
- else
- mon.write("Applying Changes.../")
- end
- os.sleep(1)
- end
- chest2.pullItem("down",1)
- chest3.pullItem("down",1)
- chest5.pullItem("down",1)
- chest6.pullItem("down",1)
- end
- function apply()
- if (credit >= price) then
- chest.condenseItems()
- chest.pushItem("north",1,4)
- chest.pushItem("down",1)
- credit = 0
- setColor()
- mode = 1
- else
- SetColors(colors.red,colors.yellow)
- mon.setCursorPos(11,3)
- mon.write("Insufficent Credit")
- mon.setCursorPos(11,4)
- mon.write("Please insert more")
- mon.setCursorPos(20-(#token/2),5)
- mon.write(token)
- os.sleep(5)
- mode = 1
- end
- end
- function ReadButtons()
- timerCode = os.startTimer(1)
- local event, side, x, y
- repeat
- event, side, x, y = os.pullEvent()
- print(event)
- if event == "timer" then
- print(timerCode..":"..side)
- if timerCode ~= side then
- print("Wrong Code")
- else
- print("Right Code")
- end
- end
- until event~= "timer" or timerCode == side
- if event == "monitor_touch" then
- print(side.." "..x..":"..y)
- if side == mont then
- if (mode == 1) then
- screen1:runOnce(x,y)
- elseif (mode == 2) then
- screen2:runOnce(x,y)
- elseif (mode == 3) then
- screen3:runOnce(x,y)
- end
- end
- end
- end
- function SetColors(forground,backbround)
- mon.clear()
- mon.setBackgroundColor(backbround)
- mon.setTextColor(forground)
- mon.setCursorPos(1,1)
- for i = 1,19 do
- mon.setCursorPos(1,i)
- for j = 1,39 do
- mon.write(" ")
- end
- end
- end
- function MainScr()
- SetColors(colors.green,colors.gray)
- mon.setCursorPos(12,1)
- mon.write("Shop Color Changer")
- mon.setCursorPos(7,3)
- mon.write("Credit: "..credit.. "/" .. price)
- mon.setCursorPos(1,4)
- mon.write("Tokens are "..token.."s")
- screen1:draw()
- end
- function Color1Screen ()
- SetColors(colors.green,colors.white)
- mon.setCursorPos(12,1)
- mon.write("Shop Color Changer")
- mon.setCursorPos(4,3)
- mon.write("Color Selector")
- mon.setCursorPos(4,4)
- mon.write("Current Color: "..colorword[transcolor1])
- fillin(5,5,colors.lightGray)
- screen2:draw()
- end
- function Color2Screen ()
- mon.clear()
- SetColors(colors.green,colors.blue)
- mon.setCursorPos(12,1)
- mon.write("Shop Color Changer")
- mon.setCursorPos(4,3)
- mon.write("Color Selector")
- mon.setCursorPos(4,4)
- mon.write("Current Color: "..colorword[transcolor2])
- fillin(30,10,colors.lightBlue)
- screen2:draw()
- end
- ButtonCreate()
- while true do
- if mode == 1 then
- MainScr()
- elseif mode == 2 then
- Color1Screen ()
- elseif mode == 3 then
- Color2Screen ()
- end
- ReadChest()
- ReadButtons()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement