From 2b59d6ee3d0fdf7557b5aa5860c948e75c4fcb6c Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 18 Feb 2023 01:09:54 -0800 Subject: [PATCH 1/2] make dfhack.job.attachJobItem available to Lua --- docs/dev/Lua API.rst | 9 +++++++++ library/LuaApi.cpp | 1 + 2 files changed, 10 insertions(+) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index ef9b35f05..c2cc7f5cd 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -1219,6 +1219,15 @@ Job module if there are any jobs with ``first_id <= id < job_next_id``, a lua list containing them. +* ``dfhack.job.attachJobItem(job, item, role, filter_idx, insert_idx)`` + + Attach a real item to this job. If the item is intended to satisfy a job_item + filter, the index of that filter should be passed in ``filter_idx``; otherwise, + pass ``-1``. Similarly, if you don't care where the item is inserted, pass + ``-1`` for ``insert_idx``. The ``role`` param is a ``df.job_item_ref.T_role``. + If the item needs to be brought to the job site, then the value should be + ``df.job_item_ref.T_role.Hauled``. + * ``dfhack.job.isSuitableItem(job_item, item_type, item_subtype)`` Does basic sanity checks to verify if the suggested item type matches diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 2dc2ddf8b..426c87566 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1659,6 +1659,7 @@ static bool jobItemEqual(const df::job_item *job1, const df::job_item *job2) } static const LuaWrapper::FunctionReg dfhack_job_module[] = { + WRAPM(Job,attachJobItem), WRAPM(Job,cloneJobStruct), WRAPM(Job,printItemDetails), WRAPM(Job,printJobDetails), From a536396bd8b7ede12cfa1cc65fe59c762b16cbac Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 26 Feb 2023 09:41:22 -0800 Subject: [PATCH 2/2] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 1192fb03d..dd109a218 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -47,6 +47,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - Gui focus strings will no longer get the "dfhack/" prefix if the string "dfhack/" already exists in the focus string ## Lua +- ``dfhack.job.attachJobItem()``: allows you to attach specific items to a job - ``dfhack.screen.paintTile()``: you can now explicitly clear the interface cursor from a map tile by passing ``0`` as the tile value - ``widgets.Label``: token ``tile`` properties can now be functions that return a value -@ ``gui.INTERIOR_FRAME``: a panel frame style for use in highlighting off interior areas of a UI