Advertisement
Vladimir_Pruskalyow

ShopServer.lua

Mar 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1.  
  2. local component = require("component")
  3. local event = require("event")
  4. local modem = component.modem
  5. local debug = component.debug
  6. local port = 222
  7.  
  8. modem.open(port)
  9.  
  10. local items = {
  11.     ["1"] = 16,
  12.     ["2"] = 32,
  13.     ["3"] = 64,
  14. }
  15.  
  16. while true do
  17.     local e = { event.pull()}
  18.  
  19.     if e[1] == "modem_message" then
  20.         if e[6] == "STerm->SServer" then
  21.             if e[7] == "How" then
  22.                 modem.broadcast(port, "SServer->STerm", "Price", items[e[8]])
  23.             end
  24.  
  25.             if e[7] == "Buying" then
  26.                 modem.broadcast(port, "SServer->SRobot", "DOIT", items[e[8]])
  27.             end
  28.         end
  29.  
  30.         if e[6] == "SRobot->SServer" then
  31.             if e[7] == "Taken" then
  32.                 print("Достаток ресурсов: ", e[8])
  33.                 modem.broadcast(port, "SServer->STerm", "Sucsesful")
  34.             end
  35.         end
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement