Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Raidau

Pages: [1]
1
DF Modding / Item description repository (for "extended item view")
« on: January 25, 2015, 11:42:17 am »
The mod itself:
Extended item viewscreen

This repository on github



In this thread i will try to encourage community contributions (and track them too :) ) to the descriptions database. Any contribution is wellcome!

Currently there can be a custom text for both items and materials. You can contribute by just making a short and useful wiki article summary, or by also adding some flavor text. This is a vanilla DF database, so you generally better to focus on vanilla items and materials.

I will accept text description from any source, that can even be just a simple forum post in this thread. I will check those descriptions and include them in the mod release (and they are very likely will go to starter pack and other mods too).

Pay attention, there always must be at least 3 things described:
1. Shape of the item
2. Usage
3. How to craft it (or how the item is obtained, in general)

Total files: 164
Current progress: 5%, 8/164, everything is needed.

2
Dwarven Family Affairs
Lets you manually assign new spouses for your dwarves or remove existing romantic relationships (useful when the spouse is dead). Also shows pregnancy info.

Download here




Savegame backup recommeded. The script needs some more testing to make sure it does not corrupt saves, as it changes history data. Please report any bugs you encounter.

Usage:
Spoiler (click to show/hide)

Installation:

Unzip the archive and place nb_family_affairs.lua in your Dwarf Fortress/hack/script folder

Gays are not supported (yet).
Tested with DFHack 0.40.23-r1 on Windows

Changelog:
Spoiler (click to show/hide)

3
Hi guys, while my mod is not ready for release, i decided to upload a standalone version of one of my last scripts.

It shows vast amount of useful information on item view screen. Armor and weapon properties, important material stats. Easy and convenient - does not need to be manually activated every time, works in fortress and adventure modes. Custom descriptions can be added to every kind of item or material - they are stored in txt files and thus easily moddable. Also spports moddable ASCII images for every creature and item in the game. Double tap Enter of ESC to close ASCII image popup.

Download here (or from GitHub)

Desription repository - feel free to contribute!

Here are examples how it looks:






Currently shows user-defined text, material info and temperature for all non-caste items (and even bone body parts 8) ), armor properties, weapon stats for weapons and combat-usable tools, food properties for suitable items. Does not replace existing lines (like reactions and ore metals).

Material strength data percentages are relative to IRON inorganic, or if it is absent (in your mod), to the first inorganic defined in the raws.

ASCII images are loaded from txt files. You may add your custom ascii images for every creature and items, usind their raw tokens (see modding instructions in the mod archive). To enable ASCII use "ascii_item" and "ascii_unit" arguments (in any order), e.g. run script with command "nb_item_info ascii_item"

Custom description guide:
Spoiler (click to show/hide)

I would really appreciate corrections related to phrases used by the script, since english is not my first language.

Tested with DFHack 0.40.23-r1 on Windows

Changelog:
Spoiler (click to show/hide)

4
DF Modding / [DFHack] easiest way to get item type index?
« on: January 18, 2015, 10:58:01 am »
Can someone answer this little question? A lot of functions (for example dfhack.items.getSubtypeCount(item_type)) accept item type as integer.

What is the most convenient way to convert item type to integer?

5
DF Modding / Dfhack: how to remove job object properly
« on: January 06, 2015, 06:26:40 am »
I want to write a function which properly removes issued job from the game.

Currenly i have written this, seems to work and it doesnt cause crashes on save and world unloading, but im afraid there are some additional references to a job in DF memory

This function is called when list prompt is cancelled, and works only if the job is the last in job list.

Dont pay attention to debug lines

Code: [Select]
function() --on cancel
print ("on cancel")
print ("holder building = "..tostring(dfhack.job.getHolder(job)))

local function get_last_job ()

local cur_job = df.global.world.job_list
while cur_job.next ~=nil do
print ("job list next checked")
cur_job = cur_job.next
end
return cur_job.item
end

if get_last_job() == job then
print ("job is last in list")

for a,b in pairs (dfhack.job.getHolder(job).jobs) do
if b == job then
dfhack.job.getHolder(job).jobs:erase(a)
job.general_refs:erase(0)
break
end
end

job.list_link.prev.next = nil
job.list_link:delete()
job:delete()

end

--dfhack.job.printJobDetails(job)
--job.flags.item_lost = true]]
end

6
The reactions that appear in workshop reaction list after adding them are always unavaliable, even if i have all required reagents (I checked that very carefully).

Code: [Select]
local e = require "plugins.eventful"

function main()

e.removeNative("KITCHEN")
e.addReactionToShop("LUA_HOOK_NB_KITCHEN_BREAD","KITCHEN")

end

Does this part of the plugin work properly? Btw, is there any way to exclude individual reactions from choice list? (Using dfhack)

7
This script allows you to burn anything you wish and get various amount of product depending on burned items weight.

How to use:

-create a lua file in your hack/scripts folder, copy the text there and add the script name to dfhack.init
-create custom reaction(s) starting with "[REACTION:LUA_HOOK_NB_CREMAT" and give it to your civ

I recommend usage of clever input stockpiles or dfhack workshop-job tool to make sure you burn only things you really want to burn.

Dwarf corpses are currenly ignored by reactions, this is hardcoded. So if you want to cremate your dwarves (as well as intruders dwarf necromancers) you need to manually set flag for the corpse item dead_dwarf = false

Code: [Select]
--NB item burning script. Produces additional ash bars depending on burned items total weight.
--By Raidau, based on Roses scripts
--[[
example reaction:
[REACTION:LUA_HOOK_NB_CREMAT_ANY_5]
[NAME:burn 5 organic items to ash]
[BUILDING:KILN:CUSTOM_B]
[REAGENT:FACTOR35:1:NONE:NONE:NONE:NONE][REACTION_CLASS:ORGANIC_BURNABLE][EMPTY] - a trick to avoid improper behavior with thread/globs and everything that has dimensions, containers and cages are very complicated, so its advisable not ot allow them to avoid exploits
[REAGENT:organic item:1:NONE:NONE:NONE:NONE][REACTION_CLASS:ORGANIC_BURNABLE][EMPTY]
[REAGENT:organic item:1:NONE:NONE:NONE:NONE][REACTION_CLASS:ORGANIC_BURNABLE][EMPTY]
[REAGENT:organic item:1:NONE:NONE:NONE:NONE][REACTION_CLASS:ORGANIC_BURNABLE][EMPTY]
[REAGENT:organic item:1:NONE:NONE:NONE:NONE][REACTION_CLASS:ORGANIC_BURNABLE][EMPTY]
[PRODUCT:0:1:BAR:NO_SUBTYPE:ASH:NO_MATGLOSS][PRODUCT_DIMENSION:150] - 0 probability still makes reaction take time and require skill, but dont produce anything
[SKILL:WOOD_BURNING]
[FUEL]

The above reaction requires [REACTION_CLASS:ORGANIC_BURNABLE] added to all desirable materials (or templates) to prevent burning e.g. bronze colossus or inorganic titans' severed body parts
--]]

function cremate(reaction,unit,input_items,input_reagents,output_items,call_native)
--print("cremat debug: ")
--print("input items: ")
--printall(input_items)

--print("maker unit: "..tostring(unit))
local factor = tonumber(string.match(reaction.reagents[0].code,"FACTOR(%d+)"))
print("custom efficiency factor found: "..tostring(factor))
if not factor then factor = 35 end
local totalweight = 0
--local x = output_items[0]

for i=0,#input_items-1 do
local v = input_items[i]
--print ("adding weight of item "..tostring(v).." to total w")
totalweight = totalweight + v.weight + (v.weight_fraction/1000000)
end

--print ("total weight calculated="..totalweight)

local barcount = totalweight^(factor/100)

--print ("barcount calculated="..barcount)

if math.random()<(barcount-math.floor(barcount)) then
barcount = barcount + 1
end

barcount = math.floor(barcount)
--print ("final bar count calculated="..barcount)

if barcount > 0 then
for i = 1, barcount do
local item=df['item_barst']:new() --incredible
item.id=df.global.item_next_id
df.global.world.items.all:insert('#',item)
df.global.item_next_id=df.global.item_next_id+1
item:setMaterial(9)
item:setMaterialIndex(-1)
item.dimension = 150
item:categorize(true)
item.flags.removed=true

if dfhack.buildings.findAtTile(unit.pos) then
dfhack.items.moveToBuilding(item,dfhack.buildings.findAtTile(unit.pos),0)
item.flags.in_building = false
else
dfhack.items.moveToGround(item,{x=unit.pos.x,y=unit.pos.y,z=unit.pos.z})
end

--print ("extra ash bar created "..tostring(item))
end
end
end

-- START Taken from hire-guard.lua
local eventful = require 'plugins.eventful'
local utils = require 'utils'

function string.starts(String,Start)
   return string.sub(String,1,string.len(Start))==Start
end

dfhack.onStateChange.loadnb_cremat = function(code)
local registered_reactions
if code==SC_MAP_LOADED then
--registered_reactions = {}
for i,reaction in ipairs(df.global.world.raws.reactions) do
-- register each applicable reaction (to avoid doing string check
-- for every lua hook reaction (not just ours), this way uses identity check
if string.starts(reaction.code,'LUA_HOOK_NB_CREMAT') then
-- register reaction.code
eventful.registerReaction(reaction.code,cremate)
-- save reaction.code
--table.insert(registered_reactions,reaction.code)
registered_reactions = true
end
end
--if #registered_reactions > 0 then print('HireGuard: Loaded') end
if registered_reactions then print('NB crematorium loaded, reaction found') end
elseif code==SC_MAP_UNLOADED then
--[[ doesn't seem to be working, and probably not needed
registered_reactions = registered_reactions or {}
if #registered_reactions > 0 then print('HireGuard: Unloaded') end
for i,reaction in ipairs(registered_reactions) do
-- un register each registered reaction (to prevent persistance between
-- differing worlds (probably irrelavant, but doesn't hurt)
-- un register reaction.code
eventful.registerReaction(reaction.code,nil)
end
registered_reactions = nil -- clear registered_reactions
--]]
end
end

print("nb_cremat loaded")
-- if dfhack.init has already been run, force it to think SC_WORLD_LOADED to that reactions get refreshed
if dfhack.isMapLoaded() then dfhack.onStateChange.loadnb_cremat(SC_MAP_LOADED) end
-- END Taken from hire-guard.lua

This is part of my upcoming (i hope) mod :)

8
Hello, this little script does 2 things: sorts all sites or regions in adventurer's log by name, distance or type.

I made it since I was really annoyed by how long it takes to find desired site in the list when I played adventure mode, now its much shorter. I dont know much about gui scripting, so there's no filter string for now (although i wish to add it).

Usage: type script name in dfhack console while viewing site/region list, arguments "a" or "t" are optional

The script itself:

advsort.lua
Code: [Select]
-- sorts sites and regions in adventure mode log view. type "?" for help

local helpstring = [[

advsort script help

usage: advsort [a|t|d] in adventure mode log view
a: sorts list of sites or regions in alphabetical order
t: sorts list of sites by type
d: sorts list of sites by distance
]]

--By Raidau

local args = {...}

if args[1] == "?" then
print(helpstring)
return
end

if df.global.gamemode ~=1 then return end

local parent = df.global.gview.view.child.child
local screenl

local function getdist(x1,y1,x2,y2)

return math.floor(math.sqrt((x1-x2)^2+(y1-y2)^2))

end

if #parent.sites>0 then
screenl = parent.sites
end
if #parent.regions>0 then
screenl = parent.regions
end
local function compSiteName (site1,site2)
return dfhack.TranslateName(site1.name,true) > dfhack.TranslateName(site2.name,true)
end
local function compSiteType (site1,site2)
return site1.type > site2.type
end

local function compSiteDist (site1,site2)

return getdist(parent.player_region_x,parent.player_region_y,site1.pos.x,site1.pos.y) > getdist(parent.player_region_x,parent.player_region_y,site2.pos.x,site2.pos.y)

end

local function swap (tab,ind1,ind2)
local temp = tab[ind1]
tab[ind1] = tab[ind2]
tab[ind2] = temp
end
local function bsort (list,compf)


for i=0, #list-1 do
for j=0, (#list-2)-i do
if compf(list[j],list[j+1]) then swap(list,j,j+1) end
end
end

end

if not screenl then return end

if args[1] == "s" or args[1] == "a" or not args[1] then
bsort(screenl,compSiteName)
end
if args[1] == "t" then
bsort(screenl,compSiteType)
end
if args[1] == "d" and #parent.sites>0 then
bsort(screenl,compSiteDist)
end

Installation:
1. create advsort.lua file in DF/hack/script folder and paste the script code there (use any basic text editor such as notepad).
2. (recommended) add following lines to your dfhack.init file:
Code: [Select]
keybinding add F@adventure_log advsort
keybinding add D@adventure_log "advsort d"

9
It is possible to somehow make certain reactions not work unless the worker meets some simple condition? For example, custom reaction "write weaponsmithing manual", which requires minimum skill level 15, otherwise product amount is forced to 0 (or whatever) and [PRESERVE_REAGENT] forced for all the reagents.

 I've seen hire-guard lua script, it deals with reactions, and changes their outcome according to performer's skills.

Pages: [1]