Commit Graph

182 Commits (b723636fe2e5571eaef2585bd541eee35dc3ccfb)

Author SHA1 Message Date
Myk Taylor 100b374af7 generalize buildingplan for all building types
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
2020-10-16 14:08:52 -07:00
Myk Taylor 1368fb4003 buildingplan: construct buildings from lua
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.
2020-10-16 14:03:05 -07:00
Myk Taylor 82013c0c5e prep buildingplan for core algorithm changes
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
2020-10-16 13:52:23 -07:00
lethosor 19a4d1df5a
Merge remote-tracking branch 'myk002/quickfort_buildingplan' into develop 2020-08-17 23:43:05 -04:00
Myk Taylor e4a35514ab document buildingplan Lua API 2020-08-15 23:03:49 -07:00
Myk Taylor 42108a64b9 expose basic buildingplan functionality to Lua 2020-08-12 15:24:32 -07:00
Myk Taylor 17c509a596 update sample code for xlsxreader to use finalize 2020-08-10 09:18:49 -07:00
Myk Taylor 4a04273fae document xlsxreader functions 2020-08-09 09:28:19 -07:00
Myk Taylor a41f7c0998 convert XlsxReader module to xlsxreader plugin 2020-08-09 08:54:42 -07:00
lethosor aee4fcd1a6 Add confirmation for convicting dwarves of crimes
Closes #1593
2020-06-20 12:06:50 -04:00
Alan 2344e60101
Merge pull request #1181 from warmist/twbt_experiments
map-render plugin
2019-08-21 09:33:45 -04:00
Alan a40adf1f86
Merge pull request #1435 from cppcooper/cxxrandom-rel
[Release] cxxrandom v2.0.1
2019-04-16 12:04:40 -04:00
Josh Cooper 9c403f509d [Release] cxxrandom v2.0.1 2019-04-15 16:21:54 -07:00
Warmist 5c1b7030e7 Also rename the plugin lua file 2018-10-12 10:44:56 +03:00
Warmist 41856aef37 Merge remote-tracking branch 'origin_DFHACK/develop' into twbt_experiments 2018-10-12 10:31:37 +03:00
lethosor 1c137f9a35 Fix a few Lua 5.3-related errors
Reported on bay12:
http://www.bay12forums.com/smf/index.php?topic=164123.msg7821831#msg7821831
2018-08-02 14:36:15 -04:00
lethosor 61df5e5286 Merge remote-tracking branch 'KlonZK/patch-1' into develop 2018-07-20 23:16:28 -04:00
KlonZK 29f6131e26
fix custom animation tables
move "local frames" from inside the block to outside.
2018-07-16 10:39:05 +02:00
Pauli 57dd9e944e Fix crafts advanced constraints in workflow
Fixes #1247
2018-07-04 19:10:51 +03:00
lethosor 862fa08ba6 Merge remote-tracking branch 'cppcooper/cxxrandom-rel' into develop 2018-06-20 11:00:43 -04:00
lethosor 5f81cac3b7 dwarfmonitor.lua: use dmerror() consistently 2018-05-21 21:23:52 -04:00
Daniel Brooks d15f87715e update comments 2018-05-08 13:04:14 -07:00
Daniel Brooks 554814920b this allows the blueprint plugin to be called from lua 2018-05-08 11:42:41 -07:00
Josh Cooper bc32d15bea [Release] cxxrandom v2.0
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
2018-04-29 21:08:44 -07:00
Josh Cooper 23b2d5eba5 Merge branch cxxrandom
Implements helper functions for random number generation.
Implemented using C++11 <random> library.

Exported Lua Functions:
- seedRNG(seed)
- rollInt(min, max)
- rollDouble(min, max)
- rollNormal(mean, std_deviation)
- rollBool(chance_for_true)
- resetIndexRolls(string, array_length)  --String identifies the instance of SimpleNumDistribution to reset
- rollIndex(string, array_length)        --String identifies the instance of SimpleNumDistribution to use
                                         --(Shuffles a vector of indices, Next() increments through then reshuffles when end() is reached)

 On branch cxxrandom-rel
 Changes to be committed:
   modified:   plugins/CMakeLists.txt
   new file:   plugins/cxxrandom.cpp
   new file:   plugins/lua/cxxrandom.lua

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Squashed commit of the following:

commit 3a7ef70d45f3e0c2fe367141dd0349dddaaff60d
Merge: fd9f1982 7aa0608c
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Fri Dec 22 22:17:27 2017 -0800

    Merge remote-tracking branch 'origin/temp' into cxxrandom

commit 7aa0608cb85dcf82686193db7a6e9d1318f5f2a5
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Thu Dec 21 21:43:35 2017 -0800

    Revises cxxrandom plugin

    New functions:
    - seedRNG(ushort seed)
        --lua exported
    - GetDistribContainer()
        --internal singleton
    - RNG()
        --internal singleton

    Summary:
    - Removed class CXXRNG
        --Refactored functions that used CXXRNG

     Changes to be committed:
            modified:   plugins/cxxrandom.cpp

commit b42979818a01c1121eace7b1ac14676f5ad5d8b2
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Wed Dec 20 13:21:49 2017 -0800

    Fixes plugin_init()

    Misread the lines indicated by lethosor to be excluded, had broken the plugin in the process.
     Changes to be committed:
    	modified:   plugins/cxxrandom.cpp

commit 753a00a14d9e6519d299638e014abf30509940af
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Wed Dec 20 12:36:17 2017 -0800

    Cleans up cxxrandom.cpp

    DFHack contributions specifies:
    -spaces instead of tabs, so tabs were converted.
    -C++ headers before dfhack stuff, so it was done

    *Also added author name, creation date, and last updated date.

     Changes to be committed:
    	modified:   plugins/cxxrandom.cpp

commit 498ebe4b8fdccc01ac1f169269f3093c830a8a10
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Tue Dec 19 22:51:58 2017 -0800

    Updates cxxrandom, fixes instance leak

    deleted header
    moved definition to cpp file #lethosor

    fixed singleton instance, no longer a pointer
    commented out dfhack commands, now only init/shutdown and exported lua functions

    	modified:   cxxrandom.cpp
    	deleted:    cxxrandom.h

commit 821044bef2a0201d0d74192e445c7b29766b42a1
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Sun Dec 17 04:01:11 2017 -0800

    Fixes RollIndex and Renames RollNormal

    Renamed the Normal Distribution RNG function to fit the standard.
    Now named RollNormal(m,s)

    Fixed some wonky white space in the lua macro export block.

    Fixed a stupid mistake with the RollIndex output. (it was outputting 0's)

    Updated usage details.

     Changes to be committed:
    	modified:   plugins/cxxrandom.cpp

commit 1536f43d137b6bc55d55759b43bdccf6ff429b33
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Fri Dec 15 08:50:08 2017 -0800

    Fixes/Improves cxxrandom

    Modified return types
    Corrected index distribution code

commit 8629c7e1509522cb0cc4b649914b90d033cb4763
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Thu Dec 14 19:02:29 2017 -0800

    Implements SimpleNumDistribution

    Exported additional functions to lua.
    Functions allow the generation of random 0-N index values.
    Generation promises all unique values [0,N] will be returned once each when generation is run N times.

     On branch cxxrandom
     Changes to be committed:
    	modified:   plugins/cxxrandom.cpp
    	modified:   plugins/cxxrandom.h

commit f035f3d20415790542cf83e5e696261661d911f3
Author: Josh Cooper <cooper.s.josh@gmail.com>
Date:   Wed Dec 13 23:55:39 2017 -0800

    Implements cxxrandom

    cxxrandom was implemented using a singleton.
    This singleton provides an interface for generating uniform numbers, or numbers in a normal distribution, and also booleans(given the probability for the true outcome)
    The singleton interface is wrapped in functions which are exposed for lua usage.

    Integrated into plugins/CMakeLists.txt

     On branch dev
     Changes to be committed:
    	modified:   CMakeLists.txt
    	new file:   cxxrandom.cpp
    	new file:   cxxrandom.h
    	new file:   lua/cxxrandom.lua
2018-04-29 21:08:44 -07:00
lethosor db95796d4c Many build fixes 2018-03-10 16:53:45 -05:00
Warmist e48e2e6534 A twbt utils plugin for misc stuff used in twbt by mifki.
Currently only render map function.
2017-12-31 13:57:37 +02:00
Warmist 620cfcc8bd Fix luasocket receive with byte count
Did not correctly detect when you typed in a number instead of pattern.
2017-08-12 15:42:56 +03:00
lethosor 2d07e5edea Add new "pathable" plugin 2017-07-05 23:54:55 -04:00
lethosor aea76b7ef3 stockflow: make sure that manager order amounts are integers
Fixes #1044
2017-03-18 17:56:06 -04:00
Lethosor ba48afe908 stockflow: Simplify calculation
See #1046

Use math.floor() for now until we can get Lua 5.3 working on Travis
2016-12-16 14:22:00 -05:00
Kelly Kinkade 1419d58b9a stockflow: Use "floor division"
Per suggestion by @dscorbett
2016-12-16 13:04:51 -06:00
Kelly Kinkade 5be77fa63d stockflow: Fix "integer expected" problem in stockflow 2016-12-16 08:09:53 -06:00
Eric Wald 060331de37 Stockflow reaction updates
SpinThread jobs now get the proper material category flag, and metal mechanisms can be ordered.
2016-06-26 19:22:53 -06:00
Eric Wald 3f0857bff3 Incrementing the manager order id properly.
There's a chance that not doing so could lead to a crash, somehow.
2016-05-16 19:48:52 -06:00
Eric Wald 2df41e6bad Clearing the active flag for new stockflow orders.
It's not entirely clear what this flag does when there aren't any conditions on the order, but new manual orders start as Ready instead of Active.
2016-05-15 22:06:20 -06:00
Eric Wald 0b1004f2b8 Notice resizing immediately, instead of on next key press 2016-05-15 09:14:30 -06:00
Eric Wald 6add87b358 Simplifying key strings 2016-05-15 08:58:45 -06:00
Eric Wald 6575f5f412 Removing the quantity limit on stockflow orders. 2016-05-14 23:40:01 -06:00
Eric Wald 3e8d4f9257 New command for clearing the stockpile order.
Shift-Space by default, using the SETUPGAME_SAVE_PROFILE_ABORT key.
2016-05-14 23:35:07 -06:00
Eric Wald 8c7d5366c9 Switching to the new manager order flags 2016-05-14 23:33:38 -06:00
Eric Wald 02e0b9e721 Manager interface now uses the full height.
Its navigation behavior has also changed, and it now has key hints for navigation.
2016-05-14 22:42:49 -06:00
lethosor 2399539990 Merge remote-tracking branches 'warmist/patch-7', 'warmist/patch-8' and 'warmist/patch-9' into develop 2016-04-10 11:58:48 -04:00
Warmist 812f6df272 Fix building-hacks color for auto_gears option
Now it should select the gear color correctly
2016-04-10 16:55:08 +03:00
Warmist c4c452c288 Show sidebar when moving from screen to screen
When both are from lua the old logic failed.
2016-04-10 16:51:58 +03:00
Warmist 29f08cd20d Fix eventful trying to show sidebar
It should not try to do that if e.g. showing buildingitems. Maybe later we will have more valid focus strings (e.g. custom item view for some buildings) but for now just use vanilla (or callback function not a class)
2016-04-10 14:58:03 +03:00
Warmist 9c9f710d5b Fix eventful not showing sidebar sometimes
E.g. when destroying buildings
2016-04-10 14:47:33 +03:00
expwnent b71c1b9e7c Merge pull request #751 from PeridexisErrant/remove-dfusion
Remove dfusion, df2mc, mapexport, dwarfexport
2016-03-13 08:22:07 -04:00
Warmist bc02e2a844 Add auto-gears mode for building hacks for automatic animation and gear positions. 2016-03-13 13:37:36 +02:00
Eric Wald 8ce115646a Updating Stockflow for version 42.06
The manager can now specify each type of craft individually, as well as in general.
There may be a better justification for not allowing pearl and shell scepters, though.
2016-02-23 22:09:26 -07:00