Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 298 299 [300] 301 302 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1399238 times)

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4485 on: September 02, 2013, 01:54:41 pm »

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.

Oddly enough when I tried unit.find I ran into errors. Hence the terrible loop through the site units that I wrote.
Now it seems to perform ok, I guess I had some typing errors back in the day.

Time to update all my scripts I guess :
fovcommand : https://gist.github.com/Devduweb/6350270
animaltrain : https://gist.github.com/Devduweb/6409714
« Last Edit: September 02, 2013, 01:57:44 pm by Boltgun »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4486 on: September 02, 2013, 11:12:31 pm »

I'm trying to get into C++ plugin writing, but as of now it's me throwing code at the wall and seeing what sticks, except I don't have a wall to throw the code at, so I'm going to throw it at you guys so you can tell me what's wrong. (Not if it's wrong, what is :P)

http://pastebin.com/UhYXrDMj

Clearly incomplete, but I want some feedback on what I have. I'm trying to make it so that the lua code in itemsyndrome can be run on equip, and, after looking around, that vmethod was the best I could find. Not sure if it does anything even remotely similar to what I want, though.

Spacebat

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4487 on: September 03, 2013, 01:25:49 am »

Okay... this is weird, I thought something might be wrong with the version of dfhack I have, but no, it appears this way on the github repository as well. All (or at least most) of the header files in the library contain #includes for header files that aren't where they think they are. Namely, it seems like these header files used to be under the directory "/df", but are now under "/modules". Am I doing something wrong here?

Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4488 on: September 03, 2013, 01:28:03 am »

Yes. Those header files are generated automatically when you build for the first time. Just go ahead and build once, and they'll appear where they're needed.
Logged

Spacebat

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4489 on: September 03, 2013, 02:30:10 am »

Oh, of course. I was trying to work straight off the .h and .cpp files like some sort of loose cannon vigilante programmer. Well, building solved that problem, even though it didn't seem to be entirely successful (8 succeeded, 3 failed), but I'm not going to look a gift horse in the mouth and try to untangle more problems that turn out to not actually be problems. I do enough of that with my usual programming.
Logged

Maulkin

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4490 on: September 03, 2013, 03:44:54 pm »

Hi!
Note sure if this is the right place to ask, but here goes:

Am i missing someting on the Workflow plugin, i enable it, and suddenly i cant delete old repeat jobs in Workshops, even those not covered by workflow Amount setups.

Is it some way to mark only the repeat jobs you want to not get canceled? since i cant manually delete them either with the plugin on, and its a hassle to jump back and forth disabeling it to cancel Repeat jobs i dont need anymore. OR in some cases where they have been adding up and so filling up the work queue.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4491 on: September 03, 2013, 03:48:49 pm »

Unrepeat them.

sirdave79

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4492 on: September 03, 2013, 07:37:23 pm »

I just attempted to use the marriage script posted earlier in the thread. I get the following output

d:\latest LNP\Dwarf Fortress 0.34.11\hack\scripts/marry.lua:60: Cannot write field histfig_hf_link_spousest.anon_1: not found.
stack traceback:
    [C]: in function '__newindex'
    d:\latest LNPzDwarf Fortress 0.34.11\hack\scipts/marry.lua:60 in function <d:\latest LNP\Dwarf Fortress 0.34.11\hack\scripts/marry.lua:5>
    [C]: in function 'with suspend'
    d:\latest LNP\Dwarf Fortress 0.34.11\hack\scripts/marry/lua:83. in main chunk

Can anybody advise what this means and what I might need to do to get the script to work for me ?

I used LUA and the command "print(dfhack.gui.getSelectedUnit().id)" to obtain 2 unit IDS 15218 and 14631, exited LUA and then typed

"marry 15218 14631"

and obtained the output above. Entering "marry x y" in LUA gives a syntax error and doesnt seem to run the command so I presume im right to run this in dfhack not LUA.

Cheers



Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4493 on: September 03, 2013, 08:41:30 pm »

anon_1 has probably been replaced with something else. Let me check...

EDIT: I think I've seen this fixed before.

EDIT 2: Replace all instances of "anon_1" with "link_strength" and hope that it doesn't mess anything up.
« Last Edit: September 03, 2013, 08:44:53 pm by Putnam »
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4494 on: September 03, 2013, 08:42:21 pm »

Hi!
Note sure if this is the right place to ask, but here goes:

Am i missing someting on the Workflow plugin, i enable it, and suddenly i cant delete old repeat jobs in Workshops, even those not covered by workflow Amount setups.

Is it some way to mark only the repeat jobs you want to not get canceled? since i cant manually delete them either with the plugin on, and its a hassle to jump back and forth disabeling it to cancel Repeat jobs i dont need anymore. OR in some cases where they have been adding up and so filling up the work queue.

What putnam said. Just remove the repeat before removing the job. The protection of repeated jobs is something that workflow does that, in my oppinion, should never be removed, because it's damn useful.
Logged

sirdave79

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4495 on: September 03, 2013, 08:58:57 pm »

Thanks for the reply Putnam.

I think your reply was to me ? I tried what you said. I didnt get a different output. Its late now though, ill try again tomorrow from scratch.

Cheers
Logged

Maulkin

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4496 on: September 04, 2013, 02:27:34 am »

Unrepeat them.

Doh! I feel sheepish! the one thing i did not try, and also THE MOST LOGICAL!!!!

Love the program, made my Df life a lot more fun. This.and evemon are must haves.

So.thanks for.the work!
Logged

Maulkin

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4497 on: September 04, 2013, 03:33:47 am »


What putnam said. Just remove the repeat before removing the job. The protection of repeated jobs is something that workflow does that, in my oppinion, should never be removed, because it's damn useful.

Yeah, its brilliant, just sometimes, i wantet to get rid of a repeat job, just could not figure it out...... turns out it was simple...  Must have been to simple fro my complex mind ;)
Logged

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4498 on: September 04, 2013, 09:27:34 am »

Is it possible for me to run an arbitrary lua script every few steps? If so, could someone show me how to set it up?

What I would like to be doing is to run a battle simulation in the arena, where I would have the script output health info on participants and make slight changes to certain variables over time. I can do this now by toggling to the dfhack command window and manually running the script, but automating the process would certainly save my fingers some trouble.

Unrelated, how could I run the "cls" command or duplicate its effects to clear the dfhack command window from inside a lua script?

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4499 on: September 04, 2013, 12:35:40 pm »

Code: [Select]
function example()
    print("Hello, world!")
    dfhack.timeout(50,"ticks",example)
end

I don't think that works in arena mode, though...
Pages: 1 ... 298 299 [300] 301 302 ... 373