Worker Defaults

This splits up the big long list of things that workers do (like find a tool, get ill, become pregnant and so on) into smaller functions so that mods can change each one individually, instead of having to overwrite the entire thing (and thus colliding with each other).

Also implements the ability to use external lists of e.g. tools, clothes, and drinks in functions (instead of hardcoded values); those lists in turn can be added on to by mods to create different sorts of tools, clothing etc that will be used by villagers just like the default ones.

This does not have any effect on its own, it’s just there to make things more flexible.

Download | How to use (FVModSync installation)

2017-04-01: No changes for 0.9.6127
2017-03-20: Updated for 0.9.6112 (pbox_worker_surviveUpdate.lua); small fix in Worker_getLightDisease.lua.

You need FVModSync 0.3.1beta or newer for anything that is using the lists; 0.4beta is required for game version 0.9.6109 and up.

The name of the main folder (“_defaults”, with underscore) should not be changed; the defaults need to load before anything else.


Functions:

  • pbox_worker_surviveUpdate.lua — main function; this overrides the game’s surviveUpdate and calls the other functions in turn
  • Worker_dumpInventory
  • Worker_findBetterDress
  • Worker_findBetterTool
  • Worker_getLightDisease
  • Worker_goToSchool
  • Worker_tryGetDrunk
  • Worker_tryGetPregnant
  • Worker_tryGoToSchool
  • Worker_tryHealHeavyDisease
  • Worker_tryHealLightDisease
  • Worker_visitHospital

Do not change the functions directly. Override them with yours instead.


Lists:

  • SawmillSimple_craftRecipes
  • Worker_dressOptions
  • Worker_drinkOptions
  • Worker_toolOptions

To add stuff to these lists (those are actually lua arrays), put an identical list in (YourModFolder)/scripts/FVModSync_defaultLists/ that has your values inserted where you want them (i.e. relative to the default values).

The folder name — FVModSync_defaultLists — is what’s telling FVModSync to treat this as a default, so it needs to be named like that. FVMS will compile all default lists into one, weeding out duplicates and keeping the relative positions intact; simple lua comments in lists (lines starting with a double hyphen) will be ignored.


Example:

Default Worker_toolOptions — has the values from the game:

fv.core.Worker.toolOptions = 
{
"improve_tool",
"tool",
}

Your Worker_toolOptions:

fv.core.Worker.toolOptions = 
{
"yourname_cooltool",
"improve_tool",
}

My Worker_toolOptions:

fv.core.Worker.toolOptions = 
{
"improve_tool",
"pbox_spiffytool",
"tool",
}

Result:

fv.core.Worker.toolOptions = 
{
"yourname_cooltool",
"improve_tool",
"pbox_spiffytool",
"tool",
}

In game, villagers will now be grabbing the cool tools if there are any, then the game’s improve_tools, then the spiffytools, and when they run out of other options  they’ll resort to the game’s regular tools.

Advertisements

2 thoughts on “Worker Defaults”

  1. Not sure if it interacted badly with an autosave or what. CTD with following error:

    2017-Mar-03 23:11:16 Stop autosave animation [ForestVillage.cpp | 871]
    2017-Mar-03 23:11:19 Model [models/people_decor/school.mim] has 288 tris, aabb[(-0.163378, -0.0597083, -0.256491), (0.154925, 0.223676, -0.0320141)], bs[(-0.00422629, 0.0819839, -0.144253), 0.240839] [TriMesh.cpp | 215]
    2017-Mar-03 23:11:24 Lua Error:[string “mods/_defaults/pbox_workerDefaults/Worker_g…”]:14: attempt to index global ‘math’ (a nil value)
    [LuaObject.cpp | 145]
    2017-Mar-03 23:11:24 mods/_defaults/pbox_workerDefaults/Worker_getLightDisease.lua:14 (getLightDisease)
    {w = userdata(849431512), warmPersent = 0.968949, satietyPersent = 0.000000, disease = userdata(844362392), (*temporary) = 1.400000, (*temporary) = nilunknown, (*temporary) = “avitaminosis”, (*temporary) = unknown, (*temporary) = “attempt to index global ‘math’ (a nil value)”}
    mods/_defaults/pbox_workerDefaults/pbox_worker_surviveUpdate.lua:39 (unknown)
    {w = userdata(849431512), data = userdata(849431512), improveAction = 0, improvCount = 4.000000, resOut = nilunknown}
    [LuaObject.cpp | 147]
    2017-Mar-03 23:11:24 Lua error [LuaObject.cpp | 153]
    2017-Mar-03 23:11:25 <<<<<<<<<<<>>>>>>>>>>> [MyBreakPad.cpp | 50]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s