mazenh

One Sign Shop

Aug 25th, 2020 (edited)
1,169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.53 KB | None | 0 0
  1. --------------------------------intro--------------------------------
  2. --                   One Sign Shop (ATM and Store)                 --
  3. --                                                                 --
  4. --   Created: 25/8/2020                       Author: SuB_Zoid     --
  5. --                                                                 --
  6. --                      For Ultimate Reloaded                      --
  7. ---------------------------------------------------------------------
  8.  
  9.  
  10. ---------------------------------------------------------------------
  11. -- V v V v V v V v V v V v V  Variables  V v V v V v V v V v V v V --
  12. ---------------------------------------------------------------------
  13. mATM=peripheral.wrap("monitor_7")                             ------(vp1)
  14. mStore=peripheral.wrap("monitor_6")                           ------(vp2)
  15. psa=peripheral.wrap("playerSensor_8")                         ------(vp3)
  16. psb=peripheral.wrap("playerSensor_11")                         ------(vp4)
  17. psc=peripheral.wrap("playerSensor_3")                         ------(vp3)
  18. psd=peripheral.wrap("playerSensor_9")                         ------(vp4)
  19. me=peripheral.wrap("meBridge_0")
  20.  
  21.  
  22. store={}  --store items Databasetable                          ------(v1)
  23. local T ={} --player DatabaseTable                            ------(v2)
  24. local bgc= colors.black  --background color        --*Temp val*------(v3)
  25. local ri=0 --rs current state                      --*func val*------(v4)  Toggle()
  26. local dri=0 --rs last state                        --*func val*------(v5)  Toggle()
  27. local AB=6 --player sensor to sensor length in x   --*func val*------(v6)  Triangulate
  28. local AC=6 --player sensor to sensor length in y   --*func val*------(v7)  Triangulate
  29. local AD=6 --player sensor to sensor length in x   --*func val*------(v8)  Triangulate
  30. local pInside={} --current players inside                      ------(v9)
  31. local minimumStock=1 --minimum stock (minimum stock is multiplied by the minimum selling quantity)  ------(v10)
  32. local osTimer = 1 -- touch screen pull event timeout time
  33. ---------------------------------------------------------------------
  34. -- V v V v V v V v V v V v V  functions  V v V v V v V v V v V v V --
  35. ---------------------------------------------------------------------
  36.  
  37. --ATM - Store Credit Purchase Toggle - RS Toggle input: LEFT         ------(f1)
  38. function Toggle(name)
  39.  
  40.     local ri=redstone.getAnalogueInput("left") --rs current state
  41.     local rsDistance=0 --distance from first lever to PC
  42.  
  43.     id=findPlayer(name)
  44.  
  45.  
  46.     if ri~=dri and ri>0 then
  47.     if ri==(15-rsDistance) then T[id].bal=T[id].bal + 50  end
  48.     if ri==(14-rsDistance) then T[id].bal=T[id].bal + 100 end
  49.     if ri==(13-rsDistance) then T[id].bal=T[id].bal + 500 end
  50.     if ri==(12-rsDistance) then T[id].bal=T[id].bal + 1000 end
  51.     if ri==(11-rsDistance) then T[id].bal=T[id].bal + 5000 end
  52.     if ri==(10-rsDistance) then T[id].bal=T[id].bal + 10000 end
  53.   end
  54.   dri=ri --rs last state
  55. end
  56.  
  57. function C(Mo)  --clear monitor                                      ------(f2)
  58.  
  59.     Mo.setBackgroundColor(bgc)
  60.     Mo.clear()
  61. end
  62.  
  63. function atmMonitor(name,mode)  --ATM Monitor                                 ------(f3)
  64.     C(mATM)
  65.     if mode == 0 then
  66.         id=findPlayer(name)
  67.         mATM.setCursorPos(2,6)
  68.         mATM.write("   Welcome! We are Open   ")
  69.         mATM.setCursorPos(2,7)
  70.         mATM.write("         Entrance -->      ")
  71.     elseif mode==1 then
  72.         id=findPlayer(name)
  73.         mATM.setCursorPos(2,6)
  74.         mATM.write("Welcome ")
  75.         mATM.write(T[id].player)
  76.         mATM.write("!")
  77.         mATM.setCursorPos(2,7)
  78.         mATM.write("Your balance is: $")
  79.         mATM.write(T[id].bal)
  80.     end
  81. end
  82.  
  83. function getNearby() --used inside triangulate                        ------(f4)
  84.     a=psa.getNearbyPlayers()
  85.     b=psb.getNearbyPlayers()  
  86.     c=psc.getNearbyPlayers()
  87.     d=psd.getNearbyPlayers()
  88.  
  89.     pabcd={}
  90.     for ia=1,table.getn(a) do
  91.         table.insert(pabcd,{player=a[ia].player,da=a[ia].distance,db=26,dc=26,dd=26})
  92.         for  ib=1,table.getn(b) do
  93.             if b[ib].player==a[ia].player then pabcd[ia].db=b[ib].distance end
  94.         end
  95.         for  ic=1,table.getn(c) do
  96.             if c[ic].player==a[ia].player then pabcd[ia].dc=c[ic].distance end
  97.         end
  98.         for  id=1,table.getn(d) do
  99.             if d[id].player==a[ia].player then pabcd[ia].dd=d[id].distance end
  100.         end
  101.     end
  102.     return pabcd
  103. end
  104.  
  105. function triangulate() --returns the players inside the room            ------(f5)
  106.     pabcd=getNearby()
  107.     playersInside={}  
  108.     for id=1,table.getn(pabcd) do
  109.         X=(pabcd[id].da^2+AB^2-pabcd[id].db^2)/(2*AB)
  110.         Y=(pabcd[id].da^2+AC^2-pabcd[id].dc^2)/(2*AC)
  111.         Z=-1*(pabcd[id].da^2+AD^2-pabcd[id].dd^2)/(2*AD)
  112.         inOut=(X>0.29 and X<5.71) and (Y>0.29 and Y<4.71) and (Z>0 and Z<4.3) --in = true
  113.         if inOut then
  114.             table.insert(playersInside,pabcd[id].player)
  115.         end
  116.     end
  117.  
  118.     return playersInside
  119. end
  120.  
  121. function register(name) --registers a new player to the database         ------(f6)
  122.     bool=true
  123.     for i=1,table.getn(T) do
  124.         if T[i].player == name then
  125.             bool=false
  126.             break
  127.         end
  128.     end
  129.     if bool then
  130.         write(name)
  131.         print(" registered!")
  132.         table.insert(T,{player=name,bal=0})
  133.     end
  134. end
  135.  
  136. function findPlayer(name) --findPlayers player's location in database                 ------(f7)
  137.     for i=1,table.getn(T) do
  138.         if T[i].player == name then
  139.             return(i)
  140.         end
  141.     end
  142. end
  143.  
  144. function findItem(name) --findPlayers player's location in database                 ------(f7.1)
  145.     for i=1,table.getn(store) do
  146.         if store[i].item == name then
  147.             return(i)
  148.         end
  149.     end
  150. end
  151.  
  152. function backup() --backup                                            ------(f8)
  153.     local output = textutils.serialize(T)
  154.     local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
  155.     handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
  156.     handle.close()
  157. end
  158.  
  159. function load()
  160.     local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
  161.     local input = handle.readAll() -- input is now the serialized table
  162.     handle.close()
  163.  
  164.     return textutils.unserialize(input) -- this will decode our table
  165. end
  166.  
  167. function getData() --Data Function (you can change the link here)
  168.     local link = "https://docs.google.com/spreadsheets/d/1BXy2tNcxcvf8EJX4__cicnSpYHB3Oh4QlRGn_MW1mY8/export?format=csv"
  169.     local fileName = "data.csv"
  170.     shell.run("wget", link, fileName)
  171.  
  172.     local csv = fs.open(fileName, "r")
  173.     local cR = 1 -- counter row
  174.     local result = {}
  175.  
  176.     while true do
  177.         local line = csv.readLine()
  178.         if not line then break end --EOF
  179.  
  180.          cC = 1 -- counter column
  181.          last = ""
  182.           out = {}
  183.  
  184.           for i in string.gmatch(line,"[^,]*") do
  185.                 if i ~= "" then
  186.                     out[cC] = i
  187.                     cC = cC+1
  188.                  elseif last == "" then
  189.                     out[cC] = i
  190.                     cC = cC+1
  191.                 end
  192.                 last = i
  193.             end
  194.  
  195.         result[cR] = out
  196.         cR = cR+1
  197.  
  198.     end
  199.  
  200.     csv.close()
  201.     fs.delete(fileName)
  202.  
  203.     --print("result[4][1] (4th row, 1st column)")
  204.     --print(result[4][1])
  205.  
  206.     local dataStore={}
  207.         table.insert(dataStore,{item="nil",name="nil",meta=0,nbt ="",qtyS=0,price=0})
  208.         table.insert(dataStore,{item="nil2",name="nil",meta=0,nbt ="",qtyS=0,price=0})
  209.     for i=3,result[1][1] do
  210.         local itemNameMerge=result[i][3]..":"..result[i][4]
  211.  
  212.         table.insert(dataStore,{item=result[i][2],name=itemNameMerge,meta=tonumber(result[i][5]),nbt =result[i][6],qtyS=tonumber(result[i][8]),price=tonumber(result[i][1]),available=false,stock=0,craftable=false})
  213.     end
  214.  
  215.     return dataStore
  216.  
  217. end
  218.  
  219.  
  220.  
  221. function buy(idItem) --buys item, enter item id in store[id]         ------(f9)
  222.  local name = pInside[1]
  223.  local id=findPlayer(name)
  224.     if idItem ~= 0 and T[id].bal>=store[idItem].price then
  225.         if store[idItem].available then        --successfull buy
  226.             mStore.setBackgroundColor(colors.black)
  227.             P("monitor_6",{2,17},colors.green,0,tostring(store[idItem].qtyS) .. " " .. store[idItem].item .. " purchased!                                ")
  228.             mStore.setTextColor(colors.white)            
  229.  
  230.             if store[idItem].craftable and ((minimumStock+2)*store[idItem].qtyS>store[idItem].stock) then
  231.                  me.craft(store[idItem].name,store[idItem].meta,store[idItem].qtyS,store[idItem].nbt) --this will make sure items are automatically crafted when they run out
  232.             end    
  233.  
  234.             T[id].bal=T[id].bal-store[idItem].price
  235.             me.retrieve(store[idItem].name,store[idItem].meta,store[idItem].qtyS,"up",store[idItem].nbt)
  236.            
  237.  
  238.         elseif (not store[idItem].available) and store[idItem].craftable then --no stock but still craftable
  239.            
  240.             mStore.setBackgroundColor(colors.black)
  241.             P("monitor_6",{2,17},colors.yellow,0,"Crafting " .. tostring(store[idItem].qtyS) .." " .. store[idItem].item .. "                 ")
  242.             mStore.setTextColor(colors.white)
  243.  
  244.  
  245.                                          
  246.             local originalStock=store[idItem].stock
  247.             local breakLoop=false
  248.  
  249.             for i=1,store[idItem].qtyS do
  250.                 local ccc=0
  251.                 availability()
  252.                 beforeCraftStock=store[idItem].stock
  253.                 me.craft(store[idItem].name,store[idItem].meta,1,store[idItem].nbt)
  254.                 local a1,a2,a3,a4 = os.pullEvent("craftingComplete")
  255.                 local MaxCountsAllowed=0.11*a4+5
  256.                 local crafting=true
  257.                 local breakLoop=0
  258.                 while crafting do
  259.                     availability()
  260.                     mStore.setBackgroundColor(colors.black)
  261.                     P("monitor_6",{1,21},colors.yellow,0,"Crafted: " .. tostring(store[idItem].stock-originalStock))
  262.                     mStore.setTextColor(colors.white)
  263.                     if store[idItem].stock > beforeCraftStock then
  264.                         crafting=false
  265.                         print("wtf is this")
  266.                     end
  267.                     if ccc>=MaxCountsAllowed then
  268.                         crafting=false
  269.                         breakLoop=1
  270.                     end
  271.                     sleep(0.2)
  272.                     ccc=ccc+1
  273.                     if store[idItem].stock >= store[idItem].qtyS then
  274.                         sleep(0.5)
  275.                         me.retrieve(store[idItem].name,store[idItem].meta,store[idItem].qtyS,"up",store[idItem].nbt)
  276.                         crafting=false
  277.                         breakLoop=2
  278.                         T[id].bal=T[id].bal-store[idItem].price
  279.                         P("monitor_6",{1,21},colors.white,0,"           ")
  280.                         P("monitor_6",{2,17},colors.green,0,tostring(store[idItem].qtyS) .. " " .. store[idItem].item .. " purchased!                                ")
  281.                         mStore.setTextColor(colors.white)
  282.                     end
  283.                 end
  284.  
  285.                 P("monitor_6",{1,21},colors.white,0,"           ")
  286.                 print("breakLoop="..breakLoop)
  287.                 if breakLoop==2 then break end --succesfull crafting and retrieving
  288.                 if breakLoop==1 then --craft unsuccessfull - break whole operation
  289.                     mStore.setBackgroundColor(colors.black)
  290.                     P("monitor_6",{2,17},colors.red,0,"Ingredients Not Available                  ")
  291.                     mStore.setTextColor(colors.white)
  292.                     break
  293.                 end
  294.             end
  295.         me.craft(store[idItem].name,store[idItem].meta,store[idItem].qtyS,store[idItem].nbt)
  296.         end
  297.        
  298.            
  299.        
  300.     elseif idItem ~= 0 and T[id].bal<=store[idItem].price then
  301.         mStore.setBackgroundColor(colors.black)
  302.         P("monitor_6",{2,17},colors.red,0,"Purchase failed: Refill balance                                                    ")
  303.         mStore.setTextColor(colors.white)
  304.  
  305.     end
  306. end
  307.  
  308. function availability()                                 ------(f10)
  309.     currentItems={}
  310.     currentCraftable={}
  311.     currentItems=me.listItems() --compare: name, amount, meta, nbt
  312.     currentCraftable=me.listCraft()                     ------------------------********* double check me ********
  313.     for i=1,table.getn(store) do
  314.         for j=1,table.getn(currentItems) do            --available
  315.            if store[i].name==currentItems[j].name and store[i].meta==currentItems[j].meta and store[i].nbt==currentItems[j].nbt then
  316.                 store[i].stock=currentItems[j].amount
  317.                 if currentItems[j].amount > (minimumStock*store[i].qtyS) then
  318.                     store[i].available=true
  319.                     store[i].stock=currentItems[j].amount
  320.                 else
  321.                     store[i].available=false
  322.                 end
  323.                 break
  324.            end
  325.            store[i].available=false
  326.            store[i].stock=0
  327.         end
  328.  
  329.         for k=1,table.getn(currentCraftable) do             --craftable
  330.            if store[i].name==currentCraftable[k].name and store[i].meta==currentCraftable[k].meta and store[i].nbt==currentCraftable[k].nbt then
  331.                store[i].craftable=true
  332.                break
  333.            end
  334.            store[i].craftable=false
  335.         end
  336.     end
  337. end
  338.  
  339. local tableStart=1      --used for scrolling the onScreen table used in f11
  340. local touchFeedBack = false
  341. local x1=0
  342. local y1=0 -- touch screen pos
  343.  
  344. function storeMonitor(name)                                ------(f11)
  345.     local line={1,10}
  346.     local txtc = colors.white
  347.     local id=findPlayer(name)
  348.     local onScreen= {}      --used to convert between onscreen values and T
  349.     local printableCounter= 0      --used to count printable values
  350.     local counter=1 --onScreen timer
  351.  
  352.  
  353.     --clear + scroll
  354.     for i=3,19 do
  355.         mStore.setCursorPos(1,i)
  356.         mStore.setBackgroundColor(colors.black)
  357.         mStore.write("                                                  ")
  358.     end
  359.     P("monitor_6",{1,1},txtc,0,"               ")
  360.     P("monitor_6",{1,28},txtc,0,"                   ")
  361.  
  362.     mStore.setBackgroundColor(colors.lightGray)
  363.     mStore.setCursorPos(1,4)
  364.     mStore.write("^")
  365.     mStore.setCursorPos(1,19)
  366.     mStore.write("v")
  367.     mStore.setBackgroundColor(colors.black)
  368.  
  369.     --2 lines space for stats
  370.  
  371.     line=P("monitor_6",line,txtc,0,"                      ")
  372.     line=P("monitor_6",{line[1],41},txtc,0,"            ")
  373.  
  374.     line={1,2}
  375.     line=P("monitor_6",line,txtc,0,"Player: ")
  376.     line=P("monitor_6",line,txtc,0,pInside[1])
  377.     line=P("monitor_6",{line[1],32},txtc,0,"balance: $")
  378.     line=P("monitor_6",line,txtc,1,T[id].bal)
  379.     line=P("monitor_6",{line[1],2},txtc,0,"System Status: ")
  380.  
  381.     --1 line table header
  382.     mStore.setBackgroundColor(colors.purple)
  383.     mStore.setTextColor(colors.black)
  384.     mStore.setCursorPos(1,3)
  385.     mStore.write(" Item                 Qty  Price  Stock  Craftable")
  386.  
  387.     mStore.setTextColor(colors.white)
  388.     mStore.setBackgroundColor(colors.black)
  389.     --table content
  390.     line={4,1}
  391.  
  392.     if tableStart == 0 then
  393.         line=P("monitor_6",{line[1],2},txtc,1,"                                                 ")
  394.         onScreen[counter]=0
  395.         counter=counter+1
  396.     end
  397.     for i=1,table.getn(store) do
  398.         if store[i].available or store[i].craftable then
  399.             printableCounter=printableCounter+1
  400.             if printableCounter >= tableStart then
  401.                 onScreen[counter]=i
  402.                 if (counter+tableStart)%2==0 then
  403.                     mStore.setBackgroundColor(colors.black)
  404.                 else
  405.                     mStore.setBackgroundColor(colors.gray)
  406.                 end
  407.                 if x1>1 and x1<=45 and y1<=19 and y1>3 and counter == y1-3 then
  408.                     print("hi- x:" .. tostring(x1) .. "  y:" .. tostring(y1))
  409.                     if T[id].bal >= store[i].price then
  410.  
  411.                         mStore.setBackgroundColor(colors.green)
  412.                     else
  413.  
  414.                         mStore.setBackgroundColor(colors.red)
  415.                     end
  416.                 end
  417.                 line=P("monitor_6",{line[1],2},txtc,0,store[i].item)
  418.                 line=P("monitor_6",line,txtc,0,"                                                       ")
  419.                 line=P("monitor_6",{line[1],23},txtc,0,tostring(store[i].qtyS))
  420.                 line=P("monitor_6",{line[1],27},txtc,0,"$ ")
  421.                 line=P("monitor_6",line,txtc,0,store[i].price)
  422.                 line=P("monitor_6",{line[1],37},txtc,0,tostring(store[i].stock))
  423.                 if store[i].craftable then
  424.                     line=P("monitor_6",{line[1],45},txtc,1,"Yes")
  425.                 else
  426.                     line=P("monitor_6",{line[1],45},txtc,1,"No")
  427.                 end
  428.                 counter=counter+1
  429.             end
  430.         end
  431.     end
  432.  
  433.     x1,y1=touch()
  434.     --print("monitor cought - x1:" .. tostring(x1) .. "  y1:" .. tostring(y1))
  435.    
  436.     if x1==1 and y1==4 then
  437.         if tableStart>1 then
  438.             tableStart=tableStart-15
  439.         else
  440.             mStore.setBackgroundColor(colors.red)
  441.             mStore.setCursorPos(1,4)
  442.             mStore.write("^")
  443.             mStore.setBackgroundColor(colors.black)
  444.             sleep(0.1)
  445.         end
  446.     elseif x1==1 and y1==19 then
  447.         if tableStart<=(printableCounter-15) then
  448.             tableStart=tableStart+15
  449.         else
  450.             mStore.setBackgroundColor(colors.red)
  451.             mStore.setCursorPos(1,19)
  452.             mStore.write("v")
  453.             mStore.setBackgroundColor(colors.black)
  454.             sleep(0.1)        
  455.         end
  456.     end
  457.  
  458.     if tableStart==0 and y1==4 then return 0 end
  459.  
  460.     if x1>1 and x1<=45 and y1<=19 and y1>3 and table.getn(onScreen)>=(y1-3) and (y1-3)>0 then
  461.         print("x1: " .. tostring(x1) .. "  y1: " .. tostring(y1))
  462.         print("purchase:" .. store[(onScreen[y1-3])].item)
  463.         print(table.getn(onScreen))
  464.         return onScreen[y1-3]
  465.     end
  466.  
  467.     return 0
  468. end
  469.  
  470. function P(monitor,pos,textColor,special,txt)  --monitor print function           ------(f12)
  471.  
  472.         -- USAGE:         P("monitor",i,txtc,0,"<enter text here>")
  473.         --special: # of lines to skip
  474.             -- "m" for middle txt + skip 1 line
  475.             -- "m2" for middle txt + skip 2 lines
  476.  
  477.     M=peripheral.wrap(monitor)
  478.  
  479.     if special == "m" or special == "m2" then
  480.         pos[2]= math.floor(71/2 - string.len(txt)/2)
  481.     end
  482.     M.setCursorPos(pos[2],pos[1])
  483.     M.setTextColor(textColor)
  484.  
  485.     M.write(txt)
  486.    
  487.  
  488.     if special ~= "m" and special ~= "m2" then
  489.         if  special > 0 then
  490.             lineValue= pos[1] + special
  491.             letterValue=2
  492.         elseif special ==0 then
  493.             lineValue= pos[1]
  494.             letterValue= pos[2] + string.len(txt)
  495.         end
  496.     else
  497.         if special == "m" then
  498.             lineValue= pos[1] + 1
  499.             letterValue= 2
  500.         elseif special == "m2" then
  501.             lineValue= pos[1] + 2
  502.             letterValue= 2
  503.         end
  504.     end
  505.    
  506.    
  507.     return({lineValue,letterValue})
  508. end
  509.  
  510. function touch()   --monitor touch function           ------(f12)
  511.  
  512.     local Y3=0
  513.     local X3=0
  514.  
  515.     local eventtocatch = 'monitor_touch' --(for example)
  516.     local timeout = os.startTimer(osTimer)
  517.     local A,side,X2,Y2 = os.pullEvent()
  518.     if A=='timer' and side==timeout then
  519.         Y3=0
  520.         X3=0
  521.     elseif A==eventtocatch and side=="monitor_6"then
  522.         X3=X2
  523.         Y3=Y2
  524.     end
  525.  
  526.     --print("tourch return - x:" .. tostring(X3) .. "  y:" .. tostring(Y3))
  527.     return X3,Y3
  528. end
  529.  
  530. function resetBalance() --Reset Balance for player inside  ------(f13)
  531.     local name = pInside[1]
  532.     local id=findPlayer(name)
  533.     T[id].bal=0
  534. end
  535. ---------------------------------------------------------------------
  536. -- V v V v V v V v V v V v V  Main Loop  V v V v V v V v V v V v V --
  537. ---------------------------------------------------------------------
  538.  
  539. print("loading...")
  540. for i=1,10 do
  541.     sleep(0.1)
  542.     write(i*10)
  543.     print("%")
  544. end
  545. print("loading Complete...")
  546.  
  547. T=load()
  548. store=getData()
  549. availability()
  550.  
  551. C(mStore)
  552. C(mATM)
  553.  
  554. local r1=0
  555. local r2=0
  556.  
  557.     write(findItem("Redstone"))
  558.     write(": ")
  559.     write(store[findItem("Redstone")].item)
  560.     write(store[findItem("Redstone")].price)
  561.     write("availability: ")
  562.     if store[findItem("Redstone")].available then write("yes") else write("no") end
  563.     write("stock: ")
  564.     print(store[findItem("Redstone")].stock)
  565.  
  566. while true do
  567.     pInside=triangulate()
  568.    
  569.  
  570.     if table.getn(pInside)==0 then
  571.         redstone.setOutput("right",true) -- shop empty
  572.         atmMonitor("test",0)
  573.         pInside[1]="test"
  574.         sleep(0.1)
  575.         C(mStore)
  576.    elseif table.getn(pInside)==1 then
  577.         redstone.setOutput("right",false) --player inside
  578.         register(pInside[1])
  579.         buy(storeMonitor(pInside[1]))
  580.         availability()
  581.         Toggle(pInside[1])
  582.         atmMonitor(pInside[1],1)
  583.    else
  584.        redstone.setOutput("right",true) -- ERROR! two players inside
  585.        sleep(0.05)
  586.    end
  587.  
  588.  
  589.     --reset balance function
  590.     r1=redstone.getInput("back")
  591.     if (r1 and (not r2)) then
  592.         resetBalance()
  593.     end
  594.     r2=r1
  595.  
  596.  
  597.  
  598.     backup()
  599.  
  600. end
Add Comment
Please, Sign In to add comment