Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 348 349 [350] 351 352 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1459227 times)

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5235 on: February 14, 2014, 07:47:37 am »

Anyone know how to use eventful.onUnitDeath?

I tried to use this very simple code to test it:

Code: [Select]
local eventful = require 'plugins.eventful'

eventful.enableEvent(eventful.eventType.UNIT_DEATH,5)

eventful.onUnitDeath=function(u)
local unit = u
print('unit died.')
end

But nothing happens.  I also tried putting the eventful.onUnitDeath inside a constantly repeating function, but still no effect.  Does anyone know of a script that uses this function?
Try eventful.onUnitDeath.someRandomName=function(u)...
Also it's not a unit, but a unit id (i think).

That just gives an error "attempt to index field 'onUnitDeath' (a function value)".

EDIT: Some other eventful functions, like onInventoryChange, work in the same circumstances.  I think onUnitDeath might operate differently.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5236 on: February 14, 2014, 07:56:12 am »

so strange. It works for me (did this in console):
Code: [Select]
lua
ev=require 'plugins.eventful'
~ev
(echo lots of lines, one relevant) :
onUnitDeath              = <event: 0 listeners>
ev.onUnitDeath.bla=function(u_id) print("unit_died"..u_id) end
ev.enableEvent(eventful.eventType.UNIT_DEATH,5)
and then it printed unit_died0, unit_died2, etc...

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5237 on: February 14, 2014, 08:12:53 am »

Uh...
Is that even lua?

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5238 on: February 14, 2014, 08:14:34 am »

Uh...
Is that even lua?
~ev -> printall(ev)
!ev -> print(ev)
it's an extension to the lua console for fast usage.
A script would look like this:
Code: [Select]
local ev=require 'plugins.eventful'
ev.onUnitDeath.bla=function(u_id) print("unit_died"..u_id) end
ev.enableEvent(eventful.eventType.UNIT_DEATH,5)

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5239 on: February 14, 2014, 08:29:54 am »

Well, that worked for some reason.  Thanks!

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5240 on: February 14, 2014, 10:16:28 am »

Anyone know how to use eventful.onUnitDeath?

I tried to use this very simple code to test it:

Code: [Select]
local eventful = require 'plugins.eventful'

eventful.enableEvent(eventful.eventType.UNIT_DEATH,5)

eventful.onUnitDeath=function(u)
local unit = u
print('unit died.')
end

But nothing happens.  I also tried putting the eventful.onUnitDeath inside a constantly repeating function, but still no effect.  Does anyone know of a script that uses this function?
Try eventful.onUnitDeath.someRandomName=function(u)...
Also it's not a unit, but a unit id (i think).

That just gives an error "attempt to index field 'onUnitDeath' (a function value)".

EDIT: Some other eventful functions, like onInventoryChange, work in the same circumstances.  I think onUnitDeath might operate differently.

That's because you literally replaced the entire onUnitDeath event with your function the first time.

Raidau

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5241 on: February 14, 2014, 09:55:32 pm »

Is there a way to change zoom level using script? I know there are variables that control window size, somewhere in df.global...
Logged
Marital status manipulator
Custom item descriprions
Natural Balance Mod (2013-2015) development suspended...

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5242 on: February 15, 2014, 05:26:18 pm »

Is there a way to run a function whenever the game is saved?  I need to retain some persistent variables accurately but saving them every frame causes major slowdown.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5243 on: February 15, 2014, 05:29:11 pm »

Is there a way to run a function whenever the game is saved?  I need to retain some persistent variables accurately but saving them every frame causes major slowdown.
Have you seen dfhack persistence module? linky
Edit: ah sorry, misread. Afaik there is no event that triggers when a game is saved (or before unload).
« Last Edit: February 15, 2014, 05:33:14 pm by Warmist »
Logged

Bo-Rufus CMVII

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5244 on: February 16, 2014, 03:19:18 am »

When a caravan is attacked and runs off leaving one of the guards behind, should you use fixmigrant to adopt him, or will that make him a slave?
Logged

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5245 on: February 16, 2014, 05:11:23 am »

Is there a way to run a function whenever the game is saved?  I need to retain some persistent variables accurately but saving them every frame causes major slowdown.

If you are doing something every frame, it may be better done in C++, and the persistence API there is more low-level and allows you to keep a reference to the actual memory used to store the data, so it can be modified without any overhead. The downside of course is that you can crash some plugins if you delete their persistence entries without telling them, e.g. via the lua api.
Logged

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: DFHack 0.34.11 r3
« Reply #5246 on: February 16, 2014, 01:10:42 pm »

Is there a way to run a function whenever the game is saved?  I need to retain some persistent variables accurately but saving them every frame causes major slowdown.

If you are doing something every frame, it may be better done in C++, and the persistence API there is more low-level and allows you to keep a reference to the actual memory used to store the data, so it can be modified without any overhead. The downside of course is that you can crash some plugins if you delete their persistence entries without telling them, e.g. via the lua api.

I'd like to be able to mod things in C++, but I honestly don't know where to begin.  What program can I use to edit them?

Also, is there any way of making a workshop that copies the native reactions and behaviors of the smelter/forge, but without needing to use fuel?

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5247 on: February 16, 2014, 01:58:50 pm »

Is there a way to run a function whenever the game is saved?  I need to retain some persistent variables accurately but saving them every frame causes major slowdown.

If you are doing something every frame, it may be better done in C++, and the persistence API there is more low-level and allows you to keep a reference to the actual memory used to store the data, so it can be modified without any overhead. The downside of course is that you can crash some plugins if you delete their persistence entries without telling them, e.g. via the lua api.

I'd like to be able to mod things in C++, but I honestly don't know where to begin.  What program can I use to edit them?

You can technically use, say, Notepad to write C++, but it'd be better to go with a more robust IDE like Code::Blocks or something.

Here's compilation instruction

wooks

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5248 on: February 16, 2014, 06:42:43 pm »

Is there a way to reset a moods gathered items? or force it to complete? I seem to have curfuffled one of my important dwarfs moods by accidentally forbidding something he was retrieving and now he won't complete the mood (I even tried using the plainpacked glitch to get an extra of what he needed). Thank You!
Logged
In a game like Dwarf Fortress, going to the wiki being cheating is like saying bringing a parachute is cheating for skydiving.
"Has it been 4 days? Better check if my penis is still there again."

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #5249 on: February 17, 2014, 01:24:42 am »

I'm trying to get the physical and mental attributes of a unit. This says that dfhack.units.getPhysicalAttrValue should work, but when I do a printall(dfhack.units) I don't see the physical or the mental one. Any thoughts?

I know I can look at a units attributes with unit.body.physical_attrs, but I was hoping for the aforementioned ones ability to compute effective levels.
Logged
Pages: 1 ... 348 349 [350] 351 352 ... 373