Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function variables()
- rednet.open("top")
- out1=peripheral.wrap("flux_gate_79")
- in1=peripheral.wrap("flux_gate_78")
- cap1=peripheral.wrap("draconic_rf_storage_16")
- isCap1={empty=false,full=false,outp=false,inp=false,c=false}
- maxIn=60000000
- maxOut=5000000
- lot=1640000000
- koupeno=0
- preneseno=0
- -- prenesenoStr
- pass=0
- pass1=0
- ipass=0
- start=false
- cBuy=0
- cCount=0
- gate=true
- isOpened=false
- btnGate=0
- mainScreenGate=false
- passGate=false
- count=0
- ID=2284
- price=10
- redstone.setOutput("left",true)
- sleep(1)
- redstone.setOutput("left",false)
- end
- function formatInt(number)
- if number == nil then number = 0 end
- local i,j,minus,int,fraction=tostring(number):find('([-]?)(%d+)([.]?%d*)')
- int=int:reverse():gsub("(%d%d%d)","%1,")
- return minus .. int:reverse():gsub("^,","") .. fraction
- end
- function getAllVariables()
- local data=fs.open("cap1.txt","r")
- isCap1.empty=data.readLine()
- isCap1.full=data.readLine()
- isCap1.outp=data.readLine()
- isCap1.inp=data.readLine()
- isCap1.c=data.readLine()
- data.close()
- local data=fs.open("gates.txt","r")
- gate=data.readLine()
- isOpened=data.readLine()
- mainScreenGate=data.readLine()
- data.close()
- local data=fs.open("pass.txt","r")
- pass=data.readLine()
- data.close()
- local data=fs.open("another.txt","r")
- start=data.readLine()
- cBuy=data.readLine()
- count=data.readLine()
- data.close()
- local data=fs.open("btnGate.txt","r")
- btnGate=data.readLine()
- data.close()
- end
- function updateCap1()
- local data=fs.open("cap1.txt","w")
- data.writeLine(isCap1.empty)
- data.writeLine(isCap1.full)
- data.writeLine(isCap1.outp)
- data.writeLine(isCap1.inp)
- data.writeLine(isCap1.c)
- data.close()
- end
- function gatesUpdate()
- local data=fs.open("gates.txt","w")
- data.writeLine(gate)
- data.writeLine(isOpened)
- data.writeLine(mainScreenGate)
- data.close()
- end
- function passUpdate()
- local data=fs.open("pass.txt","w")
- data.writeLine(pass)
- data.close()
- end
- function anotherUpdate()
- local data=fs.open("another.txt","w")
- data.writeLine(start)
- data.writeLine(cBuy)
- data.writeLine(count)
- data.close()
- end
- function btnGateUpdate()
- local data=fs.open("btnGate.txt","w")
- data.writeLine(btnGate)
- data.close()
- end
- function monClear()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextColour(colors.white)
- end
- function monSetup()
- mon=peripheral.wrap("monitor_141")
- mon.setBackgroundColor(colors.black)
- mon.clear()
- end
- function monWrite(ax,ay,tColor,BgColor,atext)
- mon.setBackgroundColor(BgColor)
- mon.setTextColour(tColor)
- mon.setCursorPos(ax,ay)
- mon.write(atext)
- end
- function firstScreen()
- btnGate=1
- monSetup()
- monWrite(10,1,colors.red,colors.black,"TERMINAL #1")
- monWrite(7,3,colors.blue,colors.black,"Max out:")
- monWrite(16,3,colors.white,colors.black,"5")
- monWrite(18,3,colors.purple,colors.black,"MRF/t")
- monWrite(7,5,colors.orange,colors.black,"1 lot:")
- monWrite(14,5,colors.white,colors.black,"1,64")
- monWrite(19,5,colors.purple,colors.black,"BRF")
- monWrite(4,7,colors.red,colors.black,"Price:")
- monWrite(11,7,colors.white,colors.black,"10")
- monWrite(14,7,colors.purple,colors.black,"Dia block/lot")
- monWrite(7,11,colors.white,colors.red,"OTEVRIT PRIPOJKU")
- while true do
- os.pullEvent()
- if btnGate==0 then
- return
- end
- end
- end
- function firstInfo()
- btnGate=2
- monClear()
- monWrite(1,1,colors.white,colors.black,"Testovaci provoz. Majtel si")
- monWrite(1,2,colors.white,colors.black,"vyhrazje pravo rusit/upravit")
- monWrite(1,3,colors.white,colors.black,"bez vaseho vedomi. jakykoliv")
- monWrite(1,4,colors.white,colors.black,"pokus o obchazeni systemu se")
- monWrite(1,5,colors.white,colors.black,"tresta. pokud nebude 30 dnu")
- monWrite(1,6,colors.white,colors.black,"aktivni output, pripojka se")
- monWrite(1,7,colors.white,colors.black,"automaticky maze.")
- monWrite(1,11,colors.white,colors.black,"Pokud souhlasis, klikni na:")
- monWrite(18,12,colors.white,colors.green,"SOUHLASIM")
- while true do
- os.pullEvent()
- if btnGate==0 then
- return
- end
- end
- end
- function passInfo()
- btnGate=3
- monClear()
- monWrite(1,3,colors.white,colors.black,"Kvuli zabezpeceni bude v")
- monWrite(1,4,colors.white,colors.black,"nasledujicim kroku zadano")
- monWrite(1,5,colors.white,colors.black,"4 mistne heslo. Toto heslo")
- monWrite(1,6,colors.white,colors.black,"bude pozdeji pozadovano pri")
- monWrite(1,7,colors.white,colors.black,"zmenach parametru pripojky")
- monWrite(1,12,colors.white,colors.black,"pro zadani hesla stiskni")
- monWrite(26,12,colors.white,colors.green,"OK")
- while true do
- os.pullEvent()
- if btnGate == 0 then
- return
- end
- end
- end
- function firstPass()
- btnGate=4
- while true do
- monClear()
- keyboardPrint()
- passGate=true
- zadejPass(1)
- while passGate do
- os.pullEvent()
- end
- pass=pass1
- pass1=0
- passGate=true
- monClear()
- keyboardPrint()
- ipass=0
- zadejPass(3)
- while passGate do
- os.pullEvent()
- end
- if pass==pass1 then
- --printClearWindow()
- --printToWindow(....)
- --mainScreenGate=true
- pass1=0
- btnGate=0
- isOpened=true
- ipass=0
- return
- else
- --printClearWindow()
- printToWindow()
- pass=0
- ipass=0
- pass1=0
- end
- end
- end
- function getPass()
- btnGate=4
- while true do
- passGate=true
- monClear()
- keyboardPrint()
- ipass=0
- zadejPass(2)
- while passGate do
- os.pullEvent()
- end
- if pass==pass1 then
- --printClearWindow()
- --printToWindow(....)
- mainScreenGate=true
- pass1=0
- btnGate=0
- ipass=0
- return
- else
- --printClearWindow()
- printToWindow()
- ipass=0
- pass1=0
- end
- end
- end
- --function printClearWindow()
- --end
- function printToWindow() --predelat
- monClear()
- monWrite(1,1,colors.white,colors.black,"CHYBA!")
- monWrite(1,2,colors.white,colors.black,"Hesla se neshoduji")
- monWrite(1,3,colors.white,colors.black,"opakuj proces")
- sleep(4)
- end
- function Loader(x)--dodelat
- if x==1 then
- getPass()
- end
- btnGate=5
- monClear()
- if x==0 then
- monWrite(1,1,colors.white,colors.black,"na cerveny blok poloz ")
- monWrite(1,2,colors.white,colors.black,"tesseract, na cerny naplneny")
- monWrite(1,3,colors.white,colors.black,"chunkoader* a potvrd")
- monWrite(1,6,colors.white,colors.black,"* Chunkloader neni nutny,")
- monWrite(1,7,colors.white,colors.black,"ale...")
- monWrite(5,11,colors.white,colors.green,"OK")
- monWrite(10,11,colors.white,colors.green,"CANCEL")
- else
- monWrite(1,1,colors.white,colors.black,"vysunul jsi loader")
- monWrite(1,2,colors.white,colors.black,"pro zasunuti stiskni ok")
- monWrite(5,11,colors.white,colors.green,"OK")
- end
- redstone.setOutput("bottom",true)
- sleep(1)
- redstone.setOutput("bottom",false)
- while true do
- os.pullEvent()
- if btnGate==0 then
- return
- end
- end
- end
- function buy(x)
- if x==1 then
- getPass()
- end
- btnGate=10
- mainScreenGate=false
- monClear()
- monWrite(1,1,colors.white,colors.black,"vhod dia do crate a potvrd")
- monWrite(1,2,colors.white,colors.black,"prepocet chvilku trva,")
- monWrite(1,3,colors.white,colors.black,"prosim o strpeni")
- monWrite(13,11,colors.white,colors.green,"OK")
- while true do
- eID,msg,dist=rednet.receive()
- if eID==ID then
- count=tonumber(msg)
- print(count)
- print(msg)
- btnGate=11
- break
- end
- end
- vratit=(count-math.floor(count/price)*price)
- zaplaceno=(math.floor(count/price))*price
- koupeno=koupeno+lot*(zaplaceno/price)
- cBuy=cBuy+(zaplaceno/price)
- print(vratit)
- print(zaplaceno)
- monClear()
- monWrite(1,1,colors.white,colors.black,"zaplaceno:")
- monWrite(1,2,colors.white,colors.black,tostring(zaplaceno))
- monWrite(1,3,colors.white,colors.black,"vraceno:")
- monWrite(1,4,colors.white,colors.black,tostring(vratit))
- monWrite(1,5,colors.white,colors.black,"koupeno nergie:")
- monWrite(1,6,colors.lightGray,colors.black,formatInt(lot*(zaplaceno/price)))
- monWrite(5,11,colors.white,colors.green,"OK")
- monWrite(10,11,colors.white,colors.red,"CANCEL")
- while true do
- os.pullEvent()
- if btnGate==0 then
- return
- end
- end
- end
- function mainScreen()
- -- monClear()
- -- prenesenoProc=(preneseno/koupeno)*100
- -- preneseno=cCount*1640000000
- if isCap1.outp then
- preneseno=(cCount)*1640000000+(1640000000-cap1.getEnergyStored())
- -- sleep(1)
- else
- preneseno=cCount*1640000000
- -- sleep(1)
- end
- monClear()
- monWrite(5,3,colors.white,colors.black,"koupeno")
- monWrite(1,4,colors.lightGray,colors.black,formatInt(koupeno))
- monWrite(3,6,colors.white,colors.black,"preneseno")
- monWrite(1,7,colors.lightGray,colors.black,formatInt(preneseno))
- monWrite(19,2,colors.white,colors.green," dokoupit ")
- monWrite(19,3,colors.white,colors.green," energii ")
- monWrite(19,5,colors.white,colors.green," vysunout ")
- monWrite(19,6,colors.white,colors.green," ch.loader")
- monWrite(19,8,colors.white,colors.green," help ")
- monWrite(19,10,colors.white,colors.red," zrusit ")
- monWrite(19,11,colors.white,colors.red," pripojku ")
- end
- function zadejPass(x)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- if x==1 then
- mon.setCursorPos(11,2)
- mon.write("zadej 4 mistne")
- mon.setCursorPos(11,3)
- mon.write("heslo a potvrd OK")
- elseif x==2 then
- mon.setCursorPos(11,2)
- mon.write(" ")
- mon.setCursorPos(11,2)
- mon.write("zadej heslo")
- mon.setCursorPos(11,3)
- mon.write("a potvrd OK")
- elseif x==3 then
- mon.setCursorPos(11,2)
- mon.write(" ")
- mon.setCursorPos(11,2)
- mon.write("potvrd heslo")
- mon.setCursorPos(11,3)
- mon.write("a potvrd OK")
- end
- end
- function keyboardPrint()
- monClear()
- mon.setBackgroundColour(colors.blue)
- mon.setCursorPos(2,1)
- mon.write(" ")
- mon.setCursorPos(5,1)
- mon.write(" ")
- mon.setCursorPos(8,1)
- mon.write(" ")
- mon.setCursorPos(2,2)
- mon.write("7 ")
- mon.setCursorPos(5,2)
- mon.write("8 ")
- mon.setCursorPos(8,2)
- mon.write("9 ")
- mon.setCursorPos(2,4)
- mon.write(" ")
- mon.setCursorPos(5,4)
- mon.write(" ")
- mon.setCursorPos(8,4)
- mon.write(" ")
- mon.setCursorPos(2,5)
- mon.write("4 ")
- mon.setCursorPos(5,5)
- mon.write("5 ")
- mon.setCursorPos(8,5)
- mon.write("6 ")
- mon.setCursorPos(2,7)
- mon.write(" ")
- mon.setCursorPos(5,7)
- mon.write(" ")
- mon.setCursorPos(8,7)
- mon.write(" ")
- mon.setCursorPos(2,8)
- mon.write("1 ")
- mon.setCursorPos(5,8)
- mon.write("2 ")
- mon.setCursorPos(8,8)
- mon.write("3 ")
- mon.setCursorPos(2,10)
- mon.write(" ")
- mon.setCursorPos(2,11)
- mon.write("0 ")
- mon.setCursorPos(5,10)
- mon.setBackgroundColor(colors.lime)
- mon.write(" ")
- mon.setCursorPos(5,11)
- mon.write("OK")
- mon.setCursorPos(8,10)
- mon.setBackgroundColor(colors.red)
- mon.write(" ")
- mon.setCursorPos(8,11)
- mon.write("DL")
- mon.setCursorPos(28,11)
- mon.write(" ")
- mon.setCursorPos(28,12)
- mon.write("X ")
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(11,5)
- mon.write("PASS:")
- end
- function buttons()
- while true do
- event, side, x, y=os.pullEvent("monitor_touch")
- if btnGate==1 then
- if x>6 and x<19 and y==11 then
- btnGate=0
- end
- elseif btnGate==2 then
- if x>17 and x<27 and y==12 then
- btnGate=0
- end
- elseif btnGate==3 then
- if x>25 and x<28 and y==12 then
- btnGate=0
- end
- elseif btnGate==4 then
- if x>1 and x<4 and y<3 and ipass<4 then
- pass1=pass1*10+7
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>4 and x<7 and y<3 and ipass<4 then
- pass1=pass1*10+8
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>7 and x<10 and y<3 and ipass<4 then
- pass1=pass1*10+9
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>1 and x<4 and y>3 and y<6 and ipass<4 then
- pass1=pass1*10+4
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>4 and x<7 and y>3 and y<6 and ipass<4 then
- pass1=pass1*10+5
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>7 and x<10 and y>3 and y<6 and ipass<4 then
- pass1=pass1*10+6
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>1 and x<3 and y>6 and y<9 and ipass<4 then
- pass1=pass1*10+1
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>3 and x<7 and y>6 and y<9 and ipass<4 then
- pass1=pass1*10+2
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>7 and x<10 and y>6 and y<9 and ipass<4 then
- pass1=pass1*10+3
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>1 and x<4 and y>9 and y<12 and ipass<4 then
- pass1=pass1*10+0
- mon.setCursorPos(16+ipass,5)
- mon.write("*")
- ipass=ipass+1
- elseif x>7 and x<10 and y>9 and y<12 then
- if ipass>0 then
- pass1=math.floor(pass1/10)
- ipass=ipass-1
- mon.setCursorPos(16+ipass,5)
- mon.write(" ")
- end
- elseif x>4 and x<7 and y>9 and y<12 and ipass==4 then
- passGate=false
- end
- elseif btnGate==5 then
- if x>4 and x<8 and y==11 then
- btnGate=0
- redstone.setOutput("left",true)
- sleep(1)
- redstone.setOutput("left",false)
- end
- elseif btnGate==10 then
- if x>10 and x<14 and y==11 then
- rednet.send(ID,1)
- mainScreenGate=true
- --if start==false and cBuy>0 then
- -- start=true
- -- gate=true
- -- end
- end
- elseif btnGate==11 then
- if x>4 and x<8 and y==11 then
- rednet.send(ID,3)
- btnGate=0
- mainScreenGate=true
- if start==false and cBuy>0 then
- start=true
- end
- --start=true
- elseif x>9 and x<17 and y==11 then
- rednet.send(ID,2)
- btnGate=0
- mainScreenGate=true
- end
- elseif btnGate==0 then
- if x>18 and x<29 and y>1 and y<4 then
- btnGate=10
- elseif x>18 and x<29 and y>4 and y<7 then
- btnGate=5
- end
- end
- sleep(0.1)
- end
- end
- function disp()
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("pass: "..pass)
- print("start: "..(start and 'true' or 'false'))
- print("gate: "..(gate and 'true' or 'false'))
- print("cap1:empty:"..(isCap1.empty and 'true' or 'false').." ,full:"..(isCap1.full and 'true' or 'false').." ,outp:"..(isCap1.outp and 'true' or 'false').." ,inp:"..(isCap1.inp and 'true' or 'false'))
- print("cBuy: "..cBuy.." ,cCount: "..cCount)
- if not isOpened then
- firstScreen()
- firstInfo()
- passInfo()
- firstPass()
- buy(0)
- Loader(0)
- else
- if mainScreenGate then
- mainScreen()
- end
- if btnGate==10 then
- buy(1)
- elseif btnGate==5 then
- Loader(1)
- end
- end
- sleep(0.1)
- end
- end
- function capReg()
- while true do
- if start then
- if gate then
- -- cCount=0
- isCap1.outp=true
- -- output.setSignalLowFlow(maxOut)
- gate=false
- end
- else
- --output.setSignalLowFlow(0)
- end
- ------------
- -- cap1 empty/full begin
- if cap1.getEnergyStored()==cap1.getMaxEnergyStored() then
- isCap1.full=true
- else
- isCap1.full=false
- end
- if cap1.getEnergyStored()==0 then
- isCap1.empty=true
- else
- isCap1.empty=false
- end
- -- cap1 empty/full end
- --cap1 set in/out flow begin
- if isCap1.outp then
- out1.setSignalLowFlow(maxOut)
- else
- out1.setSignalLowFlow(0)
- end
- if isCap1.inp then
- in1.setSignalLowFlow(maxIn)
- else
- in1.setSignalLowFlow(0)
- end
- if isCap1.empty and isCap1.outp then
- isCap1.outp=false
- isCap1.c=true
- end
- if isCap1.full and isCap1.inp then
- isCap1.inp=false
- end
- -- cap1 fill/unfill start/stop begin
- --fill
- if isCap1.empty and not isCap1.outp then
- isCap1.inp=true
- end
- --unfill
- if isCap1.full and not isCap1.inp and start then
- isCap1.outp=true
- count=count+1
- end
- -- cap1 fill/unfill start/stop end
- sleep(0.1)
- --------
- end
- end
- variables()
- --updateCap1()
- --gatesUpdate()
- --passUpdate()
- --anotherUpdate()
- --btnGateUpdate()
- --getAllVariables()
- parallel.waitForAny(buttons,disp,capReg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement