Advertisement
MCFunRide

Untitled

Aug 10th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. oldPullEvent = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3. --[[
  4.     FusionCoins Wallet
  5.     Coded by fun_ride
  6.     Backend coded by Luca_S
  7. ]]--
  8.  
  9.  
  10. function drawFusion(x,y)
  11.   paintutils.drawPixel(x,y,colors.red)
  12.   paintutils.drawPixel(x + 1,y,colors.orange)
  13.   paintutils.drawPixel(x,y + 1,colors.orange)
  14.   paintutils.drawPixel(x + 1, y + 1,colors.red)
  15.   term.setCursorPos(x,y)
  16.   term.setBackgroundColor(colors.red)
  17.   write("/")
  18.   term.setCursorPos(x + 1,y)
  19.   term.setBackgroundColor(colors.orange)
  20.   write("\\")
  21.   term.setCursorPos(x,y + 1)
  22.   write("\\")
  23.   term.setCursorPos(x + 1,y + 1)
  24.   term.setBackgroundColor(colors.red)
  25.   write("/")
  26. end
  27.  
  28. os.loadAPI("/fusion/graphix")
  29.  
  30. graphix.bgColor(colors.white)
  31. drawFusion(3,3)
  32. term.setCursorPos(7,5)
  33. term.setTextColor(colors.red)
  34. term.setBackgroundColor(colors.white)
  35. write("Username: ")
  36. local username = read()
  37. term.setCursorPos(7,6)
  38. write("Password: ")
  39. os.loadAPI("/fusion/sha256")
  40. local pass = sha256.sha256(read('*'))
  41. os.loadAPI("/fusion/api")
  42. os.loadAPI("/fusion/sha256")
  43. graphix.bgColor(colors.white)
  44. term.setBackgroundColor(colors.gray)
  45. term.setCursorPos(1,2)
  46. term.clearLine()
  47. if api.login(username,pass) then
  48.   term.setTextColor(colors.lime)
  49.   graphix.center(2,"Logged in.")
  50. else
  51.   createUser = api.create(username,pass)
  52.   if createUser == true then
  53.     term.setTextColor(colors.lime)
  54.     graphix.center(2,"Created user.")
  55.   else
  56.     term.setTextColor(colors.red)
  57.     graphix.center(2,"Username Taken / Wrong Password")
  58.     sleep(2)
  59.     graphix.bgColor(colors.black)
  60.     return
  61.   end
  62. end
  63. sleep(5)
  64. term.setBackgroundColor(colors.white)
  65. graphix.totalClear()
  66. function drawMenu()
  67.   graphix.bgColor(colors.white)
  68.   term.setTextColor(colors.black)
  69.   graphix.center(1,"Username: "..username)
  70.   graphix.center(2,"Balance: "..api.getBalance(username))
  71.   term.setBackgroundColor(colors.orange)
  72.   term.setTextColor(colors.red)
  73.   term.setCursorPos(3,5)
  74.   print("Transaction")
  75.   term.setCursorPos(3,7)
  76.   print("Delete")
  77.   term.setCursorPos(3,9)
  78.   print("Exit")
  79.   term.setCursorPos(1,18)
  80.   local stream1 = http.get("http://www.fusionpoints.site50.net/announce.php")
  81.   local stream = stream1.readAll():gsub("<!-- Hosting24 Analytics Code -->
  82. <script type="text/javascript" src="http://stats/hosting24.com/count.php"></script>
  83. <!-- End Of Analytics Code -->","")
  84.   if stream == "No MSG" then
  85.     -- Do nothing
  86.     stream.close()
  87.   else
  88.     print("Service Announcement: "..stream.readAll())
  89.     stream.close()
  90.   end
  91. end
  92.  
  93. drawMenu()
  94.  
  95. --sleep(10)
  96. while true do
  97.   drawMenu()
  98.   e, b, x, y = os.pullEvent("mouse_click")
  99.   if x > 3 and x < 14 and y == 5 then
  100.     graphix.bgColor(colors.white)
  101.     drawFusion(1,1)
  102.     term.setCursorPos(3,3)
  103.     term.setTextColor(colors.orange)
  104.     term.setBackgroundColor(colors.white)
  105.     write("Send to: ")
  106.     local toUser = read()
  107.     term.setCursorPos(3,4)
  108.     write("Amount: ")
  109.     local userAmt = tonumber(read())
  110.     if userAmt == nil then
  111.       term.setTextColor(colors.red)
  112.       graphix.center(6,"Amount not a number.")
  113.     else
  114.       trans = api.transaction(username,pass,toUser,userAmt)
  115.       if trans == "User doesn't exists!" then
  116.         term.setTextColor(colors.red)
  117.         graphix.center(7,"User doesn't exist!")
  118.         sleep(1.5)
  119.       elseif trans == "Not enough CST" then
  120.         term.setTextColor(colors.red)
  121.         graphix.center(7,"Insufficent Funds!")
  122.         sleep(1.5)
  123.       elseif trans == "Negative amount" then
  124.         term.setTextColor(colors.red)
  125.         graphix.center(7,"Negative funds!")
  126.         sleep(1.5)
  127.       elseif toUser == username then
  128.         term.setTextColor(colors.red)
  129.         graphix.center(7,"Cannot give money to yourself!")
  130.         sleep(1.5)
  131.       else
  132.         term.setTextColor(colors.green)
  133.         graphix.center(7,"Transfer Successful!")
  134.         sleep(1.5)
  135.       end
  136.     end
  137.     if x > 3 and x < 10 and y == 9 then
  138.       term.clear()
  139.       term.setCursorPos(1,1)
  140.       term.setTextColor(colors.white)
  141.       return
  142.     end
  143.     if x > 3 and x < 9 and y == 7 then
  144.       graphix.bgColor(colors.white)
  145.       term.setTextColor(colors.white)
  146.       drawFusion(1,1)
  147.       term.setTextColor(colors.red)
  148.       graphix.center(1,"Account deletion")
  149.       term.setCursorPos(3,5)
  150.       print("Are you sure you want to delete account "..username.."?")
  151.       term.setCursorPos(3,6)
  152.       print("Press 1 to delete account.")
  153.       term.setCursorPos(3,7)
  154.       print("Press 2 to go back.")
  155.       local e = {os.pullEvent("key")}
  156.       if e == "key" and key == 1 then
  157.         graphix.bgColor(colors.white)
  158.         term.setTextColor(colors.red)
  159.         graphix.center(1,"Confirm account login.")
  160.         term.setCursorPos(3,3)
  161.         write("Username: ")
  162.         local delUser = read()
  163.         term.setCursorPos(3,4)
  164.         write("Password: ")
  165.         local delPassword = sha256.sha256(read('*'))
  166.        
  167.         if not username == delUser then
  168.           term.clear()
  169.           term.setCursorPos(1,1)
  170.           print("Account not deleted.")
  171.           print("Reason: Wrong Username / Password.")
  172.           return
  173.         end
  174.         local log = api.delete(delUser,delPassword)
  175.         if log then
  176.           term.setBackgroundColor(colors.black)
  177.           term.setTextColor(colors.white)
  178.           term.clear()
  179.           term.setCursorPos(1,1)
  180.           print("Thanks for being a member of FusionCoins!")
  181.           return
  182.         end
  183.         if not log then
  184.           term.setBackgroundColor(colors.black)
  185.           term.setTextColor(colors.white)
  186.           term.clear()
  187.           term.setCursorPos(1,1)
  188.           print("Account not deleted.")
  189.           print("Reason: Wrong Username / Password")
  190.           return
  191.         end
  192.       end
  193.      end
  194.   end
  195. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement