Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("accounts")
- a = accounts.getAccounts()
- local d={}
- for i =1, #a do
- table.insert(d,#d+1,peripheral.wrap("energyDetector_"..a[i].modem))
- end
- pTick=1000
- dollPerPTick=0.1
- function calcDeduction(a)
- t=a
- amount=0
- while t >=pTick do
- t=t-pTick
- amount=amount+1
- end
- return ((1+dollPerPTick)*amount)-1
- end
- while true do
- a = accounts.getAccounts()
- for i =1, #a do
- if a[i].cash<=0 then
- d[i].setTransferRateLimit(0)
- else
- d[i].setTransferRateLimit(900000)
- end
- a[i].FPT=d[i].getTransferRate()
- a[i].used=a[i].used+a[i].FPT
- if a[i].used>=pTick then
- t = calcDeduction(a[i].used)
- --if(a[i].cash-t>0) then
- a[i].cash=a[i].cash-t
- a[i].used=0
- -- else
- -- g=a[i].cash
- -- a[i].cash=0
- -- end
- end
- accounts.updateAccount(a[i])
- end
- sleep(0.5)
- end
Add Comment
Please, Sign In to add comment