Advertisement
johnnic431

fevConomy

Sep 24th, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. canRun=false
  2. local modem=peripheral.find("modem")
  3. if modem~=nil and modem.isWireless() then
  4.     canRun=true
  5.     modem.open(662)
  6. else
  7.     print("No wireledd modem")
  8.     return;
  9. end
  10. people={["THEMAULER431"]=0,["Iban1223"]=0,["milianlou"]=0}
  11. pNames={"THEMAULER431","Iban1223","milianlou"}
  12. pins={["THEMAULER431"]=5280,["Iban1223"]=3221,["milianlou"]=0107}
  13. r=fs.open("moneys","r")
  14. line=r.readLine()
  15. m=1
  16. for m=1,#people do
  17.     people[pNames[m]]=tonumber(line)
  18. end
  19. r.close()
  20.  
  21. while canRun do
  22.     e={os.pullEvent()}
  23.     if e[1]=="key" and e[2]==keys.q then
  24.         r=fs.open("moneys","w")
  25.         for t,y in pairs(people) do
  26.             r.writeLine(y)
  27.         end
  28.         r.close()
  29.         return
  30.     elseif e[1]=="modem_message" then
  31.         msg=textutils.unserialize(e[5])
  32.         if msg.pin==pins[msg.from] and tonumber(e[5]) and (people[msg.from]-tonumber(msg.amount))>=0 then
  33.             people[msg.from]=people[msg.from]-tonumber(msg.amount)
  34.             people[msg.to]=people[mmsg.to]+tonumber(msg.amount)
  35.             modem.transmit(8816,1,"GOOD_PURCHASE")
  36.         else
  37.             modem.transmit(8816,1,"BAD_PURCHASE")
  38.         end
  39.     end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement