Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ModemPos = "top"
- MyID = os.getComputerID()
- modem = peripheral.wrap(ModemPos)
- modem.open(MyID)
- function bar(styl, text)
- if (styl == "OK") then -- Uspech
- term.setTextColor(colors.green)
- elseif (styl == "FAIL") then -- Neuspesne
- term.setTextColor(colors.red)
- elseif (styl == "INFO") then -- Informativni
- term.setTextColor(colors.lightBlue)
- elseif (styl == "def") then -- defaultni
- term.setTextColor(colors.white)
- elseif (styl == "PRO") then -- Progress
- term.setTextColor(colors.yellow)
- else
- styl = "def"
- term.setTextColor(colors.white)
- end
- if not (styl == "def") then
- zprava = ("["..textutils.formatTime(os.time(), true).."] ["..styl.."] "..text)
- else
- zprava = text
- end
- if logs then
- logy(zprava)
- end
- print (zprava)
- end
- function loop()
- local function defaultHod()
- idComp = nil
- hodnota = nil
- bar("INFO", "Pripraveno pro novy zapis")
- end
- local _, side, freq, rfreq, message = os.pullEvent('modem_message')
- if (rfreq == 8080) then
- idComp = message --login to domain
- bar("INFO", "Prijem informaci ze zarizeni "..idComp)
- end
- if (rfreq == 8081) then
- hodnota = message
- bar("PRO", "Nová hodnota: "..hodnota)
- if tonumber(idComp) > 0 then
- local zapis = fs.open("/database/"..idComp..".txt", "w")
- zapis.writeLine(hodnota)
- bar("OK", "Prepsano")
- zapis.close()
- defaultHod()
- end
- end
- loop()
- end
- bar("INFO", "Pripraveno k pouziti")
- loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement