Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(str, pat)
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- term.clear()
- term.setCursorPos(1,1)
- print("CraftCoin Alpha 1.0 Mining Server")
- modem = peripheral.wrap("bottom")
- modem.open(1)
- mining={}
- while true do
- os.startTimer(0.05)
- event, a, b, c, d, f = os.pullEventRaw()
- if event == "timer" then
- print("Tick")
- for i,v in pairs(mining) do
- if mining[i]~= 1337 then
- mining[i]=v-1
- print(v)
- if mining[i]<0 then
- print("Finished A Mine")
- modem.transmit(1,1,"mined "..i)
- mining[i]=1337
- end
- end
- end
- elseif event == "modem_message" then
- msg = d
- msgp = split(msg," ")
- if msgp[1] == "startmine" then
- if msgp[2] then
- mining[msgp[2]]= 1000/3.14*math.random(10,20)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment