From c2a4de92ccfea829a84d71e272bd44d204f7343d Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Sun, 8 Dec 2013 21:33:25 +0100 Subject: [PATCH 1/4] Update turbine.dm Turbine now works as intended in rev4407 Tweaked the power generation too to fit the increased demand Still needs a better computer code --- code/modules/power/turbine.dm | 148 ++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 41 deletions(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index f39e18acdc9..83a1a069462 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -1,3 +1,27 @@ +// TURBINE v2 AKA rev4407 Engine reborn! + +// How to use it? - Mappers +// +// This is a very good power generating mechanism. All you need is a blast furnace with soaring flames and output. +// Not everything is included yet so the turbine can run out of fuel quiet quickly. The best thing about the turbine is that even +// though something is on fire that passes through it, it won't be on fire as it passes out of it. So the exhaust fumes can still +// containt unreacted fuel - plasma and oxygen that needs to be filtered out and re-routed back. This of course requires smart piping +// For a computer to work with the turbine the compressor requires a comp_id matching with the turbine computer's id. This will be +// subjected to a change in the near future mind you. Right now this method of generating power is a good backup but don't expect it +// become a main power source unless some work is done. Have fun. At 50k RPM it generates 60k power. So more than one turbine is needed! +// +// - Numbers +// +// Example setup S - sparker +// B - Blast doors into space for venting +// *BBB****BBB* C - Compressor +// S CT * T - Turbine +// * ^ * * V * D - Doors with firedoor +// **|***D**|** ^ - Fuel feed (Not vent, but a gas outlet) +// | | V - Suction vent (Like the ones in atmos +// + + /obj/machinery/compressor name = "compressor" desc = "The compressor stage of a gas turbine generator." @@ -21,28 +45,29 @@ icon_state = "turbine" anchored = 1 density = 1 + var/opened = 0 var/obj/machinery/compressor/compressor directwired = 1 var/turf/simulated/outturf var/lastgen /obj/machinery/computer/turbine_computer - name = "Gas Turbine Control Console" + name = "Gas turbine control computer" desc = "A computer to remotely control a gas turbine" icon = 'icons/obj/computer.dmi' icon_state = "airtunnel0e" anchored = 1 density = 1 var/obj/machinery/compressor/compressor - var/list/obj/machinery/door/poddoor/doors var/id = 0 - var/door_status = 0 // the inlet stage of the gas turbine electricity generator /obj/machinery/compressor/New() ..() +// The inlet of the compressor is the direction it faces + gas_contained = new inturf = get_step(src, dir) @@ -55,6 +80,12 @@ #define COMPFRICTION 5e5 #define COMPSTARTERLOAD 2800 + +// Crucial to make things work!!!! + +/obj/machinery/power/compressor/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) + return !density + /obj/machinery/compressor/process() if(!starter) return @@ -66,11 +97,16 @@ return rpm = 0.9* rpm + 0.1 * rpmtarget var/datum/gas_mixture/environment = inturf.return_air() + + // It's a simplified version taking only 1/10 of the moles from the turf nearby. It should be later changed into a better version + var/transfer_moles = environment.total_moles()/10 //var/transfer_moles = rpm/10000*capacity var/datum/gas_mixture/removed = inturf.remove_air(transfer_moles) gas_contained.merge(removed) +// RPM function to include compression friction - be advised that too low/high of a compfriction value can make things screwy + rpm = max(0, rpm - (rpm*rpm)/COMPFRICTION) @@ -94,21 +130,35 @@ overlays += image('icons/obj/pipes.dmi', "comp-o1", FLY_LAYER) //TODO: DEFERRED +// These are crucial to working of a turbine - the stats modify the power output. TurbGenQ modifies how much raw energy can you get from +// rpms, TurbGenG modifies the shape of the curve - the lower the value the less straight the curve is. + +#define TURBPRES 9000000 +#define TURBGENQ 100000 +#define TURBGENG 0.5 + /obj/machinery/power/turbine/New() ..() +// The outlet is pointed at the direction of the turbine component + outturf = get_step(src, dir) spawn(5) +// compressor is found in the opposite direction + compressor = locate() in get_step(src, get_dir(outturf, src)) if(!compressor) stat |= BROKEN -#define TURBPRES 9000000 -#define TURBGENQ 20000 -#define TURBGENG 0.8 +// THIS MAKES IT WORK!!!!! + +/obj/machinery/power/turbine/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) + return !density + + /obj/machinery/power/turbine/process() if(!compressor.starter) @@ -119,10 +169,18 @@ if(!compressor) stat |= BROKEN return + + // This is the power generation function. If anything is needed it's good to plot it in EXCEL before modifying + // the TURBGENQ and TURBGENG values + lastgen = ((compressor.rpm / TURBGENQ)**TURBGENG) *TURBGENQ add_avail(lastgen) + + // Weird function but it works. Should be something else... + var/newrpm = ((compressor.gas_contained.temperature) * compressor.gas_contained.total_moles())/4 + newrpm = max(0, newrpm) if(!compressor.starter || newrpm > 1000) @@ -133,6 +191,8 @@ var/datum/gas_mixture/removed = compressor.gas_contained.remove(oamount) outturf.assume_air(removed) +// If it works, put an overlay that it works! + if(lastgen > 100) overlays += image('icons/obj/pipes.dmi', "turb-o", FLY_LAYER) @@ -143,6 +203,8 @@ AutoUpdateAI(src) +// AI can't use it! + /obj/machinery/power/turbine/attack_ai(mob/user) if(stat & (BROKEN|NOPOWER)) @@ -150,17 +212,13 @@ interact(user) + +// Only non-AI mobs + /obj/machinery/power/turbine/attack_hand(mob/user) add_fingerprint(user) - if(stat & (BROKEN|NOPOWER)) - return - - interact(user) - -/obj/machinery/power/turbine/proc/interact(mob/user) - if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) ) user.machine = null user << browse(null, "window=turbine") @@ -184,28 +242,50 @@ return -/obj/machinery/power/turbine/Topic(href, href_list) - if(..()) - return - if( href_list["close"] ) + +/obj/machinery/power/turbine/Topic(href, href_list) + ..() + if(stat & BROKEN) + return + if (usr.stat || usr.restrained() ) + return + if (!(istype(usr, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey") + if(!istype(usr, /mob/living/silicon/ai)) + usr << "\red You don't have the dexterity to do this!" + return + + if (( usr.machine==src && ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai))) + + + if( href_list["close"] ) + usr << browse(null, "window=turbine") + usr.machine = null + return + + else if( href_list["str"] ) + compressor.starter = !compressor.starter + + spawn(0) + for(var/mob/M in viewers(1, src)) + if ((M.client && M.machine == src)) + src.interact(M) + + else usr << browse(null, "window=turbine") usr.machine = null - return - else if( href_list["str"] ) - compressor.starter = !compressor.starter + return + - spawn(0) - for(var/mob/M in viewers(1, src)) - if ((M.client && M.machine == src)) - src.interact(M) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// COMPUTER NEEDS A SERIOUS REWRITE. + /obj/machinery/computer/turbine_computer/New() @@ -214,10 +294,7 @@ for(var/obj/machinery/compressor/C in world) if(id == C.comp_id) compressor = C - doors = new /list() - for(var/obj/machinery/door/poddoor/P in world) - if(P.id == id) - doors += P + /obj/machinery/computer/turbine_computer/attackby(I as obj, user as mob) if(istype(I, /obj/item/weapon/screwdriver)) @@ -262,8 +339,7 @@ \nTurbine speed: [src.compressor.rpm]rpm
\nPower currently being generated: [src.compressor.turbine.lastgen]W
\nInternal gas temperature: [src.compressor.gas_contained.temperature]K
- \nVent doors: [ src.door_status ? "Closed Open" : "Closed Open"] - \n
View + \n
View \n
Close \n
\n"} @@ -286,16 +362,6 @@ usr.client.eye = src.compressor else if( href_list["str"] ) src.compressor.starter = !src.compressor.starter - else if (href_list["doors"]) - for(var/obj/machinery/door/poddoor/D in src.doors) - if (door_status == 0) - spawn( 0 ) - D.open() - door_status = 1 - else - spawn( 0 ) - D.close() - door_status = 0 else if( href_list["close"] ) usr << browse(null, "window=computer") usr.machine = null @@ -307,4 +373,4 @@ /obj/machinery/computer/turbine_computer/process() src.updateDialog() - return \ No newline at end of file + return From 372992ca36e5ba2cc4f64c58cb92c08c06ac148a Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Sun, 8 Dec 2013 22:47:29 +0100 Subject: [PATCH 2/4] Lowercased "gas turbine control computer" --- code/modules/power/turbine.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 83a1a069462..7eb1525bca9 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -52,7 +52,7 @@ var/lastgen /obj/machinery/computer/turbine_computer - name = "Gas turbine control computer" + name = "gas turbine control computer" desc = "A computer to remotely control a gas turbine" icon = 'icons/obj/computer.dmi' icon_state = "airtunnel0e" From 64c08c64822c8213771bc3faf8b13721c73a779c Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Mon, 9 Dec 2013 00:17:03 +0100 Subject: [PATCH 3/4] Update turbine.dm Made compatible with LINDA --- code/modules/power/turbine.dm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 7eb1525bca9..2172d34d088 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -82,9 +82,13 @@ // Crucial to make things work!!!! - -/obj/machinery/power/compressor/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) - return !density +// OLD FIX - explanation given down below. +// /obj/machinery/power/compressor/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) +// return !density + + +/obj/machinery/power/compressor/CanAtmosPass(var/turf/T) + return !density /obj/machinery/compressor/process() if(!starter) @@ -155,8 +159,14 @@ // THIS MAKES IT WORK!!!!! -/obj/machinery/power/turbine/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) - return !density +// OLD FIX . Dunno how other engines handle this but this is how it should work: Turbine and compressor should be +// treated as walls to avoid conductivity and gas spread. This was the problem of the original turbine which was just +// a machinery - it didn't block the gas passage. +// /obj/machinery/power/turbine/CanPass(atom/movable/mover, turf/target, height=0, air_group=0) +// return !density + +/obj/machinery/power/turbine/CanAtmosPass(var/turf/T) + return !density From 29d637240f4d470475de1d751a2aa13888c1469d Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Mon, 9 Dec 2013 01:25:10 +0100 Subject: [PATCH 4/4] Update turbine.dm Replaced outdated code that wounded up there for no reason. --- code/modules/power/turbine.dm | 84 +++++++++++++++-------------------- 1 file changed, 35 insertions(+), 49 deletions(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 2172d34d088..faea0bb278d 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -217,75 +217,61 @@ /obj/machinery/power/turbine/attack_ai(mob/user) - if(stat & (BROKEN|NOPOWER)) - return + if(stat & (BROKEN|NOPOWER)) + return - interact(user) - - -// Only non-AI mobs + interact(user) /obj/machinery/power/turbine/attack_hand(mob/user) - add_fingerprint(user) + add_fingerprint(user) - if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) ) - user.machine = null - user << browse(null, "window=turbine") - return + if(stat & (BROKEN|NOPOWER)) + return - user.machine = src + interact(user) - var/t = "Gas Turbine Generator
"
+/obj/machinery/power/turbine/proc/interact(mob/user)
 
-	t += "Generated power : [round(lastgen)] W

" + if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) ) + user.machine = null + user << browse(null, "window=turbine") + return - t += "Turbine: [round(compressor.rpm)] RPM
" + user.machine = src - t += "Starter: [ compressor.starter ? "Off On" : "Off On"]" + var/t = "Gas Turbine Generator
"
 
-	t += "

Close" + t += "Generated power : [round(lastgen)] W

" - t += "
" - user << browse(t, "window=turbine") - onclose(user, "turbine") + t += "Turbine: [round(compressor.rpm)] RPM
" - return + t += "Starter: [ compressor.starter ? "Off On" : "Off On"]" + t += "

Close" + t += "
" + user << browse(t, "window=turbine") + onclose(user, "turbine") + + return /obj/machinery/power/turbine/Topic(href, href_list) - ..() - if(stat & BROKEN) - return - if (usr.stat || usr.restrained() ) - return - if (!(istype(usr, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey") - if(!istype(usr, /mob/living/silicon/ai)) - usr << "\red You don't have the dexterity to do this!" - return + if(..()) + return - if (( usr.machine==src && ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai))) + if( href_list["close"] ) + usr << browse(null, "window=turbine") + usr.machine = null + return + else if( href_list["str"] ) + compressor.starter = !compressor.starter - if( href_list["close"] ) - usr << browse(null, "window=turbine") - usr.machine = null - return - - else if( href_list["str"] ) - compressor.starter = !compressor.starter - - spawn(0) - for(var/mob/M in viewers(1, src)) - if ((M.client && M.machine == src)) - src.interact(M) - - else - usr << browse(null, "window=turbine") - usr.machine = null - - return + spawn(0) + for(var/mob/M in viewers(1, src)) + if ((M.client && M.machine == src)) + src.interact(M)