Advertisement
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 <= 18 then -- VEGGIES
- local veggies = math.random(1,33)
- if veggies >= 1 and veggies <= 8 then -- veggies2
- cenajidla = 15
- local veggies2 = math.random(1,8)
- if veggies2 == 1 then jidlo = "avocado"
- cenajidla = 15
- elseif veggies2 == 2 then jidlo = "cactus"
- cenajidla = 15
- elseif veggies2 == 3 then jidlo = "olive"
- cenajidla = 15
- elseif veggies2 == 4 then jidlo = "bamboo shoot"
- cenajidla = 15
- elseif veggies2 == 5 then jidlo = "carrot"
- cenajidla = 10
- elseif veggies2 == 6 then jidlo = "sweet potato"
- cenajidla = 15
- elseif veggies2 == 7 then jidlo = "artichoke"
- cenajidla = 15
- elseif veggies2 == 8 then jidlo = "pumpkin"
- cenajidla = 15
- end
- elseif veggies >= 9 and veggies <= 33 then -- veggies3
- cenajidla = 5
- local veggies3 = math.random(1,24)
- if veggies3 == 1 then jidlo = "pea"
- elseif veggies3 == 2 then jidlo = "brussel sprout"
- elseif veggies3 == 3 then jidlo = "soybean"
- elseif veggies3 == 4 then jidlo = "asparagus"
- elseif veggies3 == 5 then jidlo = "broccoli"
- elseif veggies3 == 6 then jidlo = "zucchini"
- elseif veggies3 == 7 then jidlo = "celery"
- elseif veggies3 == 8 then jidlo = "onion"
- elseif veggies3 == 9 then jidlo = "sea weed"
- elseif veggies3 == 10 then jidlo = "mushrooms"
- elseif veggies3 == 11 then jidlo = "eggplant"
- elseif veggies3 == 12 then jidlo = "leek"
- elseif veggies3 == 13 then jidlo = "bean"
- elseif veggies3 == 14 then jidlo = "tomato"
- elseif veggies3 == 15 then jidlo = "lettuce"
- elseif veggies3 == 16 then jidlo = "beet"
- elseif veggies3 == 17 then jidlo = "bellpepper"
- elseif veggies3 == 18 then jidlo = "cucumber"
- elseif veggies3 == 19 then jidlo = "spinach"
- elseif veggies3 == 20 then jidlo = "cabbage"
- elseif veggies3 == 21 then jidlo = "scallion"
- elseif veggies3 == 22 then jidlo = "parsnip"
- elseif veggies3 == 23 then jidlo = "cauliflower"
- elseif veggies3 == 24 then jidlo = "radish"
- end
- end
- elseif n >= 19 and n <= 34 then -- FRUITS
- local fruits = math.random(1,26)
- if fruits >= 1 and fruits <= 12 then
- cenajidla = 5
- local fruits1 = math.random(1,12) -- fruits1
- if fruits1 == 1 then jidlo = "watermelon"
- elseif fruits1 == 2 then jidlo = "plum"
- elseif fruits1 == 3 then jidlo = "rhubarb"
- elseif fruits1 == 4 then jidlo = "grape"
- elseif fruits1 == 5 then jidlo = "cherry"
- elseif fruits1 == 6 then jidlo = "peach"
- elseif fruits1 == 7 then jidlo = "apricot"
- elseif fruits1 == 8 then jidlo = "blueberry"
- elseif fruits1 == 9 then jidlo = "blackberry"
- elseif fruits1 == 10 then jidlo = "strawberry"
- elseif fruits1 == 11 then jidlo = "apple"
- elseif fruits1 == 12 then jidlo = "gooseberry"
- end
- elseif fruits >= 13 and fruits <= 26 then -- fruits2
- cenajidla = 15
- local fruits2 = math.random(1,14)
- if fruits2 == 1 then jidlo = "lemon"
- elseif fruits2 == 2 then jidlo = "coconut"
- elseif fruits2 == 3 then jidlo = "orange"
- elseif fruits2 == 4 then jidlo = "banana"
- elseif fruits2 == 5 then jidlo = "grapefruit"
- elseif fruits2 == 6 then jidlo = "fig"
- elseif fruits2 == 7 then jidlo = "pomegranate"
- elseif fruits2 == 8 then jidlo = "lime"
- elseif fruits2 == 9 then jidlo = "date"
- elseif fruits2 == 10 then jidlo = "cantaloupe"
- elseif fruits2 == 11 then jidlo = "mango"
- elseif fruits2 == 12 then jidlo = "pineapple"
- elseif fruits2 == 13 then jidlo = "dragonfruit"
- elseif fruits2 == 14 then jidlo = "papaya"
- end
- end
- elseif n >= 35 and n <= 54 then -- CARBS
- local carbs = math.random(1,7)
- if carbs == 1 then jidlo = "corn"
- cenajidla = 5
- elseif carbs == 2 then jidlo = "wheat"
- cenajidla = 5
- elseif carbs == 3 then jidlo = "potato"
- cenajidla = 5
- elseif carbs == 4 then jidlo = "barley"
- cenajidla = 5
- elseif carbs == 5 then jidlo = "rye"
- cenajidla = 5
- elseif carbs == 6 then jidlo = "rice"
- cenajidla = 15
- elseif carbs == 7 then jidlo = "oats"
- cenajidla = 5
- end
- elseif n >= 55 and n <= 68 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 = "raw turkey"
- cenajidla = 50
- elseif protein == 4 then jidlo = "raw venison"
- cenajidla = 50
- elseif protein == 5 then jidlo = "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 >= 69 and n <= 78 then -- SPICES
- local spices = math.random(1,14)
- if spices == 1 then jidlo = "sugar"
- cenajidla = 5
- elseif spices == 2 then jidlo = "chilli"
- cenajidla = 15
- elseif spices == 3 then jidlo = "garlic"
- cenajidla = 5
- elseif spices == 4 then jidlo = "mustard"
- cenajidla = 5
- elseif spices == 5 then jidlo = "maple syrup"
- cenajidla = 10
- elseif spices == 6 then jidlo = "cinnamon"
- cenajidla = 30
- elseif spices == 7 then jidlo = "vanilla bean"
- cenajidla = 15
- elseif spices == 8 then jidlo = "black pepper"
- cenajidla = 15
- elseif spices == 9 then jidlo = "ginger"
- cenajidla = 15
- elseif spices == 10 then jidlo = "honey"
- cenajidla = 10
- elseif spices == 11 then jidlo = "sesame"
- cenajidla = 15
- elseif spices == 12 then jidlo = "curry leaves"
- cenajidla = 15
- elseif spices == 13 then jidlo = "salt"
- cenajidla = 30
- elseif spices == 14 then jidlo = "spice leaf"
- cenajidla = 15
- end
- elseif n >= 79 and n <= 90 then -- FISH
- local fish = math.random(1,27)
- if fish >= 1 and fish <= 17 then -- fish1
- cenajidla = 25
- local fish1 = math.random(1, 17)
- if fish1 == 1 then jidlo = "raw fish" -- 1.1.2.1.2.1
- elseif fish1 == 2 then jidlo = "raw bass"
- elseif fish1 == 3 then jidlo = "raw carp"
- elseif fish1 == 4 then jidlo = "raw catfish"
- elseif fish1 == 5 then jidlo = "raw grouper"
- elseif fish1 == 6 then jidlo = "raw herring"
- elseif fish1 == 7 then jidlo = "raw tilapia"
- elseif fish1 == 8 then jidlo = "raw tuna"
- elseif fish1 == 9 then jidlo = "raw walleye"
- elseif fish1 == 10 then jidlo = "raw green heart fish"
- elseif fish1 == 11 then jidlo = "raw charr"
- elseif fish1 == 12 then jidlo = "raw mudfish"
- elseif fish1 == 13 then jidlo = "raw trout"
- elseif fish1 == 14 then jidlo = "raw anchovy"
- elseif fish1 == 15 then jidlo = "raw perch"
- elseif fish1 == 16 then jidlo = "raw snapper"
- elseif fish1 == 17 then jidlo = "raw eel"
- end -- 1.1.2.1.2.1E
- elseif fish >= 18 and fish <= 27 then -- fish2
- cenajidla = 25
- local fish2 = math.random(18,27)
- if fish2 == 1 then jidlo = "raw crab"
- elseif fish2 == 2 then jidlo = "raw crayfish"
- elseif fish2 == 3 then jidlo = "raw frog"
- elseif fish2 == 4 then jidlo = "raw octopus"
- elseif fish2 == 5 then jidlo = "raw scallop"
- elseif fish2 == 6 then jidlo = "raw shrimp"
- elseif fish2 == 7 then jidlo = "raw snail"
- elseif fish2 == 8 then jidlo = "raw turtle"
- elseif fish2 == 9 then jidlo = "raw calamari"
- elseif fish2 == 10 then jidlo = "raw salmon"
- end
- end
- elseif n >= 91 and n <= 100 then -- DRY PRODUCTS
- local dries = math.random(1,11)
- if dries == 1 then jidlo = "pecan"
- cenajidla = 30
- elseif dries == 2 then jidlo = "tea leaf"
- cenajidla = 15
- elseif dries == 3 then jidlo = "chestnut"
- cenajidla = 5
- elseif dries == 4 then jidlo = "cashew"
- cenajidla = 15
- elseif dries == 5 then jidlo = "almond"
- cenajidla = 15
- elseif dries == 6 then jidlo = "coffee"
- cenajidla = 15
- elseif dries == 7 then jidlo = "pistachio"
- cenajidla = 15
- elseif dries == 8 then jidlo = "peanut"
- cenajidla = 15
- elseif dries == 9 then jidlo = "walnut"
- cenajidla = 5
- elseif dries == 10 then jidlo = "cocoa"
- cenajidla = 30
- elseif dries == 11 then jidlo = "water chestnut"
- 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] = "Glucksgefuhlsausloser"
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement