"
- var/t = {"Solar Generator Control
-Generated power : [round(lastgen)] W
-Station Rotational Period: [60/abs(sun.rate)] minutes
-Station Rotational Direction: [sun.rate<0 ? "CCW" : "CW"]
-Star Orientation: [sun.angle]° ([angle2text(sun.angle)])
-Array Orientation: [rate_control(src,"cdir","[cdir]°",1,10,60)] ([angle2text(cdir)])
-
-Tracking:"}
- // END AUTOFIX
- switch(track)
- if(0)
- t += "Off Manual Automatic
"
- if(1)
- t += "Off Manual Automatic
"
- if(2)
- t += "Off Manual Automatic
"
-
-
- // AUTOFIXED BY fix_string_idiocy.py
- // C:\Users\Rob\Documents\Projects\vgstation13\code\modules\power\solar.dm:423: t += "Manual Tracking Rate: [rate_control(src,"tdir","[trackrate/10]°/min ([trackdir<0 ? "CCW" : "CW"])",1,10)]
"
- t += {"Manual Tracking Rate: [rate_control(src,"tdir","[trackrate/10]°/min ([trackdir<0 ? "CCW" : "CW"])",1,10)]
-Manual Tracking Direction:"}
- // END AUTOFIX
- switch(trackdir)
- if(-1)
- t += "CW CCW
"
- if(1)
- t += "CW CCW
"
- t += "Close
"
- user << browse(t, "window=solcon")
- onclose(user, "solcon")
- return
+ if(connected_tracker) //NOTE : handled here so that we don't add trackers to the processing list
+ if(connected_tracker.powernet != powernet)
+ connected_tracker.unset_control()
+ if(track==1 && trackrate) //manual tracking and set a rotation speed
+ if(nexttime <= world.time) //every time we need to increase/decrease the angle by 1�...
+ targetdir = (targetdir + trackrate/abs(trackrate) + 360) % 360 //... do it
+ nexttime += 36000/abs(trackrate) //reset the counter for the next 1�
/obj/machinery/power/solar_control/Topic(href, href_list)
if(..())
- usr << browse(null, "window=solcon")
- usr.unset_machine()
return
- if(href_list["close"] )
- usr << browse(null, "window=solcon")
- usr.unset_machine()
- return
-
- if(href_list["dir"])
- cdir = text2num(href_list["dir"])
- set_panels(cdir)
- update_icon()
-
- if(href_list["rate control"])
+
+ if(href_list["rate_control"])
if(href_list["cdir"])
src.cdir = dd_range(0,359,(360+src.cdir+text2num(href_list["cdir"]))%360)
+ src.targetdir = src.cdir
+ if(track == 2) //manual update, so losing auto-tracking
+ track = 0
spawn(1)
set_panels(cdir)
- update_icon()
if(href_list["tdir"])
- src.trackrate = dd_range(0,360,src.trackrate+text2num(href_list["tdir"]))
- if(src.trackrate) nexttime = world.time + 6000/trackrate
+ src.trackrate = dd_range(-7200,7200,src.trackrate+text2num(href_list["tdir"]))
+ if(src.trackrate) nexttime = world.time + 36000/abs(trackrate)
if(href_list["track"])
- if(src.trackrate) nexttime = world.time + 6000/trackrate
track = text2num(href_list["track"])
- if(powernet && (track == 2))
- if(!solars_list.Find(src,1,0) || !(locate(src) in solars_list) || !(src in solars_list))
- solars_list.Add(src)
- for(var/obj/machinery/power/tracker/T in get_solars_powernet())
- if(powernet.nodes[T])
- cdir = T.sun_angle
- break
+ if(track == 2)
+ if(connected_tracker)
+ connected_tracker.set_angle(sun.angle)
+ set_panels(cdir)
+ else if (track == 1) //begin manual tracking
+ src.targetdir = src.cdir
+ if(src.trackrate) nexttime = world.time + 36000/abs(trackrate)
+ set_panels(targetdir)
- if(href_list["trackdir"])
- trackdir = text2num(href_list["trackdir"])
+ if(href_list["search_connected"])
+ search_for_connected()
+ if(connected_tracker && track == 2)
+ connected_tracker.set_angle(sun.angle)
+ set_panels(cdir)
- set_panels(cdir)
- update_icon()
- src.updateUsrDialog()
return
-
+//rotates the panel to the passed angle
/obj/machinery/power/solar_control/proc/set_panels(var/cdir)
- if(!powernet) return
- for(var/obj/machinery/power/solar/S in get_solars_powernet())
- if(powernet.nodes[S])
- if(get_dist(S, src) < SOLAR_MAX_DIST)
- if(!S.control)
- S.control = src
- S.ndir = cdir
+
+ for(var/obj/machinery/power/solar/S in connected_panels)
+ S.adir = cdir //instantly rotates the panel
+ S.occlusion()//and
+ S.update_icon() //update it
+
+ update_icon()
/obj/machinery/power/solar_control/power_change()
- if(powered())
- stat &= ~NOPOWER
- update_icon()
- else
- spawn(rand(0, 15))
- stat |= NOPOWER
- update_icon()
+ ..()
+ update_icon()
/obj/machinery/power/solar_control/proc/broken()
@@ -511,25 +499,16 @@ Manual Tracking Direction:"}
update_icon()
-/obj/machinery/power/solar_control/meteorhit()
- broken()
- return
-
-
-/obj/machinery/power/solar_control/ex_act(severity)
- switch(severity)
- if(1.0)
- //SN src = null
- qdel(src)
- return
- if(2.0)
- if (prob(50))
- broken()
- if(3.0)
- if (prob(25))
- broken()
- return
-
+/obj/machinery/power/solar_control/ex_act(severity, target)
+ ..()
+ if(!gc_destroyed)
+ switch(severity)
+ if(2)
+ if(prob(50))
+ broken()
+ if(3)
+ if(prob(25))
+ broken()
/obj/machinery/power/solar_control/blob_act()
if (prob(75))
@@ -543,4 +522,4 @@ Manual Tracking Direction:"}
/obj/item/weapon/paper/solar
name = "paper- 'Going green! Setup your own solar array instructions.'"
- info = "Welcome
At greencorps we love the environment, and space. With this package you are able to help mother nature and produce energy without any usage of fossil fuel or plasma! Singularity energy is dangerous while solar energy is safe, which is why it's better. Now here is how you setup your own solar array.
You can make a solar panel by wrenching the solar assembly onto a cable node. Adding a glass panel, reinforced or regular glass will do, will finish the construction of your solar panel. It is that easy!.
Now after setting up 19 more of these solar panels you will want to create a solar tracker to keep track of our mother nature's gift, the sun. These are the same steps as before except you insert the tracker equipment circuit into the assembly before performing the final step of adding the glass. You now have a tracker! Now the last step is to add a computer to calculate the sun's movements and to send commands to the solar panels to change direction with the sun. Setting up the solar computer is the same as setting up any computer, so you should have no trouble in doing that. You do need to put a wire node under the computer, and the wire needs to be connected to the tracker.
Congratulations, you should have a working solar array. If you are having trouble, here are some tips. Make sure all solar equipment are on a cable node, even the computer. You can always deconstruct your creations if you make a mistake.
That's all to it, be safe, be green!
"
+ info = "Welcome
At greencorps we love the environment, and space. With this package you are able to help mother nature and produce energy without any usage of fossil fuel or plasma! Singularity energy is dangerous while solar energy is safe, which is why it's better. Now here is how you setup your own solar array.
You can make a solar panel by wrenching the solar assembly onto a cable node. Adding a glass panel, reinforced or regular glass will do, will finish the construction of your solar panel. It is that easy!
Now after setting up 19 more of these solar panels you will want to create a solar tracker to keep track of our mother nature's gift, the sun. These are the same steps as before except you insert the tracker equipment circuit into the assembly before performing the final step of adding the glass. You now have a tracker! Now the last step is to add a computer to calculate the sun's movements and to send commands to the solar panels to change direction with the sun. Setting up the solar computer is the same as setting up any computer, so you should have no trouble in doing that. You do need to put a wire node under the computer, and the wire needs to be connected to the tracker.
Congratulations, you should have a working solar array. If you are having trouble, here are some tips. Make sure all solar equipment are on a cable node, even the computer. You can always deconstruct your creations if you make a mistake.
That's all to it, be safe, be green!
"
\ No newline at end of file
diff --git a/code/modules/power/tracker.dm b/code/modules/power/tracker.dm
index d35cf81ed45..5cf341f9fbb 100644
--- a/code/modules/power/tracker.dm
+++ b/code/modules/power/tracker.dm
@@ -10,78 +10,70 @@
icon_state = "tracker"
anchored = 1
density = 1
- directwired = 1
use_power = 0
+ var/id = 0
var/sun_angle = 0 // sun angle as set by sun datum
+ var/obj/machinery/power/solar_control/control = null
/obj/machinery/power/tracker/New(var/turf/loc, var/obj/item/solar_assembly/S)
..(loc)
+ Make(S)
+ connect_to_network()
+
+/obj/machinery/power/tracker/Destroy()
+ unset_control() //remove from control computer
+ ..()
+
+//set the control of the tracker to a given computer if closer than SOLAR_MAX_DIST
+/obj/machinery/power/tracker/proc/set_control(var/obj/machinery/power/solar_control/SC)
+ if(!SC || (get_dist(src, SC) > SOLAR_MAX_DIST))
+ return 0
+ control = SC
+ SC.connected_tracker = src
+ return 1
+
+//set the control of the tracker to null and removes it from the previous control computer if needed
+/obj/machinery/power/tracker/proc/unset_control()
+ if(control)
+ control.connected_tracker = null
+ control = null
+
+/obj/machinery/power/tracker/proc/Make(var/obj/item/solar_assembly/S)
if(!S)
S = new /obj/item/solar_assembly(src)
S.glass_type = /obj/item/stack/sheet/glass
S.tracker = 1
S.anchored = 1
S.loc = src
- connect_to_network()
+ update_icon()
-/obj/machinery/power/tracker/disconnect_from_network()
- ..()
- solars_list.Remove(src)
-
-/obj/machinery/power/tracker/connect_to_network()
- ..()
- solars_list.Add(src)
-
-// called by datum/sun/calc_position() as sun's angle changes
+//updates the tracker icon and the facing angle for the control computer
/obj/machinery/power/tracker/proc/set_angle(var/angle)
sun_angle = angle
//set icon dir to show sun illumination
dir = turn(NORTH, -angle - 22.5) // 22.5 deg bias ensures, e.g. 67.5-112.5 is EAST
- // check we can draw power
- if(stat & NOPOWER)
- return
-
- // find all solar controls and update them
- // currently, just update all controllers in world
- // ***TODO: better communication system using network
- if(powernet)
- for(var/obj/machinery/power/solar_control/C in get_solars_powernet())
- if(powernet.nodes[C])
- if(get_dist(C, src) < SOLAR_MAX_DIST)
- C.tracker_update(angle)
-
+ if(powernet && (powernet == control.powernet)) //update if we're still in the same powernet
+ control.cdir = angle
/obj/machinery/power/tracker/attackby(var/obj/item/weapon/W, var/mob/user)
- if(iscrowbar(W))
- playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
+ if(istype(W, /obj/item/weapon/crowbar))
+ playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
+ user.visible_message("[user] begins to take the glass off the solar tracker.")
if(do_after(user, 50))
var/obj/item/solar_assembly/S = locate() in src
if(S)
S.loc = src.loc
S.give_glass()
- playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)
+ playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message("[user] takes the glass off the tracker.")
- del(src)
+ qdel(src)
return
..()
-// timed process
-// make sure we can draw power from the powernet
-/obj/machinery/power/tracker/process()
-
- var/avail = surplus()
-
- if(avail > 500)
- add_load(500)
- stat &= ~NOPOWER
- else
- stat |= NOPOWER
-
-
// Tracker Electronic
/obj/item/weapon/tracker_electronics
diff --git a/nano/templates/solar_control.tmpl b/nano/templates/solar_control.tmpl
new file mode 100644
index 00000000000..17c3566bece
--- /dev/null
+++ b/nano/templates/solar_control.tmpl
@@ -0,0 +1,96 @@
+
+
+Status:
+
+
+
+ Generated power:
+
+
+ {{:data.generated}} W
+
+
+
+
+
+ Orientation:
+
+
+
+ {{:data.angle}}° ({{:data.direction}})
+
+
+ {{:helper.link('15°', 'minus', {'rate_control' : '1', 'cdir' : '-15'})}}
+ {{:helper.link('1°', 'minus', {'rate_control' : '1', 'cdir' : '-1'})}}
+ {{:helper.link('1°', 'plus', {'rate_control' : '1', 'cdir' : '1'})}}
+ {{:helper.link('15°', 'plus', {'rate_control' : '1', 'cdir' : '15'})}}
+
+
+
+Tracking:
+
+
+
+ Tracker status:
+
+
+ {{:helper.link('Off', 'close', {'track' : '0'}, (data.tracking_state == 0) ? 'selected' : '')}}
+ {{:helper.link('Timed', 'clock', {'track' : '1'}, (data.tracking_state == 1) ? 'selected' : '')}}
+ {{if data.connected_tracker}}
+ {{:helper.link('Auto', 'signal-diag', {'track' : '2'}, (data.tracking_state == 2) ? 'selected' : '')}}
+ {{else}}
+ {{:helper.link('Auto', 'signal-diag', null, 'disabled')}}
+ {{/if}}
+
+
+
+
+ Tracking rate:
+
+
+
+ {{:data.tracking_rate}} deg/h ({{:data.rotating_way}})
+
+
+
+
+ {{:helper.link('180°', 'minus', {'rate_control' : '1', 'tdir' : '-180'})}}
+ {{:helper.link('30°', 'minus', {'rate_control' : '1', 'tdir' : '-30'})}}
+ {{:helper.link('1°', 'minus', {'rate_control' : '1', 'tdir' : '-1'})}}
+ {{:helper.link('1°', 'plus', {'rate_control' : '1', 'tdir' : '1'})}}
+ {{:helper.link('30°', 'plus', {'rate_control' : '1', 'tdir' : '30'})}}
+ {{:helper.link('180°', 'plus', {'rate_control' : '1', 'tdir' : '180'})}}
+
+
+
+Connected devices :
+
+
+
+ Solars panels:
+
+
+ {{:data.connected_panels}} connected
+
+
+
+
+
+ Solar tracker:
+
+
+
+ {{if data.connected_tracker}}
+ Found
+ {{else}}
+ Not found
+ {{/if}}
+
+
+
+
+ {{:helper.link('Search for devices', 'refresh', {'search_connected' : '1'})}}
+