Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --controller=peripheral.wrap("appeng_me_tilecontroller_0")
- --terminal=peripheral.wrap("appeng_me_tileterminal_0")
- --craftingmon=peripheral.wrap("appeng_me_tilecraftingmonitor_0")
- mon=peripheral.wrap("top")
- steam=peripheral.wrap("right")
- buttons={}
- buttonTexts={}
- buttonFunctions={}
- mon.clear()
- mon.setTextScale(.5)
- function cText(msg, x1, x2, y, bColor, tColor)
- mon.setBackgroundColor(colors[bColor])
- mon.setTextColor(colors[tColor])
- sizeX=(((x2)/2)-(string.len(msg)/2))-1
- mon.setCursorPos(x1+sizeX, y)
- mon.write(msg)
- sizeX, sizeY=mon.getSize()
- end
- function fillArea(x1, x2, y1, y2, color)
- mon.setBackgroundColor(colors[color])
- for y=1,1+y2-y1 do
- for x=1,1+x2-x1 do
- mon.setCursorPos(x1+x-1, y1+y-1)
- mon.write(" ")
- end
- end
- end
- function addButton(x1, x2, y1, y2, name, text)
- table.insert(buttonFunctions, name)
- table.insert(buttons, x1 .."-" ..x2 .."-" ..y1 .."-" ..y2)
- mon.setBackgroundColor(colors.green)
- for y=1,1+y2-y1 do
- for x=1,1+x2-x1 do
- mon.setCursorPos(x1+x-1, y1+y-1)
- mon.write(" ")
- end
- end
- if text~= nil then
- cText(text, x1, x2, ((y1+y2)/2), "green", "white")
- table.insert(buttonTexts, text)
- else
- table.insert(buttonTexts, "")
- end
- mon.setBackgroundColor(colors.black)
- end
- local function readButton(number)
- splits={}
- for i=1,string.len(buttons[number]) do
- if string.sub(buttons[number], i, i)=="-" then
- table.insert(splits, i)
- end
- end
- values={}
- table.insert(values, string.sub(buttons[number], 1, splits[1]-1))
- table.insert(values, string.sub(buttons[number], splits[1]+1, splits[2]-1))
- table.insert(values, string.sub(buttons[number], splits[2]+1, splits[3]-1))
- table.insert(values, string.sub(buttons[number], splits[3]+1, string.len(buttons[number])))
- newValues={}
- for i=1, #values do
- table.insert(newValues, tonumber(values[i]))
- end
- return newValues
- end
- local function isButton(posX, posY)
- found=false
- for i=1,#buttons do
- local coords=readButton(i)
- x1=coords[1]
- x2=coords[2]
- y1=coords[3]
- y2=coords[4]
- for y=1,1+y2-y1 do
- for x=1,1+x2-x1 do
- if x1+x-1==posX and y1+y-1==posY then
- found=true
- return true, i
- end
- end
- end
- end
- if not found then
- return false, 0
- end
- end
- function getButton(x, y)
- local val, num=isButton(x, y)
- if val then
- local coords=readButton(num)
- x1=coords[1]
- x2=coords[2]
- y1=coords[3]
- y2=coords[4]
- fillArea(x1, x2, y1, y2, "red")
- cText(buttonTexts[num], x1, x2, ((y1+y2)/2), "red", "white")
- if string.sub(buttonFunctions[num], 1, 4)~="code" then
- shell.run(buttonFunctions[num])
- else
- run(string.sub(buttonFunctions[num], 6, string.len(buttonFunctions[num])))
- end
- sleep(.2)
- fillArea(x1, x2, y1, y2, "green")
- cText(buttonTexts[num], x1, x2, ((y1+y2)/2), "green", "white")
- end
- end
- function run(code)
- if code=="view ME" then
- end
- end
- sizeX, sizeY=mon.getSize()
- fillArea(1, sizeX, 1, sizeY, "yellow")
- fillArea(2, sizeX-1, 2, sizeY-1, "gray")
- cText("Awesomeness Innovations", 1, sizeX, sizeY, "yellow", "black")
- cText("Base Management", 1, sizeX, 1, "yellow", "black")
- fillArea(3, 15, 3, 3, "lightGray")
- cText("Steam Dynamo", 3, 15, 3, "lightGray", "black")
- addButton(3, 15, 4, 6, "steam", "View")
- while true do
- local e, side, x, y=os.pullEvent("monitor_touch")
- if side=="top" then
- getButton(x, y)
- end
- sleep(.000001)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement