Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local slot = 0
- local myID = os.getComputerID()
- 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.")
- 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
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.open("top")
- 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 = slot - 1
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.open("top")
- rednet.broadcast(msg, "offer")
- fs.delete("currentoffer")
- sleep(3)
- else print("Heslo nerozpoznano")
- sleep(1)
- end
- end
- else
- local vacancy = 1
- while vacancy == 1 do
- rednet.open("top")
- while slot == 0 do
- slot = slot + 1
- n = math.random(1,18)
- pocet = math.random(1, 4)
- if n == 1 then
- slot = slot - 1
- elseif n == 2 then
- jidlo = "stack(s) of strings"
- cenajidla = 320
- elseif n == 3 then
- jidlo = "stack(s) of wool"
- cenajidla = 320
- elseif n == 4 then
- jidlo = "stack(s) of stone"
- cenajidla = 640
- elseif n == 5 then
- jidlo = "stack(s) of glass"
- cenajidla = 960
- elseif n == 6 then
- jidlo = "stack(s) of sandstone"
- cenajidla = 960
- elseif n == 7 then
- jidlo = "stack(s) of acacia wood planks"
- cenajidla = 320
- elseif n == 8 then
- jidlo = "stack(s) of birch wood planks"
- cenajidla = 320
- elseif n >= 9 and n<= 18 then
- slot = slot - 1
- end
- end
- vacancy = vacancy - 1
- cena = cenajidla * pocet
- local t = {}
- t[1] = pocet
- t[2] = jidlo
- t[3] = cena
- t[4] = myID
- t[5] = "F"
- t[6] = "Akka Constructions"
- local msg = textutils.serialize(t)
- rednet.open("top")
- rednet.broadcast(msg, "offer")
- local id, msg = rednet.receive(2)
- if msg == "full" then
- sleep(3)
- 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()
- 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
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.open("top")
- 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 = slot - 1
- hotovot = {}
- hotovot[4] = myID
- hotovot[5] = "F"
- local msg = textutils.serialize(hotovot)
- rednet.open("top")
- rednet.broadcast(msg, "offer")
- fs.delete("currentoffer")
- sleep(3)
- else print("Heslo nerozpoznano")
- sleep(1)
- end
- end
- end
- vacancy = vacancy + 1
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement