Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: dfHack 43.05 - list/extract (point) Notes ?  (Read 2319 times)

mstram

  • Bay Watcher
    • View Profile
dfHack 43.05 - list/extract (point) Notes ?
« on: December 03, 2017, 09:13:53 am »

Is there a way in DfHack 43.05 to list all the Notes (location and contents) from a Dwarf Fortress world ?

I searched through all the script files, and found some "NotesPoints" references that looked like they were just for building the GUI.
Logged

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #1 on: December 03, 2017, 05:45:27 pm »

Is there a way in DfHack 43.05 to list all the Notes (location and contents) from a Dwarf Fortress world ?

I searched through all the script files, and found some "NotesPoints" references that looked like they were just for building the GUI.

This?
Code: [Select]
df.global.ui.waypoints.points

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #2 on: December 03, 2017, 07:19:53 pm »

Be aware that this will only include the Notes left in the context of the current fortress - notes left on the Embark Map aren't yet known to DFHack (I'm in the process of adding them right now).
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

mstram

  • Bay Watcher
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #3 on: December 03, 2017, 08:24:58 pm »

Is there a way in DfHack 43.05 to list all the Notes (location and contents) from a Dwarf Fortress world ?

I searched through all the script files, and found some "NotesPoints" references that looked like they were just for building the GUI.

This?
Code: [Select]
df.global.ui.waypoints.points

Thanks !

That works pasting in to gui\gm-editor.

I'm guessing ? there must be some lua syntax to "pretty print" the structure(s) for "text" output ?


I tried modifying the "position.lua" script:

Code: [Select]
print(df.global.ui.waypoints.points[0])
got:

Code: [Select]
<vector<ui.T_waypoints.T_points*>[2]: 00000001413565F0>

I'm not fluent in Lua, but it seems ?  <vector> is not a native Lua type ?
Logged

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #4 on: December 03, 2017, 08:38:47 pm »


I'm not fluent in Lua, but it seems ?  <vector> is not a native Lua type ?

Use printall() instead, or just "~", as in
Code: [Select]
~df.global.ui.waypoints.points
vector is a C++ type but you can use it as a Lua table, e.g. iterate with ipairs() and index

mstram

  • Bay Watcher
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #5 on: December 03, 2017, 09:00:35 pm »

Code: [Select]
printall(df.global.ui.waypoints.points)
gives :

Code: [Select]
0                        = <ui.T_waypoints.T_points: 00000000346E0550>
1                        = <ui.T_waypoints.T_points: 00000000346E0730>

Not quite as "pretty" as I'm hoping for ;)

Code: [Select]
print (~df.global.ui.waypoints.points)
Code: [Select]
.scripts/p.lua:56: attempt to perform bitwise operation on a user data value (field 'points')
Logged

mstram

  • Bay Watcher
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #6 on: December 04, 2017, 04:55:58 am »

Ok, found the code in gm-editor.lua / function GmEditorUi:pushTarget

Thanks for the hints on what to look for.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #7 on: December 04, 2017, 12:37:55 pm »

Ok, found the code in gm-editor.lua / function GmEditorUi:pushTarget

Thanks for the hints on what to look for.
Oh wow... I'll give you kudos for that. That file is unreadable :|

mstram

  • Bay Watcher
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #8 on: December 04, 2017, 02:03:03 pm »

Ok, found the code in gm-editor.lua / function GmEditorUi:pushTarget

Thanks for the hints on what to look for.
Oh wow... I'll give you kudos for that. That file is unreadable :|

Heh, trial and errror  .... every now and then a "blind animal finds ...."

I know a tiny bit of Lua, the rest I "google".

While using gm-editor works for producing text output, I still have to interactively "pick" / edit an entry for it to be "dumped" to the console.

There should be a way to just iterate over all the notes in a script and dump them out.  Well that IS, sorta what the interactive editor is doing (one at a time).

It looks like the
Code: [Select]
df.global.ui.waypoints.points "thing" (native C++ structure) needs to be transformed into a lua table, for the data to be extracted ?

I've copied the
Code: [Select]
pushTarget function to a new file, and I'm trying to get it work "non-interactively", but I'm still "groping in the dark"
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #9 on: December 04, 2017, 03:09:08 pm »

Ok, found the code in gm-editor.lua / function GmEditorUi:pushTarget

Thanks for the hints on what to look for.
Oh wow... I'll give you kudos for that. That file is unreadable :|

Heh, trial and errror  .... every now and then a "blind animal finds ...."

I know a tiny bit of Lua, the rest I "google".

While using gm-editor works for producing text output, I still have to interactively "pick" / edit an entry for it to be "dumped" to the console.

There should be a way to just iterate over all the notes in a script and dump them out.  Well that IS, sorta what the interactive editor is doing (one at a time).

It looks like the
Code: [Select]
df.global.ui.waypoints.points "thing" (native C++ structure) needs to be transformed into a lua table, for the data to be extracted ?

I've copied the
Code: [Select]
pushTarget function to a new file, and I'm trying to get it work "non-interactively", but I'm still "groping in the dark"

Although the thing is a native c++ structure, the lua bindings are so flexible that usually you don't care. Depends on what you want to print, but it can be as simple as:
Code: [Select]
for i,point in ipairs(df.global.ui.waypoints.points) do
    print(point.id,point.name,point.comment)
end

mstram

  • Bay Watcher
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #10 on: December 04, 2017, 04:04:00 pm »

Where are these Lua bindings documented ?

Or whee are they in the source code ?

A google for "dfhack lua bindings" gives  The Lua API,, (with nothing specific there to this topic of "notes"
https://github.com/DFHack/dfhack/blob/master/docs/Lua%20API.rst
Logged

mstram

  • Bay Watcher
    • View Profile
Re: dfHack 43.05 - list/extract (point) Notes ?
« Reply #11 on: December 04, 2017, 04:06:54 pm »


Although the thing is a native c++ structure, the lua bindings are so flexible that usually you don't care. Depends on what you want to print, but it can be as simple as:
Code: [Select]
for i,point in ipairs(df.global.ui.waypoints.points) do
    print(point.id,point.name,point.comment)
end

Thanks, that's just (about) what I needed.

I was able to guess at 
Code: [Select]
point.pos.x,point.pos.y,point.pos.z from your code
« Last Edit: December 04, 2017, 04:10:56 pm by mstram »
Logged