Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(pString, pPattern)
- local Table = {}
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- end
- return Table
- end
- rednet.open("top")
- id,msg = rednet.receive()
- data = split(msg, "-")
- user = data[1]
- action = data[2]
- if action == 1 then
- f = fs.open(user .. ".txt", "r")
- fc = f.readAll()
- f.close
- if tonumber(fc) > 0 then
- w = fs.open(user .. ".txt", "w")
- new = fc - 1
- w.write(new)
- w.close()
- rednet.send(id,"ok")
- else
- rednet.send(id,"no")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement