Follow

Código Fonte desta automação 

Esse é o sistema Lunox (Trocadilho com "Linux') 😎

````lua
--SISTEMA LUNOX
--Version: 2023-08-28 00:22
--A tela (objTela) pode exibir 2 Janelas: contagem de tempo online (objControl), contagem de minérios entregues (objDetect). Que pode ser Alternado por um botão (objBotao1). Salva valores em banco de dados persistente (objServer) que guarda os valores mesmo que o servidor seja reiniciado. Avisa o jogador pelo chat A cada 30 minérios transportados.

------------------------------------------------------

-- called only once
local objTela = "15139"
local objControl = "15136"
local objServer = "15140"
local objDetect = "15132"
local objBotao1 = "15141"

local modo = "welcome0"
local tempo = 0
local contagem = 0
local contadorshow = ""
local nextToPrint = 0

function dataLoad()
contagem = $server_read(objServer, "contagem") or 0
tempo = $server_read(objServer, "tempo") or 0
end

function dataSave()
$server_write(objServer, "contagem", contagem)
$server_write(objServer, "tempo", tempo)
end

dataLoad()

function myLoop()
tempo = tempo + 1
if $get_input(objDetect) == "on" then
contagem = contagem + 1
dataSave()
if nextToPrint <= contagem then
nextToPrint = contagem + 30
$chat( string.format("Contagem de Minérios: %03d ui (tempo: %02d s)", contagem, tempo) )
end
end
if modo == "" then
local b = $get_input(objBotao1)
if b == "on" then
modo = "welcome0"
end
elseif modo == "welcome0" then
$clear_screen(objTela)
$display(objTela, 3, 'SISTEMA LUNOX')
$display(objTela, 5, 'online...')
modo = "welcome1"
elseif modo == "welcome1" then
$display(objTela, 7, string.format("%02d segundos", tempo))
if $get_input(objBotao1) == "on" then
modo = "contador0"
end
elseif modo == "contador0" then
$clear_screen(objTela)
$display(objTela, 3, 'CONTADOR DE')
$display(objTela, 4, 'MINÉRIOS:')
contadorshow = ""
modo = "contador1"
elseif modo == "contador1" then
if contadorshow ~= contagem then
contadorshow = contagem
$display(objTela, 6, string.format("%02d ui" ,contagem))
end
if $get_input(objBotao1) == "on" then
$clear_screen(objTela)
modo = ""
end
end

end
````

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.