From 119438bd3ace5328cb050fce9286c9b69a9aaa22 Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Sat, 14 Dec 2013 20:10:08 +0100 Subject: [PATCH 1/5] Includes turbine.dm in .dme file --- tgstation.dme | 1 + 1 file changed, 1 insertion(+) diff --git a/tgstation.dme b/tgstation.dme index e37f31b61a0..f15a189877d 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1057,6 +1057,7 @@ #include "code\modules\power\switch.dm" #include "code\modules\power\terminal.dm" #include "code\modules\power\tracker.dm" +#include "code\modules\power\turbine.dm" #include "code\modules\power\antimatter\containment_jar.dm" #include "code\modules\power\antimatter\control.dm" #include "code\modules\power\antimatter\shielding.dm" From 279e84f12bbd2d3b08762eb15119d302bacebe74 Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Sat, 14 Dec 2013 20:16:25 +0100 Subject: [PATCH 2/5] Updates turbine.dm to bypass the 'code\modules\power\turbine.dm:234:error: interact: duplicate definition' --- code/modules/power/turbine.dm | 69 ++++++++++++++++------------------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index faea0bb278d..33d5969a6cd 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -217,61 +217,56 @@ /obj/machinery/power/turbine/attack_ai(mob/user) - if(stat & (BROKEN|NOPOWER)) - return + if(stat & (BROKEN|NOPOWER)) + return - interact(user) + interact(user) + +// Only non-AI mobs (This is a way to get over a duplicate declaration error! Thanks Metacide!) /obj/machinery/power/turbine/attack_hand(mob/user) - add_fingerprint(user) + add_fingerprint(user) - if(stat & (BROKEN|NOPOWER)) - return + if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) ) + user.machine = null + user << browse(null, "window=turbine") + return - interact(user) + user.machine = src -/obj/machinery/power/turbine/proc/interact(mob/user) + var/t = "Gas Turbine Generator
"
 
-        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 += "Generated power : [round(lastgen)] W

" - user.machine = src + t += "Turbine: [round(compressor.rpm)] RPM
" - var/t = "Gas Turbine Generator
"
+	t += "Starter: [ compressor.starter ? "Off On" : "Off On"]"
 
-        t += "Generated power : [round(lastgen)] W

" + t += "

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

Close" - - t += "
" - user << browse(t, "window=turbine") - onclose(user, "turbine") - - return + return /obj/machinery/power/turbine/Topic(href, href_list) - if(..()) - return + if(..()) + return - if( href_list["close"] ) - usr << browse(null, "window=turbine") - usr.machine = null - return + if( href_list["close"] ) + usr << browse(null, "window=turbine") + usr.machine = null + return - else if( href_list["str"] ) - compressor.starter = !compressor.starter + 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) + spawn(0) + for(var/mob/M in viewers(1, src)) + if ((M.client && M.machine == src)) + src.interact(M) From e9e9977249f5872048a012697791884810527f2a Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Sun, 15 Dec 2013 19:23:54 +0100 Subject: [PATCH 3/5] Standarized the code further, added interact that doesn't shit the compiler --- code/modules/power/turbine.dm | 87 +++++++++++++++++------------------ 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 33d5969a6cd..97a20fd7911 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -6,8 +6,8 @@ // 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 +// 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 @@ -45,7 +45,7 @@ icon_state = "turbine" anchored = 1 density = 1 - var/opened = 0 + var/opened = 0 var/obj/machinery/compressor/compressor directwired = 1 var/turf/simulated/outturf @@ -85,8 +85,8 @@ // 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 @@ -101,9 +101,9 @@ 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) @@ -134,8 +134,8 @@ 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. +// 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 @@ -144,7 +144,7 @@ /obj/machinery/power/turbine/New() ..() -// The outlet is pointed at the direction of the turbine component +// The outlet is pointed at the direction of the turbine component outturf = get_step(src, dir) @@ -179,18 +179,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 - + + // 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) @@ -206,14 +206,8 @@ if(lastgen > 100) overlays += image('icons/obj/pipes.dmi', "turb-o", FLY_LAYER) + updateDialog() - for(var/mob/M in viewers(1, src)) - if ((M.client && M.machine == src)) - src.interact(M) - AutoUpdateAI(src) - - -// AI can't use it! /obj/machinery/power/turbine/attack_ai(mob/user) @@ -222,34 +216,39 @@ interact(user) -// Only non-AI mobs (This is a way to get over a duplicate declaration error! Thanks Metacide!) - /obj/machinery/power/turbine/attack_hand(mob/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") + if(stat & (BROKEN|NOPOWER)) return - user.machine = src + interact(user) - var/t = "Gas Turbine Generator
"
+/obj/machinery/power/turbine/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.set_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(..()) @@ -260,13 +259,11 @@ usr.machine = null return - else if( href_list["str"] ) + 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) + updateDialog() @@ -285,7 +282,7 @@ for(var/obj/machinery/compressor/C in world) if(id == C.comp_id) compressor = C - + /obj/machinery/computer/turbine_computer/attackby(I as obj, user as mob) if(istype(I, /obj/item/weapon/screwdriver)) @@ -330,7 +327,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
- \n
View + \n
View \n
Close \n
\n"} From e30da6f45879e8eb81246b5f38e4ab8539c902f1 Mon Sep 17 00:00:00 2001 From: EuroNumbers Date: Sun, 15 Dec 2013 21:56:08 +0100 Subject: [PATCH 4/5] Further code standardization --- code/modules/power/turbine.dm | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 97a20fd7911..626256f1fab 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -209,20 +209,10 @@ updateDialog() -/obj/machinery/power/turbine/attack_ai(mob/user) - - if(stat & (BROKEN|NOPOWER)) - return - - interact(user) - /obj/machinery/power/turbine/attack_hand(mob/user) - add_fingerprint(user) - - if(stat & (BROKEN|NOPOWER)) + if(..()) return - interact(user) /obj/machinery/power/turbine/interact(mob/user) From 7513625c48100d506664078fa1d1ae67ce08255f Mon Sep 17 00:00:00 2001 From: KazeEspada Date: Sun, 15 Dec 2013 17:38:23 -0700 Subject: [PATCH 5/5] fixes a rare runtime that occurs when the turbine couldn't find a compressor. Brings the code up to current standards. Removes the view function from the computer. Its rather obsolete in the days of telescreens. --- code/modules/power/turbine.dm | 139 ++++++++++++---------------------- 1 file changed, 49 insertions(+), 90 deletions(-) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 97a20fd7911..bd61fd339d7 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -38,6 +38,7 @@ var/capacity = 1e6 var/comp_id = 0 + /obj/machinery/power/turbine name = "gas turbine generator" desc = "A gas turbine used for backup power generation." @@ -171,14 +172,15 @@ /obj/machinery/power/turbine/process() - if(!compressor.starter) - return - overlays.Cut() + if(stat & BROKEN) return if(!compressor) stat |= BROKEN return + if(!compressor.starter) + return + overlays.Cut() // 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 @@ -208,61 +210,52 @@ updateDialog() - -/obj/machinery/power/turbine/attack_ai(mob/user) - - if(stat & (BROKEN|NOPOWER)) - return - - interact(user) - /obj/machinery/power/turbine/attack_hand(mob/user) - add_fingerprint(user) - - if(stat & (BROKEN|NOPOWER)) + if(..()) return interact(user) + + /obj/machinery/power/turbine/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") - return - - user.set_machine(src) - - var/t = "Gas Turbine Generator
"
-
-		t += "Generated power : [round(lastgen)] W

" - - t += "Turbine: [round(compressor.rpm)] RPM
" - - t += "Starter: [ compressor.starter ? "Off On" : "Off On"]" - - t += "

Close" - - t += "
" - user << browse(t, "window=turbine") - onclose(user, "turbine") - + if ( (get_dist(src, user) > 1 ) || (stat & (NOPOWER|BROKEN)) && (!istype(user, /mob/living/silicon/ai)) ) + user.unset_machine(src) + user << browse(null, "window=turbine") return + var/t = "Gas Turbine Generator
"
+
+	t += "Generated power : [round(lastgen)] W

" + + t += "Turbine: [round(compressor.rpm)] RPM
" + + t += "Starter: [ compressor.starter ? "Off On" : "Off On"]" + + t += "

Close" + + t += "
" + var/datum/browser/popup = new(user, "turbine", name) + popup.set_content(t) + popup.open() + + return + /obj/machinery/power/turbine/Topic(href, href_list) if(..()) return if( href_list["close"] ) usr << browse(null, "window=turbine") - usr.machine = null + usr.unset_machine(src) return else if( href_list["str"] ) - compressor.starter = !compressor.starter + if(compressor) + compressor.starter = !compressor.starter - spawn(0) updateDialog() @@ -283,79 +276,45 @@ if(id == C.comp_id) compressor = C - -/obj/machinery/computer/turbine_computer/attackby(I as obj, user as mob) - if(istype(I, /obj/item/weapon/screwdriver)) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - if(do_after(user, 20)) - if (src.stat & BROKEN) - user << "\blue The broken glass falls out." - var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc ) - new /obj/item/weapon/shard( src.loc ) - var/obj/item/weapon/circuitboard/turbine_control/M = new /obj/item/weapon/circuitboard/turbine_control( A ) - for (var/obj/C in src) - C.loc = src.loc - M.id = src.id - A.circuit = M - A.state = 3 - A.icon_state = "3" - A.anchored = 1 - del(src) - else - user << "\blue You disconnect the monitor." - var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc ) - var/obj/item/weapon/circuitboard/turbine_control/M = new /obj/item/weapon/circuitboard/turbine_control( A ) - for (var/obj/C in src) - C.loc = src.loc - M.id = src.id - A.circuit = M - A.state = 4 - A.icon_state = "4" - A.anchored = 1 - del(src) - else - src.attack_hand(user) - return - /obj/machinery/computer/turbine_computer/attack_hand(var/mob/user as mob) - user.machine = src + if(..()) + return + + interact(user) + +/obj/machinery/computer/turbine_computer/interact(mob/user) + var/dat - if(src.compressor) + if(compressor) dat += {"
Gas turbine remote control system
\nTurbine status: [ src.compressor.starter ? "Off On" : "Off On"] \n
\nTurbine speed: [src.compressor.rpm]rpm
\nPower currently being generated: [src.compressor.turbine.lastgen]W
\nInternal gas temperature: [src.compressor.gas_contained.temperature]K
- \n
View \n
Close \n
\n"} else dat += "\redNo compatible attached compressor found." - user << browse(dat, "window=computer;size=400x500") - onclose(user, "computer") + var/datum/browser/popup = new(user, "turbinecomputer", name) + popup.set_content(dat) + popup.open() return - - /obj/machinery/computer/turbine_computer/Topic(href, href_list) if(..()) return - if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon))) - usr.machine = src - if( href_list["view"] ) - usr.client.eye = src.compressor - else if( href_list["str"] ) - src.compressor.starter = !src.compressor.starter - else if( href_list["close"] ) - usr << browse(null, "window=computer") - usr.machine = null - return + else if( href_list["str"] ) + if(compressor) + compressor.starter = !compressor.starter + else if( href_list["close"] ) + usr << browse(null, "window=turbinecomputer") + usr.unset_machine(src) + return - src.add_fingerprint(usr) src.updateUsrDialog() return