Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin run 7y3scDEK
- local program = [[
- local modem = peripheral.find("modem")
- local side = "right"
- modem.open(8)
- term.clear()
- term.setCursorPos(1,1)
- if type(key) == "number" then
- print(keys.getName(key))
- else
- print("\""..key.."\"")
- end
- local mon = peripheral.find("monitor")
- local mx,my
- if mon then
- mon.setTextScale(2)
- mx,my = mon.getSize()
- end
- local drawMon = function(invertColors)
- if mon then
- if type(key) == "number" then
- mon.setCursorPos(math.max(1,math.ceil(mx/2)-math.floor(#keys.getName(key)/2)), math.ceil(my/2))
- else
- mon.setCursorPos(math.max(1,math.ceil(mx/2)-math.floor(#key/2)), math.ceil(my/2))
- end
- mon.setTextColor(invertColors and colors.black or colors.white)
- mon.setBackgroundColor(invertColors and colors.white or colors.black)
- mon.clear()
- mon.write((type(key) == "number" and keys.getName(key):upper() or key:upper()))
- end
- end
- local pushed = false
- drawMon(false)
- while true do
- local evt = {os.pullEvent()}
- if evt[1] == "monitor_touch" then
- modem.transmit(8,8,{
- ["key"] = key,
- ["status"] = true
- })
- drawMon(true)
- modem.transmit(8,8,{
- ["key"] = key,
- ["status"] = false
- })
- sleep(0.1)
- drawMon(false)
- elseif evt[1] == "redstone" then
- if (rs.getInput(side)) ~= pushed then
- pushed = not pushed
- modem.transmit(8,8,{
- ["key"] = key,
- ["status"] = pushed
- })
- if pushed then
- drawMon(true)
- if key == "turnon" then
- local comps = {peripheral.find("computer")}
- for a = 1, #comps do
- comps[a].turnOn()
- end
- end
- else
- drawMon(false)
- end
- end
- elseif evt[1] == "modem_message" then
- local message = evt[5]
- if message == "update" then
- if tonumber(key) then
- shell.run("pastebin run 7y3scDEK "..keys.getName(key))
- else
- shell.run("pastebin run 7y3scDEK "..key)
- end
- end
- end
- end
- ]]
- local tArg = {...}
- if not tArg[1] then
- error("specify key")
- end
- local file = fs.open("startup","w")
- if not tonumber(keys[tArg[1]]) then
- file.writeLine("key = \""..tArg[1].."\"")
- else
- file.writeLine("key = keys[\""..tArg[1].."\"]")
- end
- file.write(program)
- file.close()
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement