Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local nbPuit = 0
- local nbPuitsTotal = 0
- local profondeur = 0
- local message = "attente"
- mon = peripheral.wrap("right")
- function split(str,pat)
- local t = {}
- 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
- function affiche_etat()
- mon.clear()
- mon.setCursorPos(4,4)
- if message == "attente" then
- mon.write("En attente de la tortue...")
- elseif message == "encours" then
- mon.write("Avancement du minage : "..nbPuit.."/"..nbPuitsTotal)
- mon.setCursorPos(4,6)
- if profondeur == 0 then
- mon.write("Profondeur : "..profondeur)
- else
- mon.write("Profondeur : -"..profondeur)
- end
- elseif message == "retour" then
- mon.write("Minage fini, retour au point de depart...")
- elseif message == "fin" then
- mon.write("Minage fini !")
- end
- end
- rednet.open("left")
- affiche_etat()
- while true do
- event, id, text = os.pullEvent()
- if event == "rednet_message" then
- local tab = split(text,":")
- if tab[1] == "etat" then message = tab[2] end
- if tab[1] == "nbPuitsTotal" then nbPuitsTotal = tab[2] end
- if tab[1] == "nbPuits" then nbPuit = tab[2] end
- if tab[1] == "profondeur" then profondeur = tab[2] end
- affiche_etat()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement