Commit Graph

47 Commits (e55984c529d818e5ca756eb982a3a988e40ead0d)

Author SHA1 Message Date
Myk Taylor 5a4dec35f1
reorder template declarations so we can push vectors of maps 2023-04-24 14:28:21 -07:00
Myk Taylor c47f068769
add Lua::Push for sets 2023-03-15 00:28:18 -07:00
Myk Taylor 028bbca07b
allow vectors to be read from indices other than 1 2023-03-05 16:32:05 -08:00
Myk Taylor cd12f95849
add const & to Push overloads; remove circular def 2023-02-08 12:15:19 -08:00
Myk Taylor be40d55e64
update seedwatch 2023-02-01 04:03:28 -08:00
myk002 94c6bc8063
refactor generic lua function caller to Lua ns 2022-11-14 16:40:35 -08:00
myk002 4668d8c4a3 Add Lua::Push method for maps 2022-11-08 10:15:28 -08:00
myk002 b82a604c8d factor out keys -> lua onInput code to LuaTools 2022-11-08 10:15:28 -08:00
myk002 8672282fd8
add helpdb, unit test, and document API
note that we have to dynamically sort some of the expected lists for
locale agnosticism
2022-08-15 16:31:52 -07:00
Pauli f0632347d0 Remove Core.h include from DataDefs.h
Core.h isn't required for DataDefs.h which removes Core.h dependency
from DataStatics*.
2018-12-30 17:08:42 -05:00
Pauli f6b0ac7819 Refactor CoreSuspender to fix Console::lineedit exit hangs
The old CoreSuspender requires processing from Core::Update to allow
commands execute. But that causes issues if Core::Shutdown wants
quarentee cleanup order with std:🧵:join. Fixing shutdown ordering
adds too many branches to already fairly complex code.

I decided to try to refactor CoreSuspender to use simpler locking
locking using a std::recusive_muted as primary synchronization
primitive.
To help control when Core::Update unlocks the primary mutex there is
std::contition_variable_any and std::atomic<size_t> queue lenght
counter.
The last state variable is std::atomic<std:🧵:id> that is used to
keep track of owner thread for Core::IsSuspended query.

This should be merged only just after a release to make sure that it
gets maximum testing in develop branch before next release.

Fixes #1066
2018-06-22 17:57:37 +03:00
lethosor 4c21bbd5ae Add Lua::TableInsert() helper 2016-10-15 14:55:48 -04:00
lethosor 55970a71ab Fix Lua::Push for enums 2016-07-29 11:06:16 -04:00
lethosor b7856fd9f2 Use enable_if for Lua::Push specializations 2016-07-28 22:04:46 -04:00
lethosor 7b7f7a1b79 Fix support for integer fields in Lua 5.3 2016-07-28 16:36:02 -04:00
Vitaly Pronkin fe18f176f7 More 64-bit fixes
Cherry-picked from 7eb3ba6
- Lua update already done in e2c6350, 4dd411e
- Excluded library/modules/Buildings.cpp
2016-07-26 23:47:53 -04:00
Warmist d4988c5faf Add no handler version of lua event. 2016-02-01 22:22:12 +02:00
lethosor c44ac8ec6e Improve handling of fatal errors and errors in dfhack.lua
* Several fatal errors that occurred during core initialization didn't
  stop initialization or set 'errorstate' properly, which caused
  update hooks and other code to crash later. This has been fixed and
  should address crashes like the one mentioned in #470.
* Errors when loading dfhack.lua now cause Lua::Open() to fail, which
  triggers a fatal error in Core::Init()
* Failure to initialize the console no longer results in a call to
  fatal() (since it didn't actually stop initialization previously)
2015-10-17 21:18:04 -04:00
lethosor 96f3bdafb4 Implement an internal command to interrupt running Lua scripts
This inserts a debug hook that runs every 256 instructions by
default, which has a minimal impact on performance.
2015-05-24 19:06:01 -04:00
expwnent e5e0d93ef1 Added modtools/reaction-product-trigger. 2015-02-02 02:39:05 -05:00
Alexander Gavrilov e175efa689 Implement a template-based classical Perlin noise generator.
The mask argument of the Impl template is there because apparently
an inner template cannot be fully specialized, so there needs to be
some argument besides i.
2013-10-01 18:58:04 +04:00
Warmist 0e4df55364 Merge branch 'master' of https://github.com/angavrilov/dfhack 2012-11-11 12:46:55 +02:00
Alexander Gavrilov 9598316855 Add a native pen object for lua with a more checked behavior. 2012-11-03 20:06:33 +04:00
Warmist 6be65690f7 Merge branch 'master' of https://github.com/angavrilov/dfhack into experimental-dontmerge 2012-11-02 20:29:27 +02:00
Alexander Gavrilov 09f8e8e419 Start working on gui for workflow. 2012-10-23 21:42:03 +04:00
Warmist 923ea3f4b0 Reactionhooks more usefull and gm-editor minor tweaks (e.g. search in containers) 2012-10-07 20:44:18 +03:00
Petr Mrázek 8812238bf6 Update license, add contributors file, bump release number 2012-09-30 04:03:37 +02:00
Alexander Gavrilov 3a075f4bc7 Trivial siege engine aiming at units, with logic in lua. 2012-09-11 19:17:24 +04:00
Alexander Gavrilov c6c5ad56c9 Track lua event listener count, and let the C++ host know.
This allows completely avoiding the call overhead if there
are none. The downside is that the event object now has to
be a userdata with lots of metamethods.
2012-08-23 19:27:28 +04:00
Alexander Gavrilov 30f71ff510 Implement support for lua-backed viewscreens. 2012-08-19 14:27:44 +04:00
Alexander Gavrilov 87ec1de891 Improve lua api for tile biome access. 2012-05-13 13:58:41 +04:00
Alexander Gavrilov c6b52067bd Request designation rescan in auto-growing burrows.
This improves performance of burrowed miners digging 1-wide tunnels.
2012-05-12 20:54:26 +04:00
Alexander Gavrilov 81f2240c23 Fix some things that confuse MSVC. 2012-05-05 20:46:28 +04:00
Alexander Gavrilov 7e01b004e9 Implement timeouts in the core lua context, and quicksave script. 2012-05-04 20:59:06 +04:00
Alexander Gavrilov d4d6349f48 Expose builtin commands to dfhack-run, and add lua script support.
Move builtin command implementation to Core methods, and fall
back to hack/scripts/*.lua for otherwise unrecognized commands.
2012-05-04 19:47:18 +04:00
Alexander Gavrilov 28b5068382 Allow both coordinate object and (x,y,z) as arguments to getTileBlock. 2012-05-02 12:50:05 +04:00
Alexander Gavrilov 82a0e52a3e Add api to check the walkable cache, and update flow_forbid in liquids. 2012-04-26 18:51:39 +04:00
Alexander Gavrilov 125cd6622a Support sorting units in many more ui contexts. 2012-04-22 19:22:00 +04:00
Alexander Gavrilov 3beb2ebf25 Export the onStateChange event to core lua context & add some docs. 2012-04-17 11:45:09 +04:00
Alexander Gavrilov 9c25351281 Add a template to make using lua_pcallk a bit more convenient. 2012-04-16 18:01:21 +04:00
Alexander Gavrilov 3e4863bc80 Integrate coroutines with table-based error handling.
Properly attach stack traces to errors passing the resume boundary.
Replaces coroutine.resume and coroutine.wrap with appropriately
modified versions, and adds a Lua::SafeResume function for C++.
2012-04-16 14:45:04 +04:00
Alexander Gavrilov 48e4717dd2 Try working around some msvc problems. 2012-04-16 10:59:55 +04:00
Alexander Gavrilov a1756a864c Implement a way to do prompts from core context.
The trick obviously is doing it without forcing DF to wait suspended.
Fortunately, lua has built-in coroutine support, so the interactive
prompt can simply yield and rely on the external loop to do the job.
To use this however the REPL had to be replaced with lua code.
2012-04-15 21:50:22 +04:00
Alexander Gavrilov 14709e5d45 Add an official core lua context, and allow plugins to send events to it.
- This context requires core suspend lock and asserts it in a few places.
- Special 'event' objects are introduced. They can be invoked as
  functions, in which case they iterate all their fields and call
  them as functions. Errors are printed and consumed.
- When a plugin is opened by the core context, events registered in
  a special array are linked to it. The system is organized so as to
  avoid even trying to pass the event to lua if the module isn't loaded.
2012-04-15 19:09:25 +04:00
Alexander Gavrilov 2d4af4ac3e A few more utility functions for lua. 2012-04-03 20:02:01 +04:00
Alexander Gavrilov a8fe0eccb4 Add functions for checking validity of lua wrapper objects. 2012-04-02 22:02:04 +04:00
Alexander Gavrilov 0f41608ed4 Pull console output support and REPL out of dfusion into core lib. 2012-03-31 15:40:54 +04:00