Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.wrap("right")
- local backupModem = peripheral.wrap("bottom")
- backupModem.open(69)
- modem.open(420)
- local db = {}
- while true do
- local _, side, freq, rfreq, name = os.pullEvent('modem_message')
- if side == "bottom" then
- if type(name) == "table" then
- db = name
- print("Backup received.")
- elseif name == "askForDB" then
- backupModem.transmit(69, 69, db)
- print("Sent database to backup.")
- end
- elseif side == "right" then
- if db[name] then
- modem.transmit(420, 420, {"Found", db[name]["bal"]})
- print("Account already existed.")
- else
- db[name] = {}
- db[name]["bal"] = 0
- modem.transmit(420, 420, {"Not Found", db[name]["bal"]})
- backupModem.transmit(69, 69, db)
- print("Created new account with name "..name)
- end
- end
- end
- modem.close()
- backupModem.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement