Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 288 289 [290] 291 292 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1396354 times)

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4335 on: August 01, 2013, 12:26:13 am »

If you, say, run "typeHandleExample(5)", you'll get "Argument is a number". If you run "typeHandleExample("foo")", you'll get "Argument is not a number".
Also you can overload to other types with "type(value)=='string' " or "type(value)=='table' ". This is efficient because string equality comparison is O(1) in lua.
I'm doing something wrong and I can't figure out what. I have:
Spoiler (click to show/hide)

And I keep getting the error:
Spoiler (click to show/hide)

So something is wrong with how I am trying to use the Lua::SetField things, but I cannot for the life of me see what the problem could be. Help :(
As the second spoiler points it's a linking error. In cmake file add "LINK_LIBRARIES LUA" like here: https://github.com/warmist/dfhack/blob/master/plugins/CMakeLists.txt#L115 to link with lua lib.
On the other hand smallish things like this are better done in lua, because it's more trouble to compile, link, export and manage c++ plugins. C++ is reserved for high-performance (e.g. accessing all map by tiles) or imposible to do in lua (vmethod interposing). The rest can use lua (or ruby afaik) and all data structures are accesible in it. This could be lua code:
Code: [Select]
local utils = require("utils") --for call_with_string

function getFeature(name)
    for index,value in ipairs(df.global.world.cur_savegame.map_features) do
if utils.call_with_string(value,"getName")==name then
return value
end
end
end
-- call with string wraps function with temporary string to put value in
-- in a similar way:
function featureList()
local ret={}
for index,value in ipairs(df.global.world.cur_savegame.map_features) do
local featureType=value:getType()
table.insert(ret,{name=utils.call_with_string(value,"getName"), type=df.feature_type[featureType]})
end 
return ret
end
As for submitting your code to dfhack: either fork all of dfhack and then issue pull request in github (i think there was a way without forking...) or ask in irc (#dfhack in freenode, see first post) for peterix to merge in.

@ccna: looks like your install is corrupted somehow. Try reinstalling.

silentdeth

  • Bay Watcher
    • View Profile
    • Let's Play Dwarf Fortress: Mastwork Mod Season 1
Re: DFHack 0.34.11 r3
« Reply #4336 on: August 01, 2013, 12:49:48 am »

Ah, I did not think you could access those data structures from lua. This makes things so much easier. Thanks, tons and tons.
Logged
Let's Play Dwarf Fortress: Masterwork Mod Season 1 | Season 2
Let's Play Kobold Fortress: Masterwork Mod Season 1 | Season 2

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4337 on: August 01, 2013, 12:54:47 am »

Ah, I did not think you could access those data structures from lua. This makes things so much easier. Thanks, tons and tons.

I can't really think of any you can't, except some odd arrays.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4338 on: August 01, 2013, 02:03:18 am »

Ah, I did not think you could access those data structures from lua. This makes things so much easier. Thanks, tons and tons.

I can't really think of any you can't, except some odd arrays.
Actually everything that is accessible from c++ is also accessible from lua because the same code that generates c++ structures also generates lua structs.

silentdeth

  • Bay Watcher
    • View Profile
    • Let's Play Dwarf Fortress: Mastwork Mod Season 1
Re: DFHack 0.34.11 r3
« Reply #4339 on: August 01, 2013, 06:59:47 am »

Tired of working on it. Finished it, some of things are probably not the best way of doing it, but it works. And it should be similar enough to the feature plugin that no one will be overly confused.

Spoiler (click to show/hide)
Logged
Let's Play Dwarf Fortress: Masterwork Mod Season 1 | Season 2
Let's Play Kobold Fortress: Masterwork Mod Season 1 | Season 2

Ccna

  • Escaped Lunatic
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4340 on: August 01, 2013, 03:46:35 pm »

reinstalling still gives me the error :(
if it helps, this is my stdout file:

Spoiler (click to show/hide)

im on windows, and removing STD.dll allows me to play the normal game as far as I can tell.
Logged

thistleknot

  • Bay Watcher
  • Escaped Normalized Spreadsheet Berserker
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4341 on: August 02, 2013, 04:22:09 pm »

using lua, can I grab the max attainable stat for a dwarf (which is x2 of starting value).  Splinterz uses it in his Dwarf Therapist (when you hover the mouse cursor over a dwarf's attribute, you'll see the max possible as such current/max).

Anyways, I noticed vjek's Armoks_blessing script doesnt affect max value, and I was hoping to modify it...

Does AG have a data objects list for the data structure's he's done, to my understanding, that's how all this lua scripting is done.  Is there an easy way to load up these data objects in some ide, so I can see them all?

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4342 on: August 02, 2013, 04:33:29 pm »

Yeah, the max is stored as part of the attribute.  For physical attributes I think it's unit.body.physical_attrs.STRENGTH.max for example.  For mental attributes it's unit.status.current_soul.mental_attrs.WHATEVER.max instead I think.  Can't check at the moment since I'm at work.
Logged
Through pain, I find wisdom.

thistleknot

  • Bay Watcher
  • Escaped Normalized Spreadsheet Berserker
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4343 on: August 02, 2013, 04:38:01 pm »

thx, that really helps, I found this but didn't have max in there, it would be nice if all these objects were browse-able somewhere as some sort of library.

do you know if max is a read only value or can it be manipulated?

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4344 on: August 02, 2013, 05:01:43 pm »

thx, that really helps, I found this but didn't have max in there, it would be nice if all these objects were browse-able somewhere as some sort of library.

do you know if max is a read only value or can it be manipulated?

It's max_value, and it can be.

Also, the objects are browsable here. You can also use interactive lua console in DFHack with printall to look through stuff. The specific xml you want is here.

thistleknot

  • Bay Watcher
  • Escaped Normalized Spreadsheet Berserker
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4345 on: August 02, 2013, 06:12:49 pm »

thx, that really helps, I found this but didn't have max in there, it would be nice if all these objects were browse-able somewhere as some sort of library.

do you know if max is a read only value or can it be manipulated?

It's max_value, and it can be.

Also, the objects are browsable here. You can also use interactive lua console in DFHack with printall to look through stuff. The specific xml you want is here.

took me a while to figure out printall
http://www.bay12forums.com/smf/index.php?topic=91166.msg3470560#msg3470560

wait... no, not exactly sure how to use it, I get a unrecognized command using printall

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4346 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"

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4347 on: August 02, 2013, 09:48:51 pm »

thx, that really helps, I found this but didn't have max in there, it would be nice if all these objects were browse-able somewhere as some sort of library.

do you know if max is a read only value or can it be manipulated?

It's max_value, and it can be.

Also, the objects are browsable here. You can also use interactive lua console in DFHack with printall to look through stuff. The specific xml you want is here.

took me a while to figure out printall
http://www.bay12forums.com/smf/index.php?topic=91166.msg3470560#msg3470560

wait... no, not exactly sure how to use it, I get a unrecognized command using printall

You have to type "lua" first.

thistleknot

  • Bay Watcher
  • Escaped Normalized Spreadsheet Berserker
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4348 on: August 03, 2013, 06:52:22 am »

warmist gave me this tidbit

gui/gm-editor df.global.world.raws.creatures.all[466].caste[0].attributes

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4349 on: August 03, 2013, 08:20:54 am »

warmist gave me this tidbit

gui/gm-editor df.global.world.raws.creatures.all[466].caste[0].attributes
or a more generic:
for all stuff in df:
gui/gm-editor df.global
when having unit selected in gui:
gui/gm-editor
for adventurer:
gui/gm-editor df.global.world.units.active[0]
Pages: 1 ... 288 289 [290] 291 292 ... 373