ok Eric ...
here's the routine.
I have a few questions ...
as I don't know what all these variables do ...
and what others one might also have to consider ...
~~~
' gives vegs their energy meal
Public Sub feedvegs(totnrg As Long, totv As Integer)
Dim n As node
Dim t As Integer
Dim tok As Single
Dim depth As Long
Dim daymod As Single
Dim Energy As Single
Dim body As Single
Dim FeedThisCycle As Boolean
Dim OverrideDayNight As Boolean
Const Constant As Single = 0.00000005859375
Dim temp As Single
FeedThisCycle = True
OverrideDayNight = False
ok. the following two portions of code are used to 'force' the sun up or down.
SimOpts.SunUp and SimOpts.SunDown are set to True (non-zero)
by checking the boxes for the upper and lower thresholds, yes?
If SimOpts.SunUp Then
If TotalSimEnergyDisplayed < SimOpts.SunUpThreshold Then
FeedThisCycle = True ' Sim Energy has fallen below the threshold. Let the sun shine!
OverrideDayNight = True
End If
End If
If SimOpts.SunDown Then
If TotalSimEnergyDisplayed > SimOpts.SunDownThreshold Then
FeedThisCycle = False ' Sim energy has exceeded our threshold. Let the sun set!
OverrideDayNight = True
End If
End If
now what variable,if any, does unchecking the box "Enable Day/Night" set?
SimOpts.DayNight
![Huh? ???](http://forum.darwinbots.com/Smileys/DBClassic/huh.gif)
OverrideDayNight allows the SunUpSunDown to overide day/night cycles ...
and that you are setting from within the code.
what I am looking for is the variable that tells us the day/night cycle is checked
as disabled ... and would then allow the Thresholds to be the ONLY factor in
determining whether the sun is up/down ...
a switch that sets the sun if energy goes above the upper threshold ...
and KEEPs is set until the energy falls below the lower threshold ...
where it is reset to have the sun UP until energy once again rises
above the upper threshold ...
and bypasses the day/night cycles if they are disabled.
the routine below, it seems to me ...
is the day/night cycle is enabled ... ie SimOpts.DayNight true ...
and we are between the thresholds ... Not OverrideDayNight
and therefore it goes back to the day/night clock.
If SimOpts.DayNight And Not OverrideDayNight Then
' Well, we are neither above nor below the threshold or we arn't using thresholds so
'lets see if it's time to rise and shine
SimOpts.DayNightCycleCounter = SimOpts.DayNightCycleCounter + 1
If SimOpts.DayNightCycleCounter > SimOpts.CycleLength Then
SimOpts.Daytime = Not SimOpts.Daytime
SimOpts.DayNightCycleCounter = 0
End If
If SimOpts.Daytime Then
FeedThisCycle = True
Else
FeedThisCycle = False
End If
End If
so ... couldn't we then use a routine here ...
or perhaps before the day/night cycle one above ...
to allow the thresholds alone to control the sun,
when the day/night cycle is disabled?
and to then skip the above routine.
ie ... along the lines of:
(I'm sure I have this messed up but you get the idea ...
with day/night disabled ...
only the thresholds control the sun ....
each switching it on or off ...
until the other resets it.
if Not SimOpts.DayNight Then
If SimOpts.SunUp Then
If TotalSimEnergyDisplayed < SimOpts.SunUpThreshold Then
FeedThisCycle = True ' Sim Energy has fallen below the threshold. Let the sun shine!
End If
End If
If SimOpts.SunDown Then
If TotalSimEnergyDisplayed > SimOpts.SunDownThreshold Then
FeedThisCycle = False ' Sim energy has exceeded our threshold. Let the sun set!
End If
End If
End If
just blindly feelin my way along