Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Engraving slabs  (Read 1279 times)

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Engraving slabs
« on: September 02, 2015, 11:18:29 am »

Does anyone know a way to trigger the slab engraving menu from a user workshop? I can add hardcoded jobs (like collect sand), but slab engraving is a separate menu, so before I do a bunch of research I just wondered if anyone else knew how to do it.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Engraving slabs
« Reply #1 on: September 02, 2015, 12:11:31 pm »

Does anyone know a way to trigger the slab engraving menu from a user workshop? I can add hardcoded jobs (like collect sand), but slab engraving is a separate menu, so before I do a bunch of research I just wondered if anyone else knew how to do it.
Putnam. He wrote a slab-engraving script, but it doesnt make memorial slabs, it makes signs.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Engraving slabs
« Reply #2 on: September 02, 2015, 12:22:03 pm »

Well I need memorial slabs, so that won't work.

Basically I need a way to trigger the same sidebar you get when you choose the engrave slab option at the craftsman. I looks like I'll have to do some research on the associated menu button (what the category ID is and if it can be used with a custom workshop).
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Engraving slabs
« Reply #3 on: September 05, 2015, 11:34:01 am »

I figured it out! It isn't quite as nice as vanilla, but it works!

Here is the code I use for First Landing:
Code: [Select]
-- Add hard-coded jobs to user defined workshops.
eventful.postWorkshopFillSidebarMenu.FirstLandingBase = function(workshop)
if workshop:getType() ~= df.building_type.Workshop then
return
end

local ctyp = workshop:getCustomType()
if ctyp == -1 then
return
end

local id = df.building_def_workshopst.find(ctyp).code

if id == "RESOURCE_COLLECTOR" then
-- Some stuff related to adding the collect clay and sand jobs
elseif id == "SLAB_ENGRAVER" then
local allUnits = df.global.world.units.active
local deadCitizens = {}
local deadOther = {}
for i = 0, #allUnits - 1, 1 do
if allUnits[i].flags1.dead == true and allUnits[i].hist_figure_id ~= -1 then
if allUnits[i].civ_id == df.global.ui.civ_id then
table.insert(deadCitizens, allUnits[i])
else
table.insert(deadOther, allUnits[i])
end
end
end

local mkBtn = function(unit)
new_button = df.interface_button_building_new_jobst:new()
new_button.building = workshop
new_button.job_type = df.job_type.EngraveSlab
new_button.hist_figure_id = unit.hist_figure_id
new_button.item_type = 25971 -- Slab?
new_button.unk_48 = true -- ???

local wjob = df.global.ui_sidebar_menus.workshop_job
wjob.choices_all:insert("#", new_button)
wjob.choices_visible:insert("#", new_button)
end

for _, u in ipairs(deadCitizens) do
mkBtn(u)
end

for _, u in ipairs(deadOther) do
mkBtn(u)
end
end
end
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS