alias GasSensor d0 # d1= Logic Switch, Dial variant (Max=30) alias Thermostat d1 # d2 = Console, LED Display variant, optional alias TempDisplay d2 # d3 = Wall Cooler alias WallCooler d3 alias CurrentTemp r0 alias TargetTemp r1 alias MinTemp r2 alias MaxTemp r3 alias CoolingActive r4 alias HeatingActive r5 alias Cooler r6 define HEATER 24258244 define TEMPCONVERT 273.15 define VARIANCE 2 l Cooler WallCooler PrefabHash start: yield # establish min- and max-temps to registry l TargetTemp Thermostat Setting sub MinTemp TargetTemp VARIANCE add MaxTemp TargetTemp VARIANCE # get current temperature jal temp_read # update display bdseal TempDisplay display # compare current temp to max/min temp and # initiate cooling or heating if needed bgt CurrentTemp MaxTemp cooling blt CurrentTemp MinTemp heating j start temp_read: l CurrentTemp GasSensor Temperature sub CurrentTemp CurrentTemp TEMPCONVERT j ra display: s TempDisplay Setting CurrentTemp j ra cooling: yield jal temp_read # test if coolers need to be on or not sgt CoolingActive CurrentTemp TargetTemp # update display bdseal TempDisplay display # send state to coolers sb Cooler On CoolingActive bgtz CoolingActive cooling # Turn off wall-coolers when done sb Cooler On CoolingActive j start heating: yield jal temp_read # test if heaters need to be on or not slt HeatingActive CurrentTemp TargetTemp # update display bdseal TempDisplay display # send state to heaters sb HEATER On HeatingActive bgtz HeatingActive heating # Turn off wall-heaters when done sb HEATER On HeatingActive j start