Bay 12 Games Forum

Please login or register.

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

Author Topic: DFHack 0.34.11 r3  (Read 1455694 times)

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4500 on: September 04, 2013, 01:03:13 pm »

Code: [Select]
    dfhack.timeout(50,"ticks",example)
I don't think that works in arena mode, though...

There is a "frames" timer which always works, but it counts frames and will fire regularly even when the game is paused.
Logged

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4501 on: September 04, 2013, 02:55:47 pm »

Code: [Select]
    dfhack.timeout(50,"ticks",example)
I don't think that works in arena mode, though...

There is a "frames" timer which always works, but it counts frames and will fire regularly even when the game is paused.

Thanks, I'll experiment with this when I get home (to my computer with DF).

Is there a danger of overflow due to lengthy or infinite recursion?

Would the code below allow the automatic termination of the script?
Code: [Select]
function example()
    print("Hello, world!")
    if foo(spam) == false then
         dfhack.timeout(50,"ticks",example)
    end if
end

How do you manually end the script? Is this something that allows DF to run, but locks up the dfhack command window until you exit the script or force-close dfhack? I guess that I can't activate the repeating script and then use other dfhack commands.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4502 on: September 04, 2013, 03:09:50 pm »

Code: [Select]
if string.lower(...) == "disable" then
    example = nil
end

If it helps, itemsyndrome is a repeating command exactly like this one.

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4503 on: September 04, 2013, 03:21:03 pm »

How do you manually end the script? Is this something that allows DF to run, but locks up the dfhack command window until you exit the script or force-close dfhack? I guess that I can't activate the repeating script and then use other dfhack commands.

Incorrect. The script execution ends, but the code remains in memory and will be called after the time elapses. When it does, it can request to be called again after a while, and so on. Global variable values are shared between all calls to a script, so this background code and later direct calls to the script can interact. For instance, what that "example = nil" above does is clear the global variable that holds the reference to the function, so the next time it tries to do dfhack.timeout in the background it doesn't do anything.

This may be cleaner though:

Code: [Select]
function example()
  print('Tick!')

  if not dfhack.timeout_active(timeout_id) then
    timeout_id = dfhack.timeout(50,"frames",example)
  end
end

if string.lower(...) == "disable" then
  dfhack.timeout_active(timeout_id, nil)
else
  example()
end

The advantage is that if the script is called twice before the timer has a chance to fire, it won't start two "threads" of timers - that check in the example function prevents it by tracking the active timer via the timeout_id global variable. Or you can always cancel the running timer and start a new one when the script is run explicitly:

Code: [Select]
function example()
  print('Tick!')
  timeout_id = dfhack.timeout(50,"frames",example)
end

dfhack.timeout_active(timeout_id, nil)
if string.lower(...) ~= "disable" then
  example()
end
« Last Edit: September 04, 2013, 03:43:59 pm by ag »
Logged

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4504 on: September 04, 2013, 08:12:51 pm »

Does anyone know why I get redundant reports on tweaks when I start dfhack?



I've checked the stuff that's obvious to me, and I'm stumped. 
Spoiler: dfhack.init (click to show/hide)
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4505 on: September 04, 2013, 09:31:22 pm »

I get them too.

Taverius

  • Bay Watcher
  • Curly says go!
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4506 on: September 04, 2013, 11:09:14 pm »

Autolabor is pretty awesome, but the ignore-on-burrow plays hell with civilian alerts.

Would probably be better with something with custom profession names, ie profession ending in '-' is ignored or something.
Logged
The early bird gets the worm, but the second mouse gets the cheese.

Spacebat

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4507 on: September 05, 2013, 12:41:55 am »

Can anybody enlighten me as to the significance of the numbers here? They seem to correlate to what kind of event you're listening for (all the syndrome handlers use 1, job_completed handlers use 5), but I can't for the life of me figure out why.



Edit: woops, forgot image.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4508 on: September 05, 2013, 01:18:18 am »

Can anybody enlighten me as to the significance of the numbers here? They seem to correlate to what kind of event you're listening for (all the syndrome handlers use 1, job_completed handlers use 5), but I can't for the life of me figure out why.



Edit: woops, forgot image.
Could be wrong, but i think it's check frequency. So in a  sense syndromes are checked 5 times more frequently then job_completed. This is done to prevent lag as much as possible because depending on event type it could be iterating through HUGE arrays each N ticks.

Taverius

  • Bay Watcher
  • Curly says go!
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4509 on: September 05, 2013, 01:22:47 am »

Does anyone have any documentation for autofarm?
Logged
The early bird gets the worm, but the second mouse gets the cheese.

Spacebat

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4510 on: September 05, 2013, 02:00:49 am »

EDIT 2: ELECTRIC BOOGALOO I figured it out, I needed to #include "df/job.h", not just "modules/Job.h". Gawddamn names. Now to wait for the next problem.

I'm trying to do things with the item that a job is using, but this is like a navigating a 4-dimensional maze. With a blindfold on. Is there any chance someone could give me a tip on how to get the item object a job is using? according to this, it should be passing my listener a pointer to an object of type df::job, but I can't seem to actually do anything with the object. The IDE tells me an incomplete type is not allowed.
EDIT: i should say it tells me that when I try to cast it to a (df::job*) pointer, when I don't it just tells me it doesn't have a pointer-to-class type, which I thought should be remedied by casting it as the type I know it is already (df::job*).





God I hope I'm not missing something incredibly simple as usual.
« Last Edit: September 05, 2013, 02:37:59 am by Spacebat »
Logged

Spacebat

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4511 on: September 05, 2013, 04:09:45 am »

And of course, I can't build it for various mysterious reasons I'll probably have to make a pact with some elder god to solve.

gzip_stream.obj : error LNK2019: unresolved external symbol deflate referenced in function "public: bool __cdecl google::protobuf::io::GzipOutputStream::Close(void)" (?Close@GzipOutputStream@io@protobuf@google@@QEAA_NXZ)

I suspect these errors lead to

fatal error C1083: Cannot open include file: 'CoreProtocol.pb.h': No such file or directory

Anyone with a similar problem?
Logged

Spacebat

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4512 on: September 05, 2013, 04:41:04 am »

Alright, that linker issue is solved, now there's some other issues but i'm way too tired for this now.
Logged

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4513 on: September 05, 2013, 10:53:12 am »

Does anyone know why I get redundant reports on tweaks when I start dfhack?

That's because it prints one line per hook:

Spoiler (click to show/hide)
Logged

Spacebat

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4514 on: September 05, 2013, 11:57:53 am »

So, every plugin (including the default ones, so it's not my code that's an issue) I've built makes DF crash (on startup). compile.html says "When you open the solution in MSVC, make sure you never use the Debug builds. Those aren't binary-compatible with DF. If you try to use a debug build with DF, you'll only get crashes." But I'm using Release, not Debug, not even RelWithDebInfo. I tried building ALL_BUILD and PACKAGE and using the dlls output by each, both caused exactly the same crashes. Again, it's not my code, all the other plugins do it too.

Am I building the wrong package or something? There seems to be a syntax error or two when compiling "misery" and "prospector", but errors in those shouldn't make entirely unrelated plugins crash.
Logged
Pages: 1 ... 299 300 [301] 302 303 ... 373