* Update eventful.lua
Had wrong function. Fixes https://github.com/DFHack/dfhack/issues/2202
* Update Lua API.rst
Update docs to add onReactionCompleting and remove outdated info
* Update Lua API.rst
Some more minor doc fixes
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add changelog entry
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Adds cxxrandom unit test and fixes interface problems
* Tightens braces
* Adds detection code for Shuffle's seqID/engID
* Adds usage examples for cxxrandom
* Gives cxxrandom objects id ranges, sort of
* Updates changelog
* Updates changelog.txt
* Increases id space for cxxrandom
* Fixes bool distribution error message and improves check
* Adds comment explaining the seeded RNG tests for cxxrandom
* Fixes type problem for 32bit builds
* Reduces loop count a few magnitudes
* Fixes a mistake in test.cxxrandom_seed
--splitby=none is the new default, allowing all blueprint phases to be
written to a single file. old behavior of one phase per file is
supported via --splitby=phase.
refactor is a straight copy-paste. this code could really stand some
cleanup (unused vars, unnecessary use of the MapCache layer, forced
allocation of all blocks even if they are not being unhidden, etc.), but
that can come in a later PR.
- make depth and name parameters optional
- allow depth to be negative to indicate top-down instead of the
previous hard-coded bottom-up
- add --cursor for specifying start position (game cursor is not needed
if this param is specified)
Planning a 4x2 construction with DF's `umkh` keys (i.e. not automaterial's box-select) would previously produce a 5x3 construction instead, for example.
This kind of functionality is much more important now than it used to
be since there are so many supported building types.
Also modified the 'Planning Mode' status on the building placement
screen to reflect whether we're in quickfort mode, enable all mode, or
whether just the building type is enabled.
this setting is not persisted (just like quickfort_mode is not
persisted), but it can be set from onMapLoad.init
for items that cannot have a quality or be decorated:
in place mode, don't show quality adjustment hotkeys (or isDecorated
flag hotkey) and don't interpret the associated keycodes if they are
pressed.
in query mode, don't show quality or decorated fields.
solves the confusing behavior when both automaterial and buildingplan
are enabled for constructions. the two plugins now communicate with each
other over the Lua layer to negotiate consistent behavior.
if neither plugin is enabled, the standard DF UI acts as normal
if automaterial is enabled but buildingplan is not, then automaterial
behavior is unchanged.
if buildingplan is enabled and automaterial is not then behavior is
the same as other buildings with buildingplan (no material selection
screen, screen stays on building placement screen after placement).
this commit fixes a bug, though, where buildingplan would only lay
down a single tile of contruction instead of a solid block when a
block is requested.
if both plugins are enabled but buildingplan is not enabled for the
building type then automaterial is unchanged from previous behavior,
execpt for an additional header showing the separation between
automaterial hotkeys and buildingplan hotkeys.
finally, if both plugins are enabled and buildingplan is enabled for the
building type then buildingplan behavior prevails, but the box select and
hollow designations features of automaterial are still usable and
useful. the 'Auto Mat-select', 'Reselect Type', and "Open Placement"
automaterial hotkeys are hidden in the UI and ignored in the feed. This
is because buildingplan takes over material selection, so 'Auto
Mat-select' doesn't make sense. Buildingplan also already stays on the
placement screen after placement, so 'Reselect Type' is not necessary.
And all buildingplan-placed buildings have relaxed placement
restrictions (e.g. they can be built in mid-air) so 'Open Placement' is
also not necessary. The missing options are replaced with blank lines so
the vertical alignment of all other options stays constant.
we also remove a few extra lua_pop() calls that are made superfluous by
the StackUnwinder.
- remove buildings_use_blocks setting from quickfort config file
- add a new Buildingplan Global Settings dialog to house global settings
- move Quickfort Mode (for legacy Python Quickfort) into that dialog
- add four settings to control how generic building materials are matched:
- blocks
- boulders
- logs
- bars
- ajust the buildingplan algorithm to register duplicate tasks for
building material item filters, one for each type. since we track how
many items we've matched for a filter, the first matched item will
"win" and the extras will get detected as invalid and popped off the
queue.
- ensure boulders, logs, and bars are scanned last, and in that order
- more global settings planned for the future! see
http://www.bay12forums.com/smf/index.php?topic=176889.msg8202679#msg8202679
but restrict to only the currently supported set so we can still assume only one filter is required for each building.
changes:
- update buildingplan plugin version to 2.0
- new serialization format for planned buildings
- old persistent data is automatically migrated to new format on load
- algorithm now respects job_item filters; items must match job_item filter and buildingplan ItemFilter
- more invalid items are now filtered out, like items encased in ice. are there any others we should be checking (see BadFlags struct)
- items are sorted before job is unsuspended so final item ordering is correct regardless of what order the items were matched and attached
- item counts in filters are kept up to date so if buildingplan is disabled before all filters are matched and the building is completed by DF itself, the item counts will come out correct (though the item ordering and building "roughness" may be incorrect)
- fixes two memory leaks in building finalization code
- allows artifacts to be matched (ItemFilter defaults now top out at Masterful -- Artifact is selectable but must be manually specified)
- add gui to switch between items for buildings that require multiple item types
Replace C++ building construction code with lua constructBuilding so we can get the proper job_item filters set. these filters will be used when we replace the core buildingplan algorithm in the next PR.
Lots of refactoring and reorganizing, with only cosmetic player-visible changes.
- show quickfort mode hotlkey label regardless of whether the current building type has buildingplan enabled. before, it was only shown after the user enabled buildingplan for the current building. this eliminates the extra step when enabling quickfort mode, which force-enables all building types.
- changed signature of lua-exported isPlannableBuilding to take subtype
and custom type in addition to building type. this is only used by
quickfort, and it already sends all three params in preparation for
this change
- added lua-exported scheduleCycle(), which is like doCycle(), but only
takes effect on the next non-paused frame. this lets quickfort
run only one buildingplan cycle regardless of how many #build
blueprints were run
- declared a few dfhack library methods and params const so buildingplan
could call them from const methods
- converted buildingplan internal debug logging fn to have a printf api
- reshaped buildingplan-planner API and refactored implementation in
preparation for upcoming core algorithm changes for supporing all
building types (no externally-visible functionality changes)
- changed df::building_type params to type, subtype, custom tuple keys
- introduced capability to return multiple filters per building type
(though the current buildings all only have one filter per)
- split monolith hook functions in buildingplan.cpp into one per scope.
this significantly cleans up the code and preps the hooks to handle
iterating through multiple item filters.
- got rid of send_key function and replaced with better reporting of
whether keys have been handled
Major Revision
update v2.0
=-=-=-=-=
Native functions(exported to lua):
-GenerateEngine: returns engine id (args: seed)
-DestroyEngine: destroys corresponding engine (args: rngID)
-NewSeed re-seeds engine (args: rngID, seed)
-rollInt generates random integer (args: rngID, min, max)
-rollDouble generates random double (args: rngID, min, max)
-rollNormal generates random normal[gaus.] (args: rngID, avg, stddev)
-rollBool generates random boolean (args: rngID, chance)
-MakeNumSequence returns sequence id (args: start, end)
-AddToSequence adds a number to the sequence (args: seqID, num)
-ShuffleSequence shuffles the number sequence (args: rngID, seqID)
-NextInSequence returns the next number in seq.(args: seqID)
Lua plugin functions:
-MakeNewEngine returns engine id (args: seed)
Lua plugin classes:
-crng
methods:
-init(id, df, dist) :: constructor
id - Reference ID of engine to use in RNGenerations
df (optional) - bool indicating whether to destroy the Engine when the crng object is garbage collected
dist (optional) - lua number distribution to use
-__gc() :: destructor
-changeSeed(seed) :: alters engine's seed value
-setNumDistrib(distrib) :: set's the number distribution crng object should use
distrib - number distribution object to use in RNGenerations
-next() :: returns the next number in the distribution
-shuffle() :: effectively shuffles the number distribution
-normal_distribution
methods:
-init(avg, stddev) :: constructor
-next(id) :: returns next number in the distribution
id - engine ID to pass to native function
-real_distribution
methods:
-init(min, max) :: constructor
-next(id) :: returns next number in the distribution
id - engine ID to pass to native function
-int_distribution
methods:
-init(min, max) :: constructor
-next(id) :: returns next number in the distribution
id - engine ID to pass to native function
-bool_distribution
methods:
-init(min, max) :: constructor
-next(id) :: returns next boolean in the distribution
id - engine ID to pass to native function
-num_sequence
methods:
-init(a, b) :: constructor
-add(num) :: adds num to the end of the number sequence
-shuffle() :: shuffles the sequence of numbers
-next() :: returns next number in the sequence
Adds missing function exports.
Fixes numerous problems I won't go into