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.

Messages - Kurik Amudnil

Pages: [1] 2 3 ... 8
1
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: August 29, 2013, 12:12:24 am »
to get a unit by id
Code: (lua) [Select]
local utils = require 'utils'
local unit = utils.binsearch(df.global.world.units.all, id, 'id')
if unit then
    ...
end

or

Code: (lua) [Select]
local unit = df.unit.find(id)
if unit then
    ...
end

I think the df.unit.find method is the fastest way as it uses compiled code, and it is easier to use.

Also on the feeding front, in addition to setting unit.counters2.hunger_timer = 0 ; unit.counters2.stomach_content and stomach_food probably ought to get some attention.

2
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: August 05, 2013, 01:09:28 pm »
Kurik, Warmist, thanks again.  The script I'm going to call final (if nothing else comes up) is: 

Spoiler: log-region.lua (click to show/hide)

And is activated by putting "log-region" as it's own line in dfhack.init

It has occured to me that you may find the world name useful too
Code: (lua) [Select]
worldname = df.global.world.world_data.name
dfhack.TranslateName(worldname)
dfhack.TranslateName(worldname ,true)

3
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: August 02, 2013, 07:23:10 pm »
lua printall and its dfhack synonym ~ (I prefer using ~ because it also works on simple values whereas printall only works on structs/lists
Code: [Select]
[DFHack]# lua
Type quit to exit interactive lua interpreter.
[lua]# unit=dfhack.gui.getSelectedUnit()
[lua]# printall(unit.body.physical_attrs.STRENGTH)
value                    = 1064
max_value                = 2190
improve_counter          = 0
unused_counter           = 0
soft_demotion            = 93
rust_counter             = 2
demotion_counter         = 0
[lua]#
[lua]# ~unit.body.physical_attrs.STRENGTH
<unit_attribute: 0x1810f70c>
value                    = 1064
max_value                = 2190
improve_counter          = 0
unused_counter           = 0
soft_demotion            = 93
rust_counter             = 2
demotion_counter         = 0
[lua]#
[lua]# printall(unit.body.physical_attrs.STRENGTH.max_value)
[lua]# ~unit.body.physical_attrs.STRENGTH.max_value
2190

personally, I like to use these keybindings in dfhack.init to run the gm_editor when I am working on scripts
Code: (dfhack.init) [Select]
#  display gm_editor
keybinding add Alt-E gui/gm-editor
keybinding add Ctrl-E "gui/gm-editor dialog"

4
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 30, 2013, 01:11:40 am »
probably not related to your problem, but windows also doesn't like letting dfhack use Ctrl-Alt hotkeys nor Ctrl and/or Shift Z.  Hotkeys can also be blocked by other utilities/programs such as quickfort

5
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 26, 2013, 02:41:11 am »
Does anyone know how exactly deities are linked to specific entities (Urist Stylesuitor is a deity of The Glad Helms....)?

from civ_ent.unknown1b.worship ? as a reverse list of histfig ids to dieties?

where civ_ent is a civilization entry in df.global.world.enities.all or = df.historical_entity.find(df.global.ui.civ_id)

It looks to me to pick the first entity that includes the deity's historical figure id in that list.  I added the id to the group entity with no change, then removed the id from the civ entity and the "is a deity of" message changed to the group.

6
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 25, 2013, 01:00:30 pm »
yes, what warmist said

Code: [Select]
write_gamelog('Loaded '..df.global.world.cur_savegame.save_dir..', '..

7
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 25, 2013, 02:53:23 am »
@PeridexisErrant

I forgot to declare those 3 variables local, not that important here but they should be declared local.  Reformat the text as needed.  I am not sure which of the various position variables would be the most relevant or useful.  I think site.pos is the map block and according to comments in the world_site.xml, the rgn_min_x etc are embark blocks within the map block, and the global_min_x etc are the same embark blocks but in global coords rather than local to the map block.

This also should be tested with the different game modes to make sure it behaves.



@Meph
yes, that is an example script.  When we have example scripts for the other stuff it can be updated to plug that in.

I was also thinking about looking into making a compiled c++ plugin to intercept the (e)mbark button to export a lua event so that the script stuff could be done before the embark profiles come up but after a site and civ are chosen.  I am not yet sure how well that would work but it is a thought.

8
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 25, 2013, 12:06:16 am »
....

something like this?
Code: (lua) [Select]
-- On map load writes information about the loaded region to gamelog.txt

local function write_gamelog(msg)
    local log = io.open('gamelog.txt', 'a')
    log:write(msg.."\n")
    log:close()
end

local args = {...}
if args[1] == 'disable' then
    dfhack.onStateChange[_ENV] = nil
else
    dfhack.onStateChange[_ENV] = function(op)
        if op == SC_WORLD_LOADED then
            local site = df.world_site.find(df.global.ui.site_id)
            local fort_ent = df.global.ui.main.fortress_entity
            local civ_ent = df.historical_entity.find(df.global.ui.civ_id)
            -- site positions
            -- site  .pos.x  .pos.y
            -- site  .rgn_min_x  .rgn_min_y  .rgn_max_x  .rgn_max.y
            -- site  .global_min_x  .global_min_y  .global_max_x  .global_max_y
            --site.name
            --fort_ent.name
            --civ_ent.name
           
            write_gamelog('Loaded Region ('..site.pos.x..','..site.pos.y..'), '..dfhack.TranslateName(site.name)..' ('..dfhack.TranslateName(site.name, true)..')'..NEWLINE..
                          '    colonized by the group '..dfhack.TranslateName(fort_ent.name)..' ('..dfhack.TranslateName(fort_ent.name,true)..
                              ') of the civilization '..dfhack.TranslateName(civ_ent.name)..' ('..dfhack.TranslateName(civ_ent.name,true)..').'..NEWLINE)
        end
    end
end

might want to use SC_MAP_LOADED instead of world but it seems to be working with world so it might be irrelevant.

** added local to the 3 variables I set

9
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 24, 2013, 06:48:08 pm »
#1 something like this can be run from dfhack.init and listen for the embark screen
Spoiler: embark_listener.lua (click to show/hide)
Listening for the embark profile select/modify screen might be useful for adjusting the embark points according to the number of extra dwarfs given by startdwarf (number of dwarfs over 7 might be easier to detect)


#2 a problem with the popup question for startdwarf is trying to run startdwarf (a ruby script) from a lua script, or translating startdwarf to lua.  Also, if you get to the embark profile screen, it is too late to ask about startdwarf. Running startdwarf at the site selector seems to be fine.

#3 I think that filtering the trade goods probably ought to happen at the site selector also. 

#5 I haven't noticed any improved response times for marking a unit for recovery/diagnosis as the dwarf in question usually has those flags already set to true.  I have thought about trying to force the unit to have a resting state/job but haven't tested that yet.

10
any way to use workflow to set input materials? I created a "craft table" job at mason's workshop, added a custom limit to it, set output to "cobaltite table" but my mason still makes tables out of different materials.

when querying a workshop, with the job selected, I think it is Alt-A to bring up the editor for job inputs.

m for material, then selected inorganic and start typing cobaltite and it should come up.

11
could also use a two job cycle, where the first job runs the script that selects the damaged clothing for the second job which it creates (would want to have a free job slot in the workshop for the new job).  This way it can exclude the clothing worn by the worker.

12
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 17, 2013, 02:44:30 pm »
i got the latest DFHack and i would like to ask if scripts like falconne's and age/size bugfix are in the package or we need to add them?
I believe some of falconne's plugins are included, but there have been several updates to them since the latest dfhack release so I would recommend getting the updated versions.  The growth/size bugfix is also newer than the last release. You can get my version of the growth/size bugfix from this post or from my github.  I also have a compiled plugin version that I haven't released yet, if you or others are interested I will post it.


>also if i activeate a plugin (workflow for example) do i need to reactivate every time i play or is there a way to make it par default?
I believe workflow is enabled per fort (or maybe per world), it will stay active for that fort/world after you start using it.  Other plugins should be enabled or disabled by way of the dfhack.init so that they don't need to be reactivated each time.


>in the readme there are activity management examples but i do not see how to set zone command on automated execution (for keeping animal population in a pasture for example with auto butcher and auto nestbox together it should work well but i do not see a way to automatize)
I have not yet used these myself to any great degree.

13
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 15, 2013, 02:27:41 pm »
the lua statement is unfinished.  It looks like you are trying to assign true like this:
Code: (lua) [Select]
dfhack.gui.getSelectedUnit().flags1.marauder = true

14
if you tell it to sort by profession, or any other grouped sort, they you should be able to toggle by clicking the related box in the group header.  Trying to toggle for a subset would still be problematic, but all woodcutters and all masons should work as long as that is their profession or custom profession.

15
Utilities and 3rd Party Applications / Re: DFHack 0.34.11 r3
« on: July 06, 2013, 04:36:43 pm »
I have a two quick questions.. I downloaded dfhack-0.34.11-r3-Windows.zip.

The scripts in the Hack/scripts/fix.. Are they run automatically? I can't seem to run them by name like the others. And sadly if they are auto run, they don't seem to be helping my FPS as I had hoped.

Also, I see some things like "fast-heat" in the readme, but can see no evidence of their existence in the files anywhere?

Run automatically: no, unless started from dfhack.init

Because they are in the fix sub-directory they need to called with fix/scriptname

fast heat is part of the tweak plugin and is usually run with "tweak fast-heat 500" in dfhack.init

if you don't have dfhack.init (in the dwarf fortress directory), copy or rename dfhack.init-example

Pages: [1] 2 3 ... 8