Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function welcomescreen()
- term.clear()
- term.setCursorPos(1,1)
- print("-----------------------------") -- pokud je volny slot, vypis poptavku
- print("Objednavka: ", pocet, "x ", jidlo)
- print("Vyplata: ", cena," kreditu.")
- print("Pro splneni objednavky zadejte O, pro vareni jidla zadejte J")
- end
- function fcscreen()
- loop1 = true
- while loop1 == true do -- loop na cykleni vareni/zakazek 1.1.2.2.1.0.0
- welcomescreen()
- local prikaz = read()
- if prikaz == "J" then -- vareni jidla 1.1.2.2.1.1.0
- print("Kolik jste uvarili jidla?")
- local uvareno = tonumber(read())
- print("Pouzili jste nadobi? (y/n)")
- local nadobi = read()
- if nadobi == "y" then -- pouziti nadobi 1.1.2.2.1.1.1
- mod1 = 5
- else mod1 = 0
- end -- 1.1.2.2.1.1.1E
- print("Pouzili jste pri vareni pristroj? (y/n)")
- local pristroj = read()
- if pristroj == "y" then -- pouziti pristroje 1.1.2.2.1.1.2
- mod2 = 5
- else mod2 = 0
- end -- 1.1.2.2.1.1.2E
- print("Byl potreba pri vareni craftici mezikrok? (y/n)")
- local mezikrok = read()
- if mezikrok == "y" then -- pouziti mezikroku 1.1.2.2.1.1.3
- mod3 = 5
- else mod3 = 0
- end -- 1.1.2.2.1.1.3E
- mzda = uvareno * ( 5 + mod1 + mod2 + mod3)
- passwordD = "david"
- passwordF = "filip"
- local heslonerozpoznano = true
- while heslonerozpoznano do -- 1.1.2.2.1.1.4.0
- print("Pokud chcete stornovat prikaz, misto hesla zadejte STORNO")
- write("Heslo: ")
- local input = read("*")
- if input == passwordD then -- 1.1.2.2.1.1.4.1
- heslonerozpoznano = false
- print ("Mzda vyplacena. Na ucet David bylo pripsano " .. mzda .. " kreditu.")
- rednet.open("top")
- rednet.broadcast("poptavka", "ucel")
- rednet.broadcast("David","kdo")
- rednet.broadcast(mzda,"kolik")
- sleep(2,5)
- elseif input == passwordF then
- heslonerozpoznano = false
- print ("Mzda vyplacena. Na ucet Filip bylo pripsano " .. mzda .. " kreditu.")
- rednet.open("top")
- rednet.broadcast("poptavka", "ucel")
- rednet.broadcast("Filip","kdo")
- rednet.broadcast(mzda,"kolik")
- sleep(2,5)
- elseif input == "STORNO" then
- heslonerozpoznano = false
- print("Prikaz stornovan")
- sleep(1)
- else print("Heslo nerozpoznano")
- end -- konec overeni hesla 1.1.2.2.1.1.4.1E
- end -- 1.1.2.2.1.1.4.0E
- elseif prikaz == "O" then -- objednavka jidla 1.1.2.2.1.1.0 Cont
- passwordD = "david"
- passwordF = "filip"
- local heslonerozpoznano = true
- while heslonerozpoznano do -- 1.1.2.2.1.1.5.0
- print(myID)
- write("Heslo: ")
- local input = read("*")
- if input == passwordD then -- 1.1.2.2.1.1.5.1
- 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")
- loop1 = false
- 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")
- loop1 = false
- sleep(3)
- else print("Heslo nerozpoznano")
- sleep(1)
- end -- konec overeni hesla 1.1.2.2.1.1.5.1E
- end -- konec loopu pro heslo 1.1.2.2.1.1.5.0E
- end -- konec loopu pro vyber J/O 1.1.2.2.1.1.0E
- end -- konec while loopu pro cykleni mezi J/O 1.1.2.2.1.0.0E
- end
- --- ZACATEK PROGRAMU ---
- myID = os.getComputerID()
- while true do -- 1.0.0.0.0.0.0
- znovu = 1
- slot = 0
- if fs.exists("currentoffer") then -- pokud jiz existuje ulozena objednavka, nacte se ze souboru currentoffer 1.1.0.0.0.0.0
- 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]
- fcscreen()
- else -- generace nove poptavky pokud neexistuje poptavka 1.1.0.0.0.0Cont
- znovu = 1
- rednet.open("top")
- while znovu == 1 do -- generuj, dokud se neuvolni slot 1.1.2.0.0.0
- while slot == 0 do --generuj, dokud se to nepovede 1.1.2.1.0.0
- slot = 1
- sleep(180)
- n = math.random(1,200)
- pocet = math.random(32,65)
- if pocet == 65 then -- 1.1.2.1.1.0
- pocet = 128
- end -- 1.1.2.1.1E
- if n >= 1 and n <= 19 then -- VEGGIES
- local veggies = math.random(1,33)
- if veggies >= 1 and veggies <= 9 then -- veggies1
- cenajidla = 10
- local veggies1 = math.random(1,9)
- if veggies1 == 1 then jidlo = "PMP spinach"
- elseif veggies1 == 2 then jidlo = "PMP cucumber"
- elseif veggies1 == 3 then jidlo = "PMP bell pepper"
- elseif veggies1 == 4 then jidlo = "PMP lettuce"
- elseif veggies1 == 5 then jidlo = "PMP beet"
- elseif veggies1 == 6 then jidlo = "PMP tomato"
- elseif veggies1 == 7 then jidlo = "PMP onion"
- elseif veggies1 == 8 then jidlo = "carrot"
- elseif veggies1 == 9 then jidlo = "PMP celery"
- end
- elseif veggies >= 10 and veggies <= 13 then -- veggies2
- cenajidla = 15
- local veggies2 = math.random(1,4)
- if veggies2 == 1 then jidlo = "HC avocado"
- elseif veggies2 == 2 then jidlo = "cactus"
- elseif veggies2 == 3 then jidlo = "olive"
- elseif veggies2 == 4 then jidlo = "HC bamboo shoot"
- end
- elseif veggies >= 14 and veggies <= 33 then -- veggies3
- cenajidla = 5
- local veggies3 = math.random(1,20)
- if veggies3 == 1 then jidlo = "HC pea"
- elseif veggies3 == 2 then jidlo = "cactus"
- elseif veggies3 == 3 then jidlo = "HC olive"
- elseif veggies3 == 4 then jidlo = "HC soybean"
- elseif veggies3 == 5 then jidlo = "HC asparagus"
- elseif veggies3 == 6 then jidlo = "HC broccoli"
- elseif veggies3 == 7 then jidlo = "HC zucchini"
- elseif veggies3 == 8 then jidlo = "HC celery"
- elseif veggies3 == 9 then jidlo = "HC onion"
- elseif veggies3 == 10 then jidlo = "HC sea weed"
- elseif veggies3 == 11 then jidlo = "HC mushrooms"
- elseif veggies3 == 12 then jidlo = "HC eggplant"
- elseif veggies3 == 13 then jidlo = "HC leek"
- elseif veggies3 == 14 then jidlo = "HC bean"
- elseif veggies3 == 15 then jidlo = "HC tomato"
- elseif veggies3 == 16 then jidlo = "HC lettuce"
- elseif veggies3 == 17 then jidlo = "HC beet"
- elseif veggies3 == 18 then jidlo = "HC bellpepper"
- elseif veggies3 == 19 then jidlo = "HC cucumber"
- elseif veggies3 == 20 then jidlo = "HC spinach"
- end
- end
- elseif n >= 20 and n <= 36 then -- FRUITS
- local fruits = math.random(1,27)
- if fruits >= 1 and fruits <= 16 then
- cenajidla = 5
- local fruits1 = math.random(1,16) -- fruits1
- if fruits1 == 1 then jidlo = "watermelon"
- elseif fruits1 == 2 then jidlo = "PMP blueberry"
- elseif fruits1 == 3 then jidlo = "PMP strawberry"
- elseif fruits1 == 4 then jidlo = "PMP blackberry"
- elseif fruits1 == 5 then jidlo = "PMP whiteberry"
- elseif fruits1 == 6 then jidlo = "PMP gooseberry"
- elseif fruits1 == 7 then jidlo = "PMP beautyberry"
- elseif fruits1 == 8 then jidlo = "PMP orangeberry"
- elseif fruits1 == 9 then jidlo = "HC plum"
- elseif fruits1 == 10 then jidlo = "HC rhubarb"
- elseif fruits1 == 11 then jidlo = "HC grape"
- elseif fruits1 == 12 then jidlo = "HC cherry"
- elseif fruits1 == 13 then jidlo = "HC peach"
- elseif fruits1 == 14 then jidlo = "HC apricot"
- elseif fruits1 == 15 then jidlo = "HC blueberry"
- elseif fruits1 == 16 then jidlo = "HC blackberry"
- end
- elseif fruits >= 17 and fruits <= 27 then -- fruits2
- cenajidla = 15
- local fruits2 = math.random(1,11)
- if fruits2 == 1 then jidlo = "HC lemon"
- elseif fruits2 == 2 then jidlo = "HC coconut"
- elseif fruits2 == 3 then jidlo = "HC orange"
- elseif fruits2 == 4 then jidlo = "HC banana"
- elseif fruits2 == 5 then jidlo = "HC grapefruit"
- elseif fruits2 == 6 then jidlo = "HC fig"
- elseif fruits2 == 7 then jidlo = "HC pomegranate"
- elseif fruits2 == 8 then jidlo = "HC lime"
- elseif fruits2 == 9 then jidlo = "HC date"
- elseif fruits2 == 10 then jidlo = "HC cantaloupe"
- elseif fruits2 == 11 then jidlo = "HC mango"
- end
- end
- elseif n >= 37 and n <= 52 then -- CARBS
- local carbs = math.random(1,9)
- if carbs >= 1 and carbs <= 5 then -- carbs1
- cenajidla = 5
- local carbs1 = math.random(1,5)
- if carbs1 == 1 then jidlo = "PMP corn"
- elseif carbs1 == 2 then jidlo = "wheat"
- elseif carbs1 == 3 then jidlo = "potato"
- elseif carbs1 == 4 then jidlo = "HC barley"
- elseif carbs1 == 5 then jidlo = "HC rye"
- end
- elseif carbs >= 6 and n <= 9 then -- carbs2
- local carbs2 = math.random(1,4)
- if carbs2 == 1 then jidlo = "PMP wild rice"
- cenajidla = 30
- elseif carbs2 == 2 then jidlo = "HC rice"
- cenajidla = 15
- elseif carbs2 == 3 then jidlo = "PMP asian rice"
- cenajidla = 30
- elseif carbs2 == 4 then jidlo = "PMP corn"
- cenajidla = 10
- end
- end
- elseif n >= 53 and n <= 66 then -- PROTEIN
- local protein = math.random(1,8)
- if protein == 1 then jidlo = "raw mutton"
- cenajidla = 20
- elseif protein == 2 then jidlo = "raw beef"
- cenajidla = 15
- elseif protein == 3 then jidlo = "HC raw turkey"
- cenajidla = 50
- elseif protein == 4 then jidlo = "HC raw venison"
- cenajidla = 50
- elseif protein == 5 then jidlo = "HC raw rabbit"
- cenajidla = 50
- elseif protein == 6 then jidlo = "raw chicken"
- cenajidla = 10
- elseif protein == 7 then jidlo = "raw pork"
- cenajidla = 20
- elseif protein == 8 then jidlo = "eggs"
- cenajidla = 5
- end
- elseif n >= 67 and n <= 76 then -- SPICES
- local spices = math.random(1,13)
- if spices == 1 then jidlo = "sugar"
- cenajidla = 5
- elseif spices == 2 then jidlo = "HC chilli"
- cenajidla = 15
- elseif spices == 3 then jidlo = "HC garlic"
- cenajidla = 5
- elseif spices == 4 then jidlo = "HC mustard"
- cenajidla = 5
- elseif spices == 5 then jidlo = "HC maple syrup"
- cenajidla = 10
- elseif spices == 6 then jidlo = "HC cinnamon"
- cenajidla = 30
- elseif spices == 7 then jidlo = "HC vanilla bean"
- cenajidla = 15
- elseif spices == 8 then jidlo = "HC black pepper"
- cenajidla = 15
- elseif spices == 9 then jidlo = "HC ginger"
- cenajidla = 15
- elseif spices == 10 then jidlo = "HC honey"
- cenajidla = 10
- elseif spices == 11 then jidlo = "HC sesame"
- cenajidla = 15
- elseif spices == 12 then jidlo = "HC curry leaves"
- cenajidla = 15
- elseif spices == 13 then jidlo = "salt"
- cenajidla = 30
- end
- elseif n >= 77 and n<= 90 then -- FISH
- local fish = math.random(1,28)
- if fish >= 1 and fish <= 17 then -- fish1
- cenajidla = 25
- local fish1 = math.random(1, 17)
- if fish1 == 1 then jidlo = "ryba" -- 1.1.2.1.2.1
- elseif fish1 == 2 then jidlo = "HC raw bass"
- elseif fish1 == 3 then jidlo = "HC raw carp"
- elseif fish1 == 4 then jidlo = "HC raw catfish"
- elseif fish1 == 5 then jidlo = "HC raw grouper"
- elseif fish1 == 6 then jidlo = "HC raw herring"
- elseif fish1 == 7 then jidlo = "HC raw tilapia"
- elseif fish1 == 8 then jidlo = "HC raw tuna"
- elseif fish1 == 9 then jidlo = "HC raw walleye"
- elseif fish1 == 10 then jidlo = "HC raw green heart fish"
- elseif fish1 == 11 then jidlo = "HC raw charr"
- elseif fish1 == 12 then jidlo = "HC raw mudfish"
- elseif fish1 == 13 then jidlo = "HC raw trout"
- elseif fish1 == 14 then jidlo = "HC raw anchovy"
- elseif fish1 == 15 then jidlo = "HC raw perch"
- elseif fish1 == 16 then jidlo = "HC raw snapper"
- elseif fish1 == 17 then jidlo = "HC raw eel"
- end -- 1.1.2.1.2.1E
- elseif fish >= 18 and fish <= 28 then -- fish2
- cenajidla = 25
- local fish2 = math.random(18,28)
- if fish2 == 1 then jidlo = "HC raw crab"
- elseif fish2 == 2 then jidlo = "HC raw crayfish"
- elseif fish2 == 4 then jidlo = "HC raw frog"
- elseif fish2 == 5 then jidlo = "HC raw octopus"
- elseif fish2 == 6 then jidlo = "HC raw scallop"
- elseif fish2 == 7 then jidlo = "HC raw shrimp"
- elseif fish2 == 8 then jidlo = "HC raw snail"
- elseif fish2 == 9 then jidlo = "HC raw turtle"
- elseif fish2 == 10 then jidlo = "HC raw calamari"
- elseif fish2 == 11 then jidlo = "salmon"
- end
- end
- elseif n >= 91 and n <= 100 then -- DRY PRODUCTS
- local dries = math.random(1,11)
- if dries == 1 then jidlo = "PMP peanuts"
- cenajidla = 30
- elseif dries == 2 then jidlo = "HC tea leaf"
- cenajidla = 15
- elseif dries == 3 then jidlo = "HC chestnut"
- cenajidla = 5
- elseif dries == 4 then jidlo = "HC cashew"
- cenajidla = 15
- elseif dries == 5 then jidlo = "HC almond"
- cenajidla = 15
- elseif dries == 6 then jidlo = "HC coffee"
- cenajidla = 15
- elseif dries == 7 then jidlo = "HC pistachio"
- cenajidla = 15
- elseif dries == 8 then jidlo = "HC peanut"
- cenajidla = 15
- elseif dries == 9 then jidlo = "HC walnut"
- cenajidla = 5
- elseif dries == 10 then jidlo = "cocoa"
- cenajidla = 30
- elseif dries == 11 then jidlo = "HC pecan"
- cenajidla = 15
- end
- elseif n >= 101 and n <= 200 then
- slot = 0
- end -- konec rng jidla 1.1.2.1.2.0E
- end -- konec while loop pro generaci poptavky 1.1.2.1.0.0E
- cena = cenajidla * pocet
- local t = {}
- t[1] = pocet
- t[2] = jidlo
- t[3] = cena
- t[4] = myID
- t[5] = "F"
- t[6] = "Dave'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 1.1.2.2.0.0
- sleep(3)
- znovu = 1
- else
- znovu = 0
- 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()
- fcscreen()
- end -- konec overeni dostupnosti slotu 1.1.2.2.0.0E
- end -- konec znovu loopu 1.1.1.0.0.0.0E
- znovu = 1
- end -- konec while loopu pro gen poptavky 1.1.0.0.0.0.0E
- end -- konec if statement pro overeni existence currentoffer 1.0.0.0.0.0.0E
Add Comment
Please, Sign In to add comment