Sony_08

Sony's QuadShop Controller

Mar 9th, 2020
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.83 KB | None | 0 0
  1. @name Sony's QuadShop Controller
  2. @inputs [EGP]:wirelink [User]:entity RangerTL RangerTR RangerBL RangerBR
  3. @outputs ShipmentUserTL ShipmentUserTR ShipmentUserBL ShipmentUserBR
  4. @persist SelectedOption
  5. @trigger
  6.  
  7. # Sony's QuadShop Controller
  8. # Made by Sony - https://steamcommunity.com/id/Sony_08/
  9. # Feel free to drop me a message if you have any problems.
  10.  
  11.  
  12. # --== QuadShop Config: ==-- #
  13.  
  14. CurrencySymbol = "£"         # What currency symbol do we display?
  15.  
  16. GunNameTL = "Keypad Cracker" # What gun are we selling? (String)
  17. GunPriceTL = 250             # For what price?          (Number)
  18.  
  19. GunNameTR = "Lockpick"       # What gun are we selling? (String)
  20. GunPriceTR = 100             # For what price?          (Number)
  21.  
  22. GunNameBL = "Holoscanner"    # What gun are we selling? (String)
  23. GunPriceBL = 500             # For what price?          (Number)
  24.  
  25. GunNameBR = "Knife"          # What gun are we selling? (String)
  26. GunPriceBR = 100             # For what price?          (Number)
  27.  
  28.  
  29. # By default this uses some sounds from TF2 because they sound better IMO.
  30. # For those that don't want to use TF2 content, just change these vars to use HL2 sounds instead.
  31.  
  32. Sound_Purchase = "mvm/mvm_bought_upgrade.wav"   # What sound plays when someone buys something? (string)
  33. Sound_Failed = "mvm/mvm_money_vanish.wav"       # What sound plays when there is a problem.     (string)
  34.  
  35. # --== End of config, don't edit below here unless you know what you're doing. ==-- #
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. if(first() || dupefinished())
  45. {
  46.    function void prefixPrint(Text:string)
  47.    {
  48.        printColor(vec(100, 100, 255), format("\n[%s]", "QuadShop"), vec(180), " : ", Text)
  49.    }
  50.  
  51.    # Keep a track of which shipment they're trying to buy so we can trigger the right user later.
  52.     SelectedOption = 1
  53.    
  54.     function void wirelink:mainScreen()
  55.     {
  56.         ShipmentUserTL = 0
  57.         ShipmentUserTR = 0
  58.         ShipmentUserBL = 0
  59.         ShipmentUserBR = 0
  60.        
  61.         This:egpClear()
  62.        
  63.         This:egpText(1, "Press to buy", vec2(256, 40))
  64.         This:egpAlign(1, 1, 1)
  65.         This:egpSize(1, 90)
  66.        
  67.     # Top-Left shipment
  68.         if(GunNameTL != ""&&GunPriceTL != 0){
  69.             This:egpBox(2,vec2(5,130),vec2(10,10))
  70.             This:egpSize(2,vec2(1000,60))
  71.             This:egpColor(2, vec(25))
  72.            
  73.             This:egpText(3,GunNameTL + " : " + CurrencySymbol + toString(GunPriceTL),vec2(50,115))
  74.             This:egpSize(3,30)
  75.             This:egpColor(3,vec(240,240,240))
  76.         }
  77.  
  78.     # Top-Right shipment        
  79.         if(GunNameTR != ""&&GunPriceTR != 0){
  80.             This:egpBox(4,vec2(5,200),vec2(10,10))
  81.             This:egpSize(4,vec2(1000,60))
  82.             This:egpColor(4, vec(25))
  83.            
  84.             This:egpText(5,GunNameTR + " : " + CurrencySymbol + toString(GunPriceTR),vec2(50,185))
  85.             This:egpSize(5,30)
  86.             This:egpColor(5,vec(240,240,240))
  87.         }
  88.  
  89.     # Bottom-Left shipment
  90.         if(GunNameBL != ""&&GunPriceBL != 0){
  91.             This:egpBox(6,vec2(5,270),vec2(10,10))
  92.             This:egpSize(6,vec2(1000,60))
  93.             This:egpColor(6, vec(25))
  94.            
  95.             This:egpText(7,GunNameBL + " : " + CurrencySymbol + toString(GunPriceBL),vec2(50,255))
  96.             This:egpSize(7,30)
  97.             This:egpColor(7,vec(240,240,240))
  98.         }
  99.  
  100.     # Bottom-Right shipment
  101.         if(GunNameBR != ""&&GunPriceBR != 0){
  102.             This:egpBox(8,vec2(5,340),vec2(10,10))
  103.             This:egpSize(8,vec2(1000,60))
  104.             This:egpColor(8, vec(25))
  105.            
  106.             This:egpText(9,GunNameBR + " : " + CurrencySymbol + toString(GunPriceBR),vec2(50,325))
  107.             This:egpSize(9,30)
  108.             This:egpColor(9,vec(240,240,240))
  109.         }
  110.  
  111.     # Let people know how to use the shop.
  112.         This:egpText(10, "Press E on an option to buy!", vec2(256, 420))
  113.         This:egpAlign(10, 1, 1)
  114.         This:egpSize(10, 25)  
  115.  
  116.     # Let people know who owns this shop.
  117.         This:egpText(11, "Shop owned and operated by "+owner():name(), vec2(256, 460))
  118.         This:egpAlign(11, 1, 1)
  119.         This:egpSize(11, 20)
  120.  
  121.     # Credit that will surely never be removed by who ever downloads this.
  122.         This:egpText(12, "Shop Dupe and E2 Controller Made by Sony", vec2(256, 480))
  123.         This:egpAlign(12, 1, 1)
  124.         This:egpSize(12, 20)
  125.        
  126.     # Tiny Reboot Button at the bottom for convenience.
  127.         This:egpBox(13,vec2(256,500),vec2(10,10))
  128.         This:egpSize(13,vec2(50,20))
  129.         This:egpColor(13, vec(0))
  130.        
  131.         This:egpText(14, "Reboot", vec2(256, 500))
  132.         This:egpAlign(14, 1, 1)
  133.         This:egpSize(14, 10)
  134.         This:egpColor(14,vec(50,50,50))
  135.        
  136.  
  137.     # Mark entries as out of stock if the ranger can't find a shipment in that spot.
  138.    
  139.        if (RangerTL == 0)
  140.        {
  141.            This:egpColor(2, vec(255,50,50))
  142.            This:egpSetText(3,"Out of stock!")
  143.        }
  144.        if (RangerTR == 0)
  145.        {
  146.            This:egpColor(4, vec(255,50,50))
  147.            This:egpSetText(5,"Out of stock!")
  148.        }
  149.        if (RangerBL == 0)
  150.        {
  151.            This:egpColor(6, vec(255,50,50))
  152.            This:egpSetText(7,"Out of stock!")
  153.        }
  154.        if (RangerBR == 0)
  155.        {
  156.            This:egpColor(8, vec(255,50,50))
  157.            This:egpSetText(9,"Out of stock!")
  158.        }
  159.  
  160.    }
  161.    
  162.    # What shows on the screen when somone purchases our contents:
  163.    function void wirelink:purchasedScreen()
  164.    {
  165.        EGP:entity():soundPlay(1, 1, Sound_Purchase)
  166.        This:egpClear()
  167.        
  168.        This:egpCircle(2, vec2(256), vec2(196))
  169.        This:egpColor(2, vec(35))
  170.        
  171.        This:egpText(3, "Thanks!", vec2(256, 190))
  172.        This:egpAlign(3, 1, 1)
  173.        This:egpSize(3, 100)
  174.        
  175.        This:egpText(4, ":)", vec2(256, 276))
  176.        This:egpAlign(4, 1, 1)
  177.        This:egpSize(4, 80)
  178.        
  179.        This:egpText(5, "Enjoy!", vec2(256, 340))
  180.        This:egpAlign(5, 1, 1)
  181.        This:egpSize(5, 50)
  182.        
  183.        This:egpColor(3, vec(0, 255, 0))
  184.        
  185.        # Activate the corresponding user to dispense the item from the shipment.
  186.        if (SelectedOption == 1)
  187.        {
  188.           ShipmentUserTL = 1
  189.        }
  190.        elseif (SelectedOption == 2)
  191.        {
  192.           ShipmentUserTR = 1
  193.        }
  194.        elseif (SelectedOption == 3)
  195.        {
  196.           ShipmentUserBL = 1
  197.        }
  198.        elseif (SelectedOption == 4)
  199.        {
  200.           ShipmentUserBR = 1
  201.        }
  202.        else
  203.        {
  204.           print("Something went wrong!")
  205.        }
  206.        
  207.        timer("Reset", 3000)
  208.    }
  209.    
  210.    # What shows on the screen when somone tries to buy, but can't:
  211.     function void wirelink:failedScreen()
  212.     {
  213.         EGP:entity():soundPlay(1, 1, Sound_Failed)
  214.         This:egpClear()
  215.        
  216.         This:egpCircle(2, vec2(256), vec2(196))
  217.         This:egpColor(2, vec(35))
  218.        
  219.         This:egpText(3, "Failed.", vec2(256, 190))
  220.         This:egpAlign(3, 1, 1)
  221.         This:egpSize(3, 100)
  222.        
  223.         This:egpText(4, ":(", vec2(256, 276))
  224.         This:egpAlign(4, 1, 1)
  225.         This:egpSize(4, 80)
  226.        
  227.         This:egpText(5, "Not enough?", vec2(256, 340))
  228.         This:egpAlign(5, 1, 1)
  229.         This:egpSize(5, 50)
  230.         This:egpColor(3, vec(255, 0, 0))
  231.        
  232.         timer("Reset", 3000)
  233.     }
  234.    
  235.     EGP:mainScreen()
  236. }
  237.  
  238. Cursor = EGP:egpCursor(User) #Defines Cursor
  239.  
  240. function number button(Num){
  241.     return inrange(Cursor,EGP:egpPos(Num),EGP:egpPos(Num) + EGP:egpSize(Num)) #Function for buttons.
  242. }
  243.  
  244. interval(50)
  245.  
  246. # When the user selects a button by hovering over it and pressing E.
  247. if(button(2) && clk() || button(3) && clk()){
  248.     if (RangerTL != 0) {
  249.         moneyRequest(User,GunPriceTL,"Purchase 1x "+GunNameTL+" from shop:")
  250.         SelectedOption = 1
  251.     }
  252. }
  253. if(button(4) && clk() || button(5) && clk()){
  254.     if (RangerTR != 0) {
  255.         moneyRequest(User,GunPriceTR,"Purchase 1x "+GunNameTR+" from shop:")
  256.         SelectedOption = 2
  257.     }
  258. }
  259. if(button(6) && clk() || button(7) && clk()){
  260.     if (RangerBL != 0) {
  261.         moneyRequest(User,GunPriceBL,"Purchase 1x "+GunNameBL+" from shop:")
  262.         SelectedOption = 3
  263.     }  
  264. }
  265. if(button(8) && clk() || button(9) && clk()){
  266.     if (RangerBR != 0) {
  267.         moneyRequest(User,GunPriceBR,"Purchase 1x "+GunNameBR+" from shop:")
  268.         SelectedOption = 4
  269.     }  
  270. }
  271.  
  272.  
  273. # Tiny reboot button at the bottom of the screen to quickly reboot the E2 without opening up the shop.
  274. if(button(13) && clk() || button(14) && clk()){
  275.     prefixPrint("Rebooting in 1 second!")
  276.     timer("Reset", 1000)
  277. }
  278.  
  279.  
  280. # Purchase success!
  281. if(moneyClk()){
  282.     EGP:purchasedScreen()
  283. }
  284.  
  285. # Purchase failed, they clicked no or it timed out.
  286. if(moneyNoClk() | moneyTimeout()){
  287.     EGP:failedScreen()
  288. }
  289.  
  290. if(clk("Reset"))
  291. {
  292.     reset()
  293. }
Advertisement
Add Comment
Please, Sign In to add comment