File information

Last updated

Original upload

Created by

Tenhats

Uploaded by

tenhats

Virus scan

Safe to use

About this mod

Most mods that add custom crops aren't fully functional They wont generate resources for the workbench. This tutorial will show you how to do it the right way.

Permissions and credits
Changelogs
Intro
A fully functional crop, such as all those in vanilla or a few of my own mods, is one that will passively generate its resources for the workshop inventory when a settler is assigned.

Most mods that add new crops are not fully functional. The player can typically hand pick the resource, but the resource will not be passively generated on its own during workshop production cycles.

This tutorial will walk you through how to use the provided files to make your mod's crops fully functional.
We will make a fully functional silt bean by the end of this tutorial, though the technique can be used for anything, including non-foods.
I go into a lot of detail but it's really quite a quick process once you understand it.

Some images have been included showing certain steps in action.


Tools
FO4Edit - a basic working knowledge is assumed
Notepad++ - optional, but helpful
PapyrusPlusPlus - optional, but helpful. Don't worry, you aren't going to be writing any scripts, just renaming the ones I've provided.


Section 1: Function Import  This section walks you through how to import these functions into your mod.
Spoiler:  
Show

  • Download the provided file and install it via your mod manager
  • Load both OCsWorkingCropsTutorial and MyWorkingCrops via FO4Edit

  • Go to OCsWorkingCropsTutorial and select ResourceLvledListType1 in the Leveled Item tab. Use "Copy as new record into..." to duplicate this into MyWorkingCrops.
  • Repeat Step 3 for both ResourceRatingType1 in the Actor Value Information tab and WorkshopQuestInjector in the quest tab.
  • Staying within OCsWorkingCropsTutorial select FloraGourdVine01 and FloraSiltBean01 and use "Copy as Override into..." MyWorkingCrops


Section 2: Quest Setup
Spoiler:  
Show

  • Everything from here on out will be done within MyWorkingCrops

  • Go to ResourceLvlListType1 and rename it to ResourceLvledListSiltBean
  • Go to ResourceLvledListSiltBean and replace NULL - Null Reference [00000000] with SiltBean "Silt Bean" [ALCH:001BE2AB]
  • Go to ResourceRatingType1 and rename it to ResourceRatingSiltBean

  • Go to WorkshopQuestInjector. Go to Script > ScriptName OCs_WorkshopQuestInjectorPart1 > Property > PropertyName NewResourceType > Value > Array of Struct > Struct 0
  • At Struct 0 go to foodObject > Value > FormID > NULL - Null Reference [00000000]. Replace NULL - Null Reference with ResourceLvledListSiltBean
  • Remaining in Struct 0 go to resourceValue > Value > FormID > NULL - Null Reference [00000000]. Replace NULL - Null Reference with ResourceRatingSiltBean

  • Remaining in WorkshopQuestInjector go to Script > ScriptName OCs_WorkshopQuestInjectorPart2 > Property > PropertyName NewResourceType > Value > Array of Struct > Struct 0
  • At Struct 0 go to resourceValue > Value > FormID > NULL - Null Reference [00000000]. Replace NULL - Null Reference with ResourceRatingSiltBean.

  • Steps 5 through 7 linked the items in ResourceLvledListSiltBean to the rating ResourceRatingSiltBean. Any time ResourceRatingSiltBean adds up to 1 within a settlement during a production cycle ResourceLvledListSiltBean will be called upon once to generate its contents. For example, 6 items with a rating of .5 each will generate 3 silt beans in our case here.
  • Steps 8 and 9 ensure the rating is recalculated each workshop cycle to account for removed crops or reassigned settlers.
    
    


Section 3: A Functional Bean
Spoiler:  
Show

  • Select FloraSiltBean01, Use "Copy as new record into..." MyWorkingCrops.
  • Rename this duplicate to Workshop_FloraSiltBean01

  • Select both FloraGourdVine01 and Workshop_FloraSiltBean01 at the same time
  • Drag "VMAD - Virtual Machine Adapter" from FloraGourdVine01 into Workshop_FloraSiltBean01
  • Repeat Step 4 but with "PRPS - Properties (sorted)" and "KWDA - Keywords (sorted)"
  • Go to the WorkshopRatingFoodTypeGourd property within your silt bean, replace it with ResourceRatingSiltBean

    You now have a fully functional silt bean plant for you settlement. You'll need to hook it up to a workshop recipe to plant it, but everything about that is normal so I'll trust you to know how to do that.
    


Section 4: Iterating or how to add as many new crops as you want
Spoiler:  
Show

  • Go to WorkshopQuestInjector. Go to Script > ScriptName OCs_WorkshopQuestInjectorPart1 > Property > PropertyName
    NewResourceType > Value > Array of Struct
  • At "Array of Struct" right click and hit "add".
  • Drag Struct 0 into Struct 1

  • Go to Script > ScriptName OCs_WorkshopQuestInjectorPart2 > Property > PropertyName NewResourceType > Value > Array of Struct
  • At "Array of Struct" right click and hit "add", drag Struct 0 into Struct 1 again

  • From here simply repeat all of "Section 2, Quest Setup" but using a new resource, perhaps Brain Fungus, and using Struct 1 instead of Struct 0 for both OCs_WorkshopQuestInjectorPart1 and OCs_WorkshopQuestInjectorPart2.
  • For a third crop do this again but with Struct 2, and so on.




Section 5: Testing
Spoiler:  
Show

The goal of this section is to make sure that your object generates its resources after a production cycle.
  • Make a backup save
  • Travel to an empty settlement
  • Clear the settlement's inventory
  • Type the following commands into the console: "tgm" "player.placeatme 20593." This will spawn a settler and put you in god mode.
  • Place a water pump, a bed, about 6 of the objects you want to test, and a turret.
  • Assign the settler to the settlement you're in
  • Assign the settler to the test objects
  • Travel far away
  • Sleep in game for 48 hours
  • The game now needs to sit for a few minutes unpaused for the production cycle to trigger. You can do something else in the game if you like, or just get up and make yourself some food irl. The exact time is unknown, but in my experience it's less than 5 minutes. The happiness changing is generally a good sign that a production cycle has occurred.
  • Return to the settlement, check its Aid tab. I'll describe the results below.

  • If there is purified water and the test resource in the workbench then you've got a fully functional resource generating object.
  • If there is only purified water in the workbench then something went wrong and the object isn't functioning.
  • If there's no food or water in the workbench then a production cycle hasn't occurred. Travel away, sleep in game for a day, and wait irl with the game unpaused some more.



From here you can publish, just make sure you ship a folder called Scripts containing OCs_WorkshopQuestInjectorPart1 and OCs_WorkshopQuestInjectorPart2 alongside your esp. However there's still one more thing you can do to maximize compatibility.


Section 6: Maximum Compatibility an optional section
Spoiler:  
Show

  • Go to Data\Scripts\Source\User
  • Locate OCs_WorkshopQuestInjectorPart1 and OCs_WorkshopQuestInjectorPart2
  • Change their names to something specific to you.

  • Open both scripts up with Notepad++ with the PapyrusPlusPlus plugin installed
  • At the top where "ScriptName OCs_WorkshopQuestInjectorPart1 extends Quest" is written change OCs_WorkshopQuestInjectorPart1 to your new name.
  • Press ctrl-shift-c to compile
  • Repeat steps 5 and 6 for OCs_WorkshopQuestInjectorPart2

  • Open MyWorkingCrops and go to WorkshopQuestInjector and change the ScriptName field to match the new name you chose. Make sure to do this for both Part1 and Part2.
  • Ship the esp alongside these scripts instead of the originals.
    



FAQ
Spoiler:  
Show

Q: Can I put more than 1 entry into the leveled list?
A: Yes. The leveled lists here follow all the rules of normal leveled lists and can be as complex as you like, so long as they're calling upon inventory items in the end.

Q: Does the value for Food [AVIF:00000331] need to match my ResourceRating value?
A: They don't need to match, you can have .5 Food alongside 2 ResourceRating if you like. This will cause your ResourceLvledList to be called twice upon a production cycle with just 1 of these objects planted. You can even give 1 object multiple different ratings.

Q: Why do you use scripts?
A: To prevent conflicts. Without script injection we must edit WorkshopQuest directly which means any 2 mods that both do that will break the other.

Q: Do I need to credit you?
A: No, the scripts here were modified out of existing script injector packs with open perms. I'm just documenting what was already known to some.

  翻译: