Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("rm price")
- shell.run("pastebin get KkUbsxEG price")
- is=peripheral.wrap("bottom")
- function fileToTable(file)
- if fs.exists(file)~=true then
- print("file"..file.." not found")
- return(false)
- end
- fp=fs.open(file,"r")
- line={}
- i=1
- line[i]=fp.readLine()
- if line[i]==nil then return(false) end
- while line[i]~=nil do
- i=i+1
- line[i]=fp.readLine()
- end
- return(line)
- end
- function printMoney(money)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Click here to reset")
- term.setCursorPos(1,2)
- term.write("Money: "..tostring(money))
- end
- function main()
- money=0
- printMoney(money)
- price=fileToTable("price")
- while true do
- i=1
- e, id, amount =os.pullEvent()
- if e=="isort_item" then
- while price[i]~=nil do
- if id==tonumber(price[i]) then
- money=money+tonumber(price[i+2])*amount
- printMoney(money)
- end
- i=i+3
- end
- is.sort(3,amount)
- end
- if e=="key" then
- if id==28 then money=0 end
- printMoney(money)
- end
- if e=="monitor_touch" then
- money=0
- printMoney(money)
- end
- sleep(0)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement