Timmy94W 0 Posted July 6, 2015 Share Posted July 6, 2015 This litte and simple Programm is my version of a DHD. It showes you the Chevrons on the Screen and when they are encoded. Pretty simple and unique i think. It designed to work with LanteaCraft. Originally written for OCJam A short Viedopreview: https://youtu.be/MaeEQqPi3No With this three lines you can change the settings like the time to close the gate after a connecting ist ethablished or the aspect of the DHD. @Vexatos: Can i at this to the OPPM? local timeUntilClosing = 30 -- Idle time until closing the Gate after ethablishing a wormhole [ DEFAULT: 30 ] sX=sX/2-6 -- If you want edit the 'x' position at the screen [ DEFAULT: sX=sX/2-6 ] sY=sY/2-6 -- If you want edit the 'y' position at the screen [ DEFAULT: sY=sY/2-6 ] Here is the complet code: --[[ Simple DHD Author: by Timmy94W ( http://t94.cwsurf.de/wbb/ ) Version: 1.0 To Work with LanteaCraft (http://lanteacraft.com) ]] local term = require("term") local component = require("component") local event = require("event") local shell = require("shell") local address local maxCount = -1 local tX,tY local gpu = component.gpu local sX,sY = gpu.getResolution() -- You can change the line below this one. local timeUntilClosing = 30 -- Idle time until closing the Gate after ethablishing a wormhole [ DEFAULT: 30 ] sX=sX/2-6 -- If you want edit the 'x' position at the screen [ DEFAULT: sX=sX/2-6 ] sY=sY/2-6 -- If you want edit the 'y' position at the screen [ DEFAULT: sY=sY/2-6 ] -- Please do not more change lines below this. if not component.isAvailable("stargate")then term.clear() print("No Stargate aviable. Closing program.") os.exit() end local sg = component.stargate function closeWormhole() sg.disconnect() term.clear()term.setCursor(sX,sY) print("--o--o--o--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("o o")term.setCursor(sX,sY+3) print("- -")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("o o")term.setCursor(sX,sY+6) print("--o--=--o--")term.setCursor(sX,sY+7) term.setCursor(sX,sY+10) term.write(sg.getAddress()) term.setCursor(sX,sY+11) term.write("Disconnecting") os.sleep(3) mainProcess() end function showIdleScreen() term.clear() term.setCursor(sX,sY) print("--o--o--o--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("o o")term.setCursor(sX,sY+3) print("- Error -")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("o o")term.setCursor(sX,sY+6) print("--o--=--o--")term.setCursor(sX,sY+7) term.setCursor(sX,sY+10) term.write(sg.getAddress()) term.setCursor(sX,sY+11) term.write("Can't dial to: "..address) os.sleep(15) mainProcess() end function showChevron() local count = 0 while count ~= maxCount do local _, _, Chevron = event.pull("sgChevronEncode") count = Chevron if(Chevron==1)then term.clear()term.setCursor(sX,sY) print("--o--o--x--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("o o")term.setCursor(sX,sY+3) print("- Dialing -")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("o o")term.setCursor(sX,sY+6) print("--o--=--o--")term.setCursor(sX,sY+7) term.setCursor(sX,sY+10) term.write(sg.getAddress()) term.setCursor(sX,sY+11) term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(Chevron==2)then term.setCursor(sX,sY+2)print("o x") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(Chevron==3)then term.setCursor(sX,sY+5)print("o x") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(Chevron==4)then term.setCursor(sX,sY+5)print("x x") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(Chevron==5)then term.setCursor(sX,sY+2)print("x x") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(Chevron==6)then idleStateOne = event.timer(15, showIdleScreen) term.setCursor(sX,sY)print("--x--o--x--") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(Chevron==7)then event.cancel(idleStateOne) if(maxCount==7)then term.setCursor(sX,sY)print("--x--x--x--") term.setCursor(sX,sY+3)print("-Connected-") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(maxCount==9)then term.setCursor(sX,sY+6)print("--o--=--x--") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end end if(Chevron==8)then idleStateTwo = event.timer(15, showIdleScreen) term.setCursor(sX,sY+6)print("--x--=--x--") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end if(Chevron==9)then event.cancel(idleStateTwo) term.clear()term.setCursor(sX+7,sY+15)term.write("Shut down") term.setCursor(sX,sY)print("--x--x--x--") term.setCursor(sX,sY+11)term.write("Chevron "..Chevron.." encoded") os.sleep(1) end end end function exitProgram() term.clear() print("Shutting down DHD.") sg.disconnect() os.exit() end function toggleIris() -- Iris is not implemented in LanteaCraft term.setCursor(sX/2,sY+13)term.write("The Iris is not implemented in LanteaCraft") term.setCursor(sX/2,sY+14)term.write("Look at http://lanteacraft.com for Infomations.") term.setCursor(sX,sY+12)os.sleep(5) end function checkIncoming() while true do event.listen("sgIdle",mainProcess) term.clear()term.setCursor(sX,sY) print("--o--o--o--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("o o")term.setCursor(sX,sY+3) print("-Incoming -")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("o o")term.setCursor(sX,sY+6) print("--o--=--o--")term.setCursor(sX,sY+7) term.setCursor(sX,sY+10) term.write(sg.getAddress()) term.setCursor(sX,sY+11) term.write("Incoming Wormhole") term.setCursor(sX,sY+12) term.write("") address = io.read() if(address=="iris")then toggleIris() end if(address=="exit")then exitProgram() end end end function mainProcess() while true do event.listen("sgIncoming",checkIncoming) if(sg.isDialing()==true)then term.setCursor(sX,sY) print("--o--o--o--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("o o")term.setCursor(sX,sY+3) print("- Dialing -")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("o o")term.setCursor(sX,sY+6) print("--o--=--o--")term.setCursor(sX,sY+7) ShowChevron() end term.clear() term.setCursor(sX,sY) print("--o--o--o--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("o o")term.setCursor(sX,sY+3) print("- Idle -")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("o o")term.setCursor(sX,sY+6) print("--o--=--o--")term.setCursor(sX,sY+7) term.setCursor(sX,sY+10) term.write(sg.getAddress()) term.setCursor(sX,sY+11) term.write("Please enter an address: ") term.setCursor(sX,sY+12) term.write("") address = io.read() maxCount = string.len(address) if(address=="exit")then exitProgram() end if(address=="iris")then toggleIris() end if(address=="disconnect")then closeWormhole() end term.setCursor(sX,sY) print("--o--o--o--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("o o")term.setCursor(sX,sY+3) print("- Dialing -")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("o o")term.setCursor(sX,sY+6) print("--o--=--o--")term.setCursor(sX,sY+7) if(sg.isConnected()==true)then closeWormhole() end if(sg.dial(address)==true)then showChevron() end if(sg.isConnected()==true)then term.clear()term.setCursor(sX,sY) print("--x--x--x--")term.setCursor(sX,sY+1) print("- -")term.setCursor(sX,sY+2) print("x x")term.setCursor(sX,sY+3) print("-Connected-")term.setCursor(sX,sY+4) print("- -")term.setCursor(sX,sY+5) print("x x")term.setCursor(sX,sY+6) print("--x--=--x--")term.setCursor(sX,sY+7) term.setCursor(sX,sY+10) term.write(sg.getAddress()) term.setCursor(sX,sY+11) term.write("Connected to: "..address) os.sleep(timeUntilClosing) sg.disconnect() end end end mainProcess() exitProgram() Quote Link to post Share on other sites