Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local myID = os.getComputerID()
- while true do -- 1
- znovu = 1
- slot = 0
- if fs.exists("currentoffer") then -- pokud jiz existuje ulozena objednavka, nacte se ze souboru currentoffer 2
- znovu = 0
- slot = 1
- 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.")
- passwordD = "david"
- passwordF = "filip"
- local heslonerozpoznano = true
- while heslonerozpoznano do -- overeni heslem 3
- write("Heslo: ")
- local input = read("*")
- if input == passwordD then -- overeni hesla pro Davida 4
- 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 = 0
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.broadcast(msg, "offer")
- fs.delete("currentoffer")
- sleep(3)
- elseif input == passwordF then -- overeni hesla pro Filipa
- 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 = 0
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.broadcast(msg, "offer")
- fs.delete("currentoffer")
- sleep(3)
- else print("Heslo nerozpoznano") -- pokud se neshoduje heslo
- sleep(1)
- end -- konec overeni inputu 4E
- end -- ukonceni while loopu pro overeni heslem 3E
- else -- generace nove poptavky pokud neexistuje poptavka 2C
- znovu = 1
- rednet.open("top")
- while znovu == 1 do -- generuj, dokud se neuvolni slot 4,5
- while slot == 0 do --generuj, dokud se to nepovede 5
- slot = 1
- sleep(180)
- n = math.random(1,194)
- pocet = math.random(32,65)
- if pocet == 65 then -- 6
- pocet = 128
- end -- 6E
- if n == 1 then -- 7
- slot = 0
- 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 = 5
- 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 = 20
- 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" -- 8
- 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 -- 8E
- 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 = 10
- elseif n == 63 then
- jidlo = "x HC orange"
- cenajidla = 5
- elseif n == 64 then
- jidlo = "x HC chestnut"
- cenajidla = 5
- elseif n == 65 then
- jidlo = "x HC cherry"
- cenajidla = 5
- elseif n == 66 then
- jidlo = "x HC banana"
- cenajidla = 5
- elseif n == 67 then
- jidlo = "x HC cashew"
- cenajidla = 5
- elseif n == 68 then
- jidlo = "x HC grapefruit"
- cenajidla = 5
- elseif n == 69 then
- jidlo = "x HC cinnamon"
- cenajidla = 10
- elseif n == 70 then
- jidlo = "x HC vanilla bean"
- cenajidla = 5
- elseif n == 71 then
- jidlo = "x HC fig"
- cenajidla = 5
- elseif n == 72 then
- jidlo = "x HC almond"
- cenajidla = 5
- elseif n == 73 then
- jidlo = "x HC pomegranate"
- cenajidla = 5
- elseif n == 74 then
- jidlo = "x HC pepper"
- cenajidla = 5
- elseif n == 75 then
- jidlo = "x HC broccoli"
- cenajidla = 5
- elseif n == 76 then
- jidlo = "x HC coffee"
- cenajidla = 5
- elseif n == 77 then
- jidlo = "x HC lime"
- cenajidla = 5
- elseif n == 78 then
- jidlo = "x HC date"
- cenajidla = 5
- elseif n == 79 then
- jidlo = "x HC ginger"
- cenajidla = 5
- elseif n == 80 then
- jidlo = "x HC zucchini"
- cenajidla = 5
- elseif n == 81 then
- jidlo = "x HC honey"
- cenajidla = 5
- elseif n == 82 then
- jidlo = "x PC wine grapes"
- cenajidla = 5
- elseif n == 83 then
- jidlo = "x eggs"
- cenajidla = 5
- elseif n >= 84 and n<= 96 then
- jidlo = "x jidlo"
- cenajidla = 10
- elseif n >= 97 and n <= 194 then
- slot = 0
- end -- konec rng jidla 7E
- end -- konec while loop pro generaci poptavky 5E
- cena = cenajidla * pocet
- local t = {}
- t[1] = pocet
- t[2] = jidlo
- t[3] = cena
- t[4] = myID
- t[5] = "F"
- t[6] = "David's Corner"
- local msg = textutils.serialize(t)
- rednet.open("top")
- rednet.broadcast(msg, "offer")
- local id, msg = rednet.receive(2)
- if msg == "full" then -- overi dostupnost slotu - pokud neni volny, opakuj gen 9
- sleep(3)
- znovu = 1
- else
- znovu = 0
- print("-----------------------------") -- pokud je volny slot, vypis poptavku
- 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()
- passwordD = "david"
- passwordF = "filip"
- local heslonerozpoznano = true
- while heslonerozpoznano do -- 10
- write("Heslo: ")
- local input = read("*")
- if input == passwordD then -- 11
- 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 = 0
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.broadcast(msg, "offer")
- fs.delete("currentoffer")
- sleep(3)
- 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 = 0
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.broadcast(msg, "offer")
- fs.delete("currentoffer")
- sleep(3)
- else print("Heslo nerozpoznano")
- sleep(1)
- end -- konec overeni hesla 11E
- end -- konec loopu pro heslo 10E
- end -- konec overeni dostupnosti slotu 9E
- end -- konec znovu loopu 4,5E
- znovu = 1
- end -- konec while loopu pro gen poptavky 2E
- end -- konec if statement pro overeni existence currentoffer 1E
Add Comment
Please, Sign In to add comment