Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- FUNCTIONS
- local function clear(z,x)
- if z == nil or x == nil then z = 1 x = 1 end
- term.setCursorPos(x,x)
- term.clear()
- end
- local function printUsage()
- print("Usage: ")
- print[[
- reexp <Direction>
- reexp <Direction> time
- reexp wireless
- reexp <Direction> receiver]]
- end
- local function timer(from, to, ra, text)
- if from == nil or to == nil then print("Please enter the numbers.") return end
- if ra == nil then ra = 1 end
- clear()
- while true do
- print(text, from)
- sleep(ra)
- clear()
- if from > to then
- from = from - ra
- if from == to then
- break
- end
- elseif from < to then
- from = from + ra
- if from == to then
- break
- end
- end
- end
- end
- local function openModems()
- for _, sModems in ipairs( peripheral.getNames() ) do
- if peripheral.getType( sModems ) == "modem" then
- if not rednet.isOpen( sModems ) then
- rednet.open( sModems )
- end
- return true
- end
- end
- print("no modems found, please place one and try again.")
- return false
- end
- local function redraw(text, var1)
- if not text then printError("enter text") end
- clear()
- write(text)
- term.setBackgroundColor( colors.lightGray )
- write(var1)
- term.setBackgroundColor( colors.black )
- end
- -- -------VARIABLES
- --Dierction
- local dirc = {"right", "Right", "Left", "left", "Bottom", "bottom", "Top", "top", "front", "back"}
- --VERSION
- local version = "1.0"
- -- LOCAL
- local tArgs = { ... }
- if #tArgs > 2 or #tArgs == 0 then
- printUsage()
- return false
- end
- local sCommand = tArgs[1]
- local nCommand = tArgs[2]
- local function matdir()
- for n, ndir in ipairs( dirc ) do
- if sCommand == ndir then
- return true
- end
- end
- end
- if #tArgs == 1 then
- for n, ns in ipairs( dirc ) do
- if sCommand == ns then
- clear()
- timer(10, 0, 1, "The explosion after: ")
- print("explosion!!!")
- rs.setOutput(sCommand, true)
- sleep(1)
- rs.setOutput(sCommand, false)
- end
- end
- elseif nCommand == "time" and matdir() == true then
- local chTime = 5
- local localTime = "s"
- local conTime = chTime.. localTime
- local maxm = 5
- local lowm = 1
- local maxs = 55
- local lows = 5
- local mrate = 1
- local srate = 5
- local mtos = {}
- redraw("Choose your time: ", conTime)
- while true do
- local e, but = os.pullEvent()
- if e == "key" then
- if but == 200 and localTime == "s" then
- chTime = chTime + srate
- if chTime > maxs then chTime = lowm localTime = "m" end
- elseif but == 208 and localTime == "s" then
- chTime = chTime - srate
- if chTime < lows then chTime = maxm localTime = "m" end
- elseif but == 200 and localTime == "m" then
- chTime = chTime + mrate
- if chTime > maxm then chTime = lows localTime = "s" end
- elseif but == 208 and localTime == "m" then
- chTime = chTime - mrate
- if chTime < lowm then chTime = maxs localTime = "s" end
- end
- conTime = chTime.. localTime
- redraw("Choose your time: ", conTime)
- end
- if e == "key" and but == 28 then
- if localTime == "s" then
- timer(chTime, 0, 1, "The Explostion After: ")
- print("explosion!!!")
- rs.setOutput(sCommand, true)
- break
- elseif localTime == "m" then
- local theSin = 0
- for i=1, chTime do
- theSin = theSin + 60
- table.insert(mtos, theSin)
- chTime = mtos[i]
- end
- timer(chTime, 0, 1, "The Explostion After: ")
- print("explosion!!!")
- rs.setOutput(sCommand, true)
- break
- end
- end
- end
- elseif nCommand == "wireless" and matdir() == true then
- if not openModems() then
- return
- end
- local numberDraw = 0
- redraw("Receiver ID: ", numberDraw)
- while true do
- local e, but = os.pullEvent()
- if e == "key" then
- if but == 200 then
- numberDraw = numberDraw + 1
- redraw("Receiver ID: ", numberDraw)
- elseif but == 208 then
- numberDraw = numberDraw - 1
- redraw("Receiver ID: ", numberDraw)
- elseif but == 28 then
- computerID = numberDraw
- clear()
- rednet.send(computerID, "Do your work please")
- local a,c = rednet.receive()
- clear()
- if c == "okay!" then
- print("explosion!!")
- end
- break
- end
- if numberDraw < 0 then clear() numberDraw = 0 redraw("Receiver ID: ", numberDraw) end
- end
- end
- elseif nCommand == "receiver" and matdir() == true then
- if not openModems() then
- return
- end
- clear()
- print("i'll receive it!!!, receiver on.")
- sleep(3)
- clear()
- local coid, me = rednet.receive()
- if me == "Do your work please" then sleep(0.5) rednet.send(coid, "okay!") end
- rs.setOutput(sCommand, true)
- else
- printUsage()
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement