Jump to content

Mutually exclusive Snacks processors [With Module Manager patch]


Okhin

Recommended Posts

Hi,

I'm playing around with Snacks, and I'm trying to get a new resource (Sleep in this case) working. I do have a configuration which works, and I can switch modules in Night mode. And it's cool.

However, I'd like to turn off some SnacksProcessor when activating Sleep Mode (I doubt you can sleep when people are running the Entertainment complex next to you).

And I can't seems to find a way to do that. The Snacks wiki have an API call for SnacksDisqualifier, but I do not see where I can check if a SnacksConverter is running. I guess, that I can probably try to get all the SnacksProcessor from the part I'm patching, but I do not find stuff such as EVENTS associated to a SnackConverter starts or stop, or a way to check if its running.

Below you'll find what I have now as code. I do not mind adding other mods as dependencies, but I've got hope that there's a precondition / outcome somewhere I'm missing.

Thanks for the help :)
 

 //This node is used to display a description window describing the new resource being tracked. It's only shown once per game.
 SNACKS_RESOURCE_INTRO
 {
         name = Sleep
 }
 @SNACKS_RESOURCE_INTRO[Sleep]:FOR[SnacksSleep]
 {
         title = Sleep!
     description = This addon adds Sleep management. If you work your kerbals too much, they'll end up exhausted. And you do not want that. So you can send them to have good night sleep. Even if it's perpetually  night up there in space. Or day. Whatev'. That's why some modules embed a Migh simulator, which ables Kerbals to get in their bunk and have some sleep in a nice and warm red light. Of course, Entertainment AND  sleep is not really compatible.<br>If your kerbals didn't slept well, they'll be more stressed and, eventually, be exhausted. At which point they'll faint to have a short nap, which will not really make them r ecover sleep. They just fell asleep whatever they were doing.
 }
 
 //This resource is added to a kerbal<92>s crew roster entry. These aren<92>t resources in the traditional sense; they are characteristics of the kerbal itself.
 SNACKS_ROSTER_RESOURCE
 {
         resourceName = Sleep
 
         displayName = Hours without sleep
 
         //Flag to indicate whether or not to show the resource in the snapshot window. Default: true
         showInSnapshot = true
 
         //A customized format for the status. The following parameters are all optional:
         //<<percent>>: amount divided by maxAmount.
         //<<amount>>: Current amount of roster resource.
         //<<maxAmount>>: Max amount of roster resource.
         statusFormat = <<amount>> hours (<<maxAmount>> max)
 
     //Amount to add
         amount = 0
 
         //Max amount possible.
         maxAmount = 4
 
         //Amount to add when the kerbal levels up
         experienceBonusAmount = 0
 
         //Max amount to add when the kerbal levels up
         experienceBonusMaxAmount = 0.2
 }
 
 //The OnStrikePenalty removes skill effects from kerbals that experience the penalty, but because more than one event and part and such can also remove crew skills,
 //they all need to be coordinated via conditions. The SKILL_LOSS_CONDITION node defines the conditions that remove a kerbal's skill effects. If a kerbal has at least
 //one condition that's on this list, then skill effects will be removed. If the kerbals have none of the conditions on the list then they regain use of their skills.
 SKILL_LOSS_CONDITION
 {
         name = Exhausted
 }
 
 SKILL_LOSS_CONDITION
 {

         name = Sleeping
 }
 
 // Sleep processor
 SNACKS_RESOURCE_PROCESSOR
 {
     name = Sleep!
     secondsPerCycle = 3600
 
     PRODUCED_RESOURCE
     {
         resourceName = Sleep
         amount = 1
         showInSnapshot = true
         failureResultAppliesOutcomes = true
     }
 
     OUTCOME
     {
         // If we're pushing it a Kerbal might faint for half an hour after the third hour without seep
         name = FaintPenalty
         canBeRandom = true
         playerMessage = fell asleep due to exhaustion!
         resourceName = Sleep
         cyclesBeforeFainting = 3
         faintDurationSeconds = 1800
     }
 
     OUTCOME
     {
         // We're exhausted if we can't add sleep
         name = SetCondition
         conditionSummary = Exhausted
         playerMessage = <<KerbalName>> worked themself to exhaustion!
     }
 
     OUTCOME:NEEDS[SnacksStress]
     {
         name = ProduceResource
         resourceName = Stress
         amount = 0.1 // We're checking every hour, so let's not go crazy
     }
 }
 
 //Kerbals back at KSC recover from Sleep deprivation and exhaustion
 SNACKS_EVENT
 {
         name = kscDorm
         category = categoryPostProcessCycle
         affectedKerbals = affectsAllAvailable
         daysBetweenChecks = 1
 
         OUTCOME

         {
                 name  = ConsumeResource
                 resourceName = Sleep
                 amount = 4
         }
 }
 
 //Just being a badass lets you needing less sleep
 SNACKS_EVENT
 {
         name = bada55
         eventCategory = categoryPostProcessCycle
         kerbalsAffected = affectsAllAssigned
         secondsBetweenChecks = 3600
 
         PRECONDITION
         {
                 name = CheckBadass
 
                 //You can check for absense of badass too. Default value is true.
                 mustExist = true
         }
 
         OUTCOME
         {
                 name = ConsumeResource
                 resourceName = Sleep
                 amount = 0.25
         }
 }
 
 // These parts help kerbals sleep
 @PART[MK!CrewCabin,crewCabin,mk2CrewCabin,mk3CrewCabin]
 {
         MODULE
         {
                 name = SnacksConverter
         ConverterName = Night Simulator
                 StartActionName = Engage Nightmode
                 StopActionName = Disengage Nightmode
                 AutoShutdown = false
                 GeneratesHeat = false
                 UseSpecialistBonus = false
                 
                 //No need for a crew to keep things quiet
                 minimumCrew = 0
 
                 //Connection back home required to receive entertainment.
                 requiresHomeConnection = false
 
                 //This condition is set whenever the kerbal enters the part and the converter is active, and
                 //when the converter is started. Since it's registered as a SKILL_LOSS_CONDITION, the kerbals will lose their
                 //skills while the converter is running.

                 conditionSummary = Sleeping
 
                 //Works like an INPUT_RESOURCE except:
                 // It applies to individual kerbals.
                 // You can specify an AmountPerDay or AmountPerSecond.
                 ROSTER_INPUT_RESOURCE
                 {
                         ResourceName = Sleep
 
                         //AmountPerDay will be translated into: AmountPerDay / seconds per homeworld day
                         //This will override AmountPerSecond if it is defined in the node.
                         AmountPerSecond = 0.00027 // 1/3600, one hour of sleep remove one hour of sleep deprivation
                 }
 
         // Sleeping reduces stress. Less than entertainment but still
         ROSTER_INPUT_RESOURCE:NEEDS[SnacksStress]
         {
             ResourceName = Stress
             AmountPerDay = 1
         }

    }
}

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...