/obj/machinery/power/generator name = "thermoelectric generator" desc = "It's a high efficiency thermoelectric generator." icon_state = "teg" density = TRUE use_power = NO_POWER_USE var/obj/machinery/atmospherics/components/binary/circulator/cold_circ var/obj/machinery/atmospherics/components/binary/circulator/hot_circ var/lastgen = 0 var/lastgenlev = -1 var/lastcirc = "00" /obj/machinery/power/generator/Initialize(mapload) . = ..() find_circs() connect_to_network() SSair.atmos_machinery += src update_icon() component_parts = list(new /obj/item/circuitboard/machine/generator) /obj/machinery/power/generator/ComponentInitialize() . = ..() AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS ) /obj/machinery/power/generator/Destroy() kill_circs() SSair.atmos_machinery -= src return ..() /obj/machinery/power/generator/update_icon() if(stat & (NOPOWER|BROKEN)) cut_overlays() else cut_overlays() var/L = min(round(lastgenlev/100000),11) if(L != 0) add_overlay(image('icons/obj/power.dmi', "teg-op[L]")) if(hot_circ && cold_circ) add_overlay("teg-oc[lastcirc]") #define GENRATE 800 // generator output coefficient from Q /obj/machinery/power/generator/process_atmos() if(!cold_circ || !hot_circ) return if(powernet) var/datum/gas_mixture/cold_air = cold_circ.return_transfer_air() var/datum/gas_mixture/hot_air = hot_circ.return_transfer_air() if(cold_air && hot_air) var/cold_air_heat_capacity = cold_air.heat_capacity() var/hot_air_heat_capacity = hot_air.heat_capacity() var/delta_temperature = hot_air.temperature - cold_air.temperature if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0) var/efficiency = 0.65 var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity) var/heat = energy_transfer*(1-efficiency) lastgen += energy_transfer*efficiency hot_air.temperature = hot_air.temperature - energy_transfer/hot_air_heat_capacity cold_air.temperature = cold_air.temperature + heat/cold_air_heat_capacity //add_avail(lastgen) This is done in process now // update icon overlays only if displayed level has changed if(hot_air) var/datum/gas_mixture/hot_circ_air1 = hot_circ.airs[1] hot_circ_air1.merge(hot_air) if(cold_air) var/datum/gas_mixture/cold_circ_air1 = cold_circ.airs[1] cold_circ_air1.merge(cold_air) update_icon() var/circ = "[cold_circ && cold_circ.last_pressure_delta > 0 ? "1" : "0"][hot_circ && hot_circ.last_pressure_delta > 0 ? "1" : "0"]" if(circ != lastcirc) lastcirc = circ update_icon() src.updateDialog() /obj/machinery/power/generator/process() //Setting this number higher just makes the change in power output slower, it doesnt actualy reduce power output cause **math** var/power_output = round(lastgen / 10) add_avail(power_output) lastgenlev = power_output lastgen -= power_output ..() /obj/machinery/power/generator/proc/get_menu(include_link = TRUE) var/t = "" if(!powernet) t += "Unable to connect to the power network!" else if(cold_circ && hot_circ) var/datum/gas_mixture/cold_circ_air1 = cold_circ.airs[1] var/datum/gas_mixture/cold_circ_air2 = cold_circ.airs[2] var/datum/gas_mixture/hot_circ_air1 = hot_circ.airs[1] var/datum/gas_mixture/hot_circ_air2 = hot_circ.airs[2] t += "