Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local slot = 0
- local myID = os.getComputerID()
- function hotovo()
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.open("top")
- rednet.broadcast(msg, "offer")
- fs.delete("currentoffer")
- sleep(180)
- end
- function password()
- passwordD = "david"
- passwordF = "filip"
- local heslonerozpoznano = true
- while heslonerozpoznano do
- write("Heslo: ")
- local input = read("*")
- if input == passwordD
- then
- heslonerozpoznano = false
- print ("Objednavka prijata. Na ucet David bylo pripsano " .. cena .. " kreditu.")
- rednet.open("top")
- rednet.broadcast("poptavka", "ucel")
- rednet.broadcast("David","kdo")
- rednet.broadcast(cena,"kolik")
- slot = slot - 1
- hotovo()
- elseif input == passwordF
- then
- heslonerozpoznano = false
- print ("Objednavka prijata. Na ucet Filip bylo pripsano " .. cena .. " kreditu.")
- rednet.open("top")
- rednet.broadcast("poptavka", "ucel")
- rednet.broadcast("Filip","kdo")
- rednet.broadcast(cena,"kolik")
- slot = slot - 1
- hotovo()
- else print("Heslo nerozpoznano")
- sleep(1)
- end
- end
- end
- function vyplata()
- sendtable()
- local id, msg = rednet.receive(2)
- if msg == "full" then
- sleep(180)
- slot = 0
- else
- print("-----------------------------")
- print("Objednavka: ", pocet, jidlo)
- print("Vyplata: ", cena," kreditu.")
- local savetable = {}
- cena = cenajidla * pocet
- savetable[1] = pocet
- savetable[2] = jidlo
- savetable[3] = cena
- local fileWT = fs.open("currentoffer", "w")
- fileWT.write(textutils.serialize(savetable))
- fileWT.close()
- password()
- end
- end
- function sendtable()
- cena = cenajidla * pocet
- local t = {}
- t[1] = pocet
- t[2] = jidlo
- t[3] = cena
- t[4] = myID
- t[5] = "F"
- t[6] = "Glucksgefuhlausloser"
- local msg = textutils.serialize(t)
- rednet.open("top")
- rednet.broadcast(msg, "offer")
- end
- function offergen()
- while slot == 0 do
- slot = slot + 1
- n = math.random(1,152)
- pocet = math.random(32,65)
- if pocet == 65 then
- pocet = 128
- end
- if n == 1 then
- slot = slot - 1
- elseif n == 2 then
- jidlo = "x PMP spenat"
- cenajidla = 10
- elseif n == 3 then
- jidlo = "x PMP okurka"
- cenajidla = 10
- elseif n == 4 then
- jidlo = "x PMP zluta paprika"
- cenajidla = 10
- elseif n == 5 then
- jidlo = "x PMP salat"
- cenajidla = 10
- elseif n == 6 then
- jidlo = "x PMP kukurice"
- cenajidla = 5
- elseif n == 7 then
- jidlo = "x obili"
- cenajidla = 5
- elseif n == 8 then
- jidlo = "x cervena repa"
- cenajidla = 10
- elseif n == 9 then
- jidlo = "x meloun"
- cenajidla = 5
- elseif n == 10 then
- jidlo = "x PMP divoka ryze"
- cenajidla = 5
- elseif n == 11 then
- jidlo = "x jehneci"
- cenajidla = 50
- elseif n == 12 then
- jidlo = "x hovezi"
- cenajidla = 15
- elseif n >= 13 and n<= 18 then
- cenajidla = 25
- local ryba = math.random(1, 17)
- if ryba == 1 then jidlo = "x ryba"
- elseif ryba == 2 then jidlo = "x HC raw bass"
- elseif ryba == 3 then jidlo = "x HC raw carp"
- elseif ryba == 4 then jidlo = "x HC raw catfish"
- elseif ryba == 5 then jidlo = "x HC raw grouper"
- elseif ryba == 6 then jidlo = "x HC raw herring"
- elseif ryba == 7 then jidlo = "x HC raw tilapia"
- elseif ryba == 8 then jidlo = "x HC raw tuna"
- elseif ryba == 9 then jidlo = "x HC raw walleye"
- elseif ryba == 10 then jidlo = "x HC raw green heart fish"
- elseif ryba == 11 then jidlo = "x HC raw charr"
- elseif ryba == 12 then jidlo = "x HC raw mudfish"
- elseif ryba == 13 then jidlo = "x HC raw trout"
- elseif ryba == 14 then jidlo = "x HC raw anchovy"
- elseif ryba == 15 then jidlo = "x HC raw perch"
- elseif ryba == 16 then jidlo = "x HC raw snapper"
- elseif ryba == 17 then jidlo = "x HC raw eel"
- end
- elseif n == 19 then
- jidlo = "x HC raw crab"
- cenajidla = 25
- elseif n == 20 then
- jidlo = "x HC raw crayfish"
- cenajidla = 25
- elseif n == 21 then
- jidlo = "x HC raw frog"
- cenajidla = 25
- elseif n == 22 then
- jidlo = "x HC raw octopus"
- cenajidla = 25
- elseif n == 23 then
- jidlo = "x HC raw scallop"
- cenajidla = 25
- elseif n == 24 then
- jidlo = "x HC raw shrimp"
- cenajidla = 25
- elseif n == 25 then
- jidlo = "x HC raw snail"
- cenajidla = 25
- elseif n == 26 then
- jidlo = "x HC raw turtle"
- cenajidla = 25
- elseif n == 27 then
- jidlo = "x HC raw turkey"
- cenajidla = 50
- elseif n == 28 then
- jidlo = "x HC raw venison"
- cenajidla = 50
- elseif n == 29 then
- jidlo = "x HC raw rabbit"
- cenajidla = 50
- elseif n == 30 then
- jidlo = "x HC raw calamari"
- cenajidla = 25
- elseif n == 31 then
- jidlo = "x losos"
- cenajidla = 30
- elseif n == 32 then
- jidlo = "x PMP rajce"
- cenajidla = 10
- elseif n == 33 then
- jidlo = "x PMP cibule"
- cenajidla = 10
- elseif n == 34 then
- jidlo = "x mrkev"
- cenajidla = 10
- elseif n == 35 then
- jidlo = "x PMP peanuts"
- cenajidla = 10
- elseif n == 36 then
- jidlo = "x kaktus"
- cenajidla = 15
- elseif n == 37 then
- jidlo = "x kure"
- cenajidla = 10
- elseif n == 38 then
- jidlo = "x veprove"
- cenajidla = 20
- elseif n == 39 then
- jidlo = "x cukr"
- cenajidla = 10
- elseif n == 40 then
- jidlo = "x PMP blueberry"
- cenajidla = 5
- elseif n == 41 then
- jidlo = "x PMP strawberry"
- cenajidla = 5
- elseif n == 42 then
- jidlo = "x PMP blackberry"
- cenajidla = 5
- elseif n == 43 then
- jidlo = "x PMP whiteberry"
- cenajidla = 5
- elseif n == 44 then
- jidlo = "x PMP gooseberry"
- cenajidla = 5
- elseif n == 45 then
- jidlo = "x PMP beautyberry"
- cenajidla = 5
- elseif n == 46 then
- jidlo = "x PMP orangeberry"
- cenajidla = 5
- elseif n == 47 then
- jidlo = "x brambory"
- cenajidla = 5
- elseif n == 48 then
- jidlo = "x HC avocado"
- cenajidla = 5
- elseif n == 49 then
- jidlo = "x HC olive"
- cenajidla = 5
- elseif n == 50 then
- jidlo = "x HC pea"
- cenajidla = 5
- elseif n == 51 then
- jidlo = "x HC chilli"
- cenajidla = 5
- elseif n == 52 then
- jidlo = "x HC plum"
- cenajidla = 5
- elseif n == 53 then
- jidlo = "x HC lemon"
- cenajidla = 5
- elseif n == 54 then
- jidlo = "x HC tea leaf"
- cenajidla = 5
- elseif n == 55 then
- jidlo = "x HC soybean"
- cenajidla = 5
- elseif n == 56 then
- jidlo = "x HC asparagus"
- cenajidla = 5
- elseif n == 57 then
- jidlo = "x HC garlic"
- cenajidla = 5
- elseif n == 58 then
- jidlo = "x HC rhubarb"
- cenajidla = 5
- elseif n == 59 then
- jidlo = "x HC grape"
- cenajidla = 5
- elseif n == 60 then
- jidlo = "x HC mustard"
- cenajidla = 5
- elseif n == 61 then
- jidlo = "x HC coconut"
- cenajidla = 5
- elseif n == 62 then
- jidlo = "x HC maple syrup"
- cenajidla = 20
- elseif n == 63 then
- jidlo = "x HC orange"
- cenajidla = 5
- elseif n == 64 then
- jidlo = "x HC chestnut"
- cenajidla = 5
- elseif n >= 65 and n<= 75 then
- jidlo = "x jidlo"
- cenajidla = 10
- elseif n >= 76 and n<= 152 then
- slot = slot - 1
- end
- end
- end
- function checkreq()
- while true do
- if fs.exists("currentoffer") then
- fileCO = fs.open("currentoffer", "r")
- local line = fileCO.readAll()
- fileCO.close()
- offertable = textutils.unserialize(line)
- pocet = offertable[1]
- jidlo = offertable[2]
- cena = offertable[3]
- print("---------------------------")
- print("Objednavka: ", pocet, jidlo)
- print("Vyplata: ", cena, " kreditu.")
- password()
- else
- local vacancy = 1
- while vacancy == 1 do
- rednet.open("top")
- offergen()
- vacancy = vacancy - 1
- vyplata()
- vacancy = vacancy + 1
- end
- end
- end
- end
- checkreq()
Add Comment
Please, Sign In to add comment