Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Paramètres
- local chlore_min_pct = 50
- local chlore_max_pct = 95
- local hydrogene_min_pct = 50
- local hydrogene_max_pct = 95
- local hysteresis = 10
- local seuil = 90
- -- Valeurs max réelles
- local chlore_max = 200000
- local hydrogene_max = 200000
- -- Lecture des fluides
- local chlore = red['kr-chlorine'] or 0
- local hydrogene = green['kr-hydrogen'] or 0
- -- Pourcentages
- local chlore_pct = (chlore / chlore_max) * 100
- local hydrogene_pct = (hydrogene / hydrogene_max) * 100
- -- Initialisation si nécessaire
- if a == nil then a = 2 end
- if b == nil then b = 2 end
- -- --- Fluide1 (chlore)
- if chlore_pct > chlore_max_pct and hydrogene_pct < hydrogene_min_pct then
- a = 1
- elseif a == 1 then
- if chlore_pct < (chlore_max_pct - hysteresis) or hydrogene_pct > seuil then
- a = 2
- end
- end
- -- --- Fluide2 (hydrogène)
- if hydrogene_pct > hydrogene_max_pct and chlore_pct < chlore_min_pct then
- b = 1
- elseif b == 1 then
- if hydrogene_pct < (hydrogene_max_pct - hysteresis) or chlore_pct > seuil then
- b = 2
- end
- end
- -- --- Réactivation possible
- -- même si a ou b était actif avant, on peut les réactiver si conditions présentes
- if a == 2 and chlore_pct > chlore_max_pct and hydrogene_pct < hydrogene_min_pct then
- a = 1
- end
- if b == 2 and hydrogene_pct > hydrogene_max_pct and chlore_pct < chlore_min_pct then
- b = 1
- end
- -- Sorties
- out['signal-A'] = a
- out['signal-B'] = b
Advertisement
Add Comment
Please, Sign In to add comment