I want to develop a dfhack plugin to export functions for random number generation.
The C++ random number distributions are looking quite appealing for a lua script I'm developing. There are some table entries I need to randomly select. I want to exhaust all selection options, randomly, in the fewest iterations necessary. So a std::uniform_int_distribution would be quite fitting for this task. Even creating a custom number distribution would be easier written in C++ over lua. A custom number distribution wherein: I create an array of my selection options (ie. a bunch of indices), then shuffle the array to a random order, and finally "generate" numbers by iterating through it.
I've looked over dfhack documentation, but there doesn't seem to be anything covering the creation of plugins. I've never worked with lua before last week, so I'm not even sure how exporting functions works.
- How can I get started?
- Do plugins require dfhack source files to integrate/build?
- Do I need to clone the entire repo? If so can anybody point me to a thread that covers getting setup? (preferrably in visual studio 2013-2017)
- Could I instead create my plugin without any of the dfhack source files, then drop it in? I feel this would be too convenient to be possible.
So there is a module that already has Mersenne twister implemented (before we could use c++XX) in
a module . It could be extended to have more random stuff exposed to lua.
On the other hand module vs plugin (AFAIK) only difference is that modules are "baked in" into main library so other plugins/modules can easily use them.
- See: Compiling docs and Any files in here . There is also "skeleton plugin" but imho it's more complicated than it needs to be.
- Yes and no. Yes it needs for easiest build and integration. But there are ways to compile it without compiling whole dfhack. I think only mifki (of TWBT and other cool stuff) does that.
- Yes cloning entire repo is preferable. Currently we are in "new df version chaos" so pull-req are not being handled (afaik) and the compiling link should cover setup
- There are ways to do it... I did it by using online Continous Integration thing, but it does full dfhack compile (30min) so developing is slow and i'm using it only when
i'm too lazy to update dfhack away from from my main pc.
As always: you can post your issues in dfhack thread or on
irc channel