expwnent
aa5d7c11bc
Merge remote-tracking branches 'lethosor/patch-12' and 'lethosor/fs-expansion' into develop
...
Conflicts:
NEWS
2015-01-31 20:25:01 -05:00
lethosor
3ab558c72d
Check for init.lua existence properly
...
Fixes #501
2015-01-30 16:37:23 -05:00
expwnent
1445b0a919
Allowed Lua scripts to share variables with run_script and corrected dfhack.findScript so that it can find save-specific scripts.
2015-01-26 21:45:31 -05:00
Lethosor
d21cd54648
Add '@' documentation to dfhack.lua
2014-09-14 11:50:03 -04:00
lethosor
fadca0aef2
Add a variant of printall() that uses ipairs
2014-09-08 20:30:22 -04:00
expwnent
0a16bc2e12
Merge remote-tracking branch 'origin/perSaveScripts' into scriptOrganization
...
Conflicts:
plugins/CMakeLists.txt
2014-07-07 09:01:07 -04:00
expwnent
3c06f3bada
Allowed per-save script folders.
2014-07-07 08:50:40 -04:00
lethosor
830b39e13b
Non-silent version of Lua's run_command
2014-06-27 21:58:36 -04:00
Alexander Gavrilov
6f162a4e72
Verify that mkmodule is called with the correct module name.
2014-06-26 18:11:05 +04:00
lethosor
d538e13450
Allow runCommand arguments to be passed as a table internally
2014-06-16 11:16:35 -04:00
lethosor
2a01259192
Fix runCommand crash, return output and result
2014-06-10 21:38:21 -04:00
lethosor
143b1e3469
Lua runCommand improvements
...
* Return error codes (e.g. CR_FAILURE) when a command fails instead of output
* Make dfhack.runCommand() take a list of arguments as well
2014-06-10 13:41:01 -04:00
lethosor
91a93a00d2
Add dfhack.run_command (Lua)
...
Simplified version of runCommand
2014-06-07 20:31:20 -04:00
Alexander Gavrilov
a09e132107
Support using multiple lua init scripts per save.
...
This should make it easier to add and remove init script code by
automated means, or install multiple mods that need such code.
2014-03-31 16:00:55 +04:00
Alexander Gavrilov
9e81d27cd1
Implement the same random generator as DF uses for DFHack.
2013-09-30 19:46:39 +04:00
Alexander Gavrilov
bb3a491d68
Implement a per-save lua init script.
2012-12-21 14:00:50 +04:00
Alexander Gavrilov
d336abfd97
Add label and list widgets, and switch stock dialogs to them.
2012-10-16 14:18:35 +04:00
Alexander Gavrilov
33bd8103de
Extract an abstract View superclass from Screen to handle widget trees.
2012-10-15 15:30:00 +04:00
Alexander Gavrilov
57b72831ca
Overhaul the concept of lua 'class' initialization yet again.
2012-09-18 20:30:25 +04:00
Alexander Gavrilov
325e294af2
Start the siege engine plugin with code to highlight obstacles on screen.
2012-09-07 19:54:32 +04:00
Alexander Gavrilov
d5ea05ebb8
Implement a pressure plate sensitive to machine power.
...
When built next to a gearbox, it will monitor its powered state.
2012-09-06 12:37:29 +04:00
Alexander Gavrilov
27f169e298
Provide a partial application utility function to lua.
...
Implemented in C++ for efficiency.
2012-09-05 17:37:36 +04:00
Alexander Gavrilov
296f82b02f
Try using the Objective-C 'alloc + init' idiom for lua screen objects.
2012-08-24 13:28:34 +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
cacb082416
Add a stupid example of a lua-controlled viewscreen.
2012-08-19 17:53:25 +04:00
Alexander Gavrilov
30f71ff510
Implement support for lua-backed viewscreens.
2012-08-19 14:27:44 +04:00
jj
8e17ebbefc
add SC_PAUSED / SC_UNPAUSED onStateChange events
2012-07-05 18:03:02 +02:00
Alexander Gavrilov
bd37cc09c5
Update the Lua API document with info about scripts.
2012-06-22 20:17:55 +04:00
Alexander Gavrilov
65e82f7c12
Support controllable error presentation verbosity in lua code.
...
Use qerror to squash stack traces and location prefix.
2012-06-22 16:36:50 +04:00
Alexander Gavrilov
7eb4fc19de
Make dfhack.run_script usable from other scripts, and document it.
2012-06-14 12:46:12 +04:00
Alexander Gavrilov
87ec1de891
Improve lua api for tile biome access.
2012-05-13 13:58:41 +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
4cffb6428d
Update building creation code with new knowledge, and fix zone.
...
Also, document new lua api, and add a more convenient wrapper.
2012-05-01 18:55:30 +04:00
Alexander Gavrilov
2303a25bde
Implement unconstructed building instance creation and linking into world.
...
For more flexibility, the base api is split into 3 phases:
alloc, setSize, and construct. No support for non-actual
buildings like stockpiles and activity zones at the moment.
2012-04-29 21:07:39 +04:00
Alexander Gavrilov
16ee049664
Split off the burrows api from Maps and Units.
2012-04-26 12:56:28 +04:00
Alexander Gavrilov
763a301b4f
Add a few more lua api functions, documentation, and unit sort orders.
...
Units::getProfessionName appears to work correctly for
everything except nobles.
2012-04-23 21:30:53 +04:00
Alexander Gavrilov
2ef321a208
Preserve the original lua global environment for modules.
...
The intent is to prevent accidental pollution of module namespaces
by globals defined from careless scripts running in the _G environment.
2012-04-21 20:15:57 +04:00
Alexander Gavrilov
3beb2ebf25
Export the onStateChange event to core lua context & add some docs.
2012-04-17 11:45:09 +04:00
Warmist
17d5b2de04
Multiline interpreter.
...
To test try writing for k,v in pairs(table) do <enter> print(k) <enter> end
Also prompt could be changed (couldn't think of anything better).
2012-04-16 18:46:20 +03:00
Alexander Gavrilov
1e64a6a2f6
Make dfhack.lineedit automatically interact with RunCoreQueryLoop.
...
It still falls back to the original waiting mode if yield fails.
2012-04-16 18:05:42 +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
cb49c92b99
Allow plugins to export functions to lua with safe reload support.
...
- To ensure reload safety functions have to be wrapped. Every call
checks the loaded state and locks a mutex in Plugin. If the plugin
is unloaded, calling its functions throws a lua error. Therefore,
plugins may not create closures or export yieldable functions.
- The set of function argument and return types supported by
LuaWrapper is severely limited when compared to being compiled
inside the main library.
Currently supported types: numbers, bool, std::string, df::foo,
df::foo*, std::vector<bool>, std::vector<df::foo*>.
- To facilitate postponing initialization until after all plugins
have been loaded, the core sends a SC_CORE_INITIALIZED event.
- As an example, the burrows plugin now exports its functions.
2012-04-14 19:44:07 +04:00
Alexander Gavrilov
2d8611a480
Add core api for moving items between ground and containers.
2012-04-12 18:37:27 +04:00
Alexander Gavrilov
0c2b78b96b
Add api for manipulating burrows to the core.
2012-04-11 19:42:05 +04:00
Alexander Gavrilov
61245711f7
Export a few maps functions to lua.
2012-04-11 16:20:16 +04:00
Alexander Gavrilov
e74788cb26
Add a generic facility for object finalization during stack unwind.
...
Supports two modes of finalization:
- try {...} finally {...}
- try {...} catch { ...; throw }
Argument passing discipline is designed with vararg tail calls in mind.
2012-04-07 14:21:38 +04:00
Alexander Gavrilov
0daafef690
Wrap MaterialInfo for lua.
2012-04-06 19:56:19 +04:00
Alexander Gavrilov
903e9ee716
Export a few more functions to lua.
2012-04-06 11:21:28 +04:00
Alexander Gavrilov
9eed9f0d24
Wrap a few utility functions defined on the c++ side for lua.
2012-04-05 19:55:59 +04:00
Alexander Gavrilov
7efbd798ce
Upgrade lua errors to structures when attaching stack trace.
...
This allows detecting when it's re-thrown and avoiding attaching the
stack twice, and so on. Would also be useful if debugging is added.
2012-04-04 13:34:07 +04:00
Alexander Gavrilov
2d4af4ac3e
A few more utility functions for lua.
2012-04-03 20:02:01 +04:00
Alexander Gavrilov
edd63080b5
Only print the shortcut help once in the lua interactive mode.
2012-04-01 17:00:25 +04:00
Alexander Gavrilov
afe4eba957
Improve performance of the persistent data api, and wrap it for lua.
...
Use an stl table for string keys to avoid linear cost of lookup.
This uncovered a bug in the new luaL_getsubtable function.
2012-04-01 16:43:40 +04:00
Alexander Gavrilov
a9a6fbd8b5
Lua tweaks: a couple of functions, dfusion tweak, backtrace metadata.
2012-04-01 12:50:56 +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