Jump to content

Determining building tiers in a mod?


Recommended Posts

It may be better to ask "how do I determine data from the persistent file/game state in my mod?",but that's more general than what I need right now.

In my mod All Y'All, there is a minor bug in that you can run a surface sample if you have a Kerbal in a command chair but have not upgraded the R&D Building to the 2nd tier. I'd like to plug this hole by checking - whenever a surface sample would be run - the tier level of the building to make sure the Kerbal should be capable of it.

I've done a few searches but my Fu doesn't seem strong tonight. I can't seem to find ANY information about modding and the building tiers at all.

Anybody have an idea here, or a link to something that could help?

Link to comment
Share on other sites

Some code here from Contract Configurator:

            int level = (int)Math.Round(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) *
                ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility)) + 1;
            return level == 0 && contract != null && contract.ContractState == Contracts.Contract.State.Active ||
                level >= minLevel && level <= maxLevel;

Note that level is between 1 and 3 inclusive.  I forget why it checks for level == 0 - it might be in some scenes the ScenarioUpgradeableFacilities isn't loaded and so it always returns zero, so make sure to test it in all scenes you need it in.

Link to comment
Share on other sites

1 hour ago, nightingale said:

GetFacilityLevel

I think I tried every name I could think of, EXCEPT "facility" :D

ScenarioUpgradeableFacilities.GetFacilityLevel() is exactly what I needed. You are partially responsible for version 0.4 of my mod :)

Edited by 5thHorseman
Link to comment
Share on other sites

3 hours ago, 5thHorseman said:

I think I tried every name I could think of, EXCEPT "facility" :D

ScenarioUpgradeableFacilities.GetFacilityLevel() is exactly what I needed. You are partially responsible for version 0.4 of my mod :)

You could say that he... *sunglasses* ...facilitated it? :D

 

I'm sorry, I'm sorry, I'll show myself out...!

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...