Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3

Author Topic: DFusion - a dfhack plugin for who knows what...  (Read 35654 times)

archit3

  • Escaped Lunatic
    • View Profile
Re: DFusion - a dfhack plugin for writing lua plugins.
« Reply #15 on: April 05, 2012, 10:04:43 am »

Hello :)
I have been trying to make combat announcements by editing /data/init/announcements.txt but it didn't worked out. I want to make some kind of "pup up" message (more visible than red "C" in the corner). Is it possible to achive this kind of functionality with DFusion?
Logged

Ghills

  • Bay Watcher
    • View Profile
Re: DFusion - a dfhack plugin for writing lua plugins.
« Reply #16 on: April 13, 2012, 02:00:16 pm »

Embark anywhere crashes DF.  Get a "Process has stopped working" message. 

Is there a timeline on when that plugin will be fully ported over?
Logged
I AM POINTY DEATH INCARNATE
Ye know, being an usurper overseer gone mad with power isn't too bad. It's honestly not that different from being a normal overseer.
To summarize:
They do an epic face. If that fails, they beat said object to death with their beard.

mostly_harmless

  • Escaped Lunatic
    • View Profile
Re: DFusion - a dfhack plugin for writing lua plugins.
« Reply #17 on: August 06, 2012, 01:27:11 pm »

Hope this thread is still alive.
I am new to dhack and dfusion.
I want to leave my fortress (not abandon it completely) and start up a new fortress somewhere, which then gets caravans from the old fortress (king arrived there).
I understand I can do that with a combination of dhack and dfusion.
However, when I type dfusion in the dhack window I get:
Quote
dfusion/common.lua:45: ,Text region not found!
stack traceback:
[C]: in function 'error'
dfusion/common.lua:45: in function 'GetTextRegion'
dfusion/common.lua:89: in fucntion 'unlockDF'
dfusion/init.lua:66: in main chunk
Am I missing any crucial step before that?

Thanks
mh
Logged

mostly_harmless

  • Escaped Lunatic
    • View Profile
Re: DFusion - a dfhack plugin for writing lua plugins.
« Reply #19 on: August 06, 2012, 03:28:55 pm »

Thank you.
Logged

Akjosch

  • Bay Watcher
    • View Profile
Re: DFusion - a dfhack plugin for writing lua plugins.
« Reply #20 on: September 19, 2012, 03:40:59 pm »

I have to say, I love this little tool. I always wanted to be able to rename my Dwarves (not just give them a nick name, rename them!) - and now I can!

Code: [Select]
figs=df.global.world.history.figures
units=df.global.world.units.active
for _,v in ipairs(units) do
  if v.race == df.global.ui.race_id and v.name.nickname and v.name.nickname ~= "" then
    v.name.first_name = v.name.nickname
    for _2,f in ipairs(figs) do
      if v.hist_figure_id  == f.id then
        f.name.first_name = v.name.nickname
      end
    end
    v.name.nickname = ""
  end
end

Just awesome. :)
Logged

IamanElfCollaborator

  • Bay Watcher
  • Resident God of Shipping (and Posting)
    • View Profile
    • The Final Fantasy Mod. Welcome to the world of Bahamut!
Re: DFusion - a dfhack plugin for writing lua plugins.
« Reply #21 on: September 19, 2012, 03:45:07 pm »

 ......you just made my day.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #22 on: September 20, 2012, 03:53:15 am »

Code: [Select]
function idlechange(unit)
--local myoff=offsets.getEx("AdvCreatureVec")
--local vector=engine.peek(myoff,ptr_vector)
print("Self or at position? (s or anything else):");
local r=getline()
local unit
if r=="s" or r=="S" then
unit=getAdv()
else
if unit==nil then
unit=getCreatureAtPos(getxyz())
end
end
local sx,sy,sz
sx=unit.pos.x
sy=unit.pos.y
sz=unit.pos.z
print("Current coords:"..sx.." "..sy.." "..sz)
print("Jump where (coordinates in form 'dx dy dz' or 'c' for cursor):")
r=getline()
local tx,ty,tz
if r=="c" then
tx,ty,tz=getxyz()
else
lp=string.gmatch(r,"%-?%d+")
--local d
--d=lp()
tx=sx+tonumber(lp())
ty=sy+tonumber(lp())
tz=sz+tonumber(lp())
end
print("Warp to coords:"..tx.." "..ty.." "..tz)
unit.path.dest.x=tx
unit.path.dest.y=ty
unit.path.dest.z=tz
end
tools.menu:add("Move here",idlechange)
this code will allow you to move NPCS out of the way or path them some where you want to go. tested in adventure mode
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #23 on: September 23, 2012, 04:46:06 pm »

Would there be a simple way to remove a name from a creature--E.G, turn "Urist Dastotmorul" into "Urist Dastot"?

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #24 on: September 24, 2012, 02:17:48 am »

there is but not a simple one.

Akjosch

  • Bay Watcher
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #25 on: September 24, 2012, 03:01:17 pm »

Would there be a simple way to remove a name from a creature--E.G, turn "Urist Dastotmorul" into "Urist Dastot"?

Yes.

Put the following script in your Dwarf Fortress directory, as "dfhack\scripts\shortname.lua":

Code: [Select]
function shorten_last_name()
  unit = dfhack.gui.getSelectedUnit()
  if unit == nil then
    print("No unit under cursor!  Aborting.")
    return
  end
  figs = df.global.world.history.figures
  for _,f in ipairs(figs) do
      if unit.hist_figure_id == f.id then
        f.name.words[1] = -1
        unit.name.words[1] = -1
      end
    end
end
shorten_last_name()

Now, in the game, open up your shortcuts list ("H"), pick some unused, and name ("n") it "shortname" (without the quotes).

Use "k" to select a character, then hit your just assigned hotkey.

Instead of assigning hotkeys, you can instead just use "k" to select the character, then switch to the dfhack window and type in "shortname" (again, without the quotes). There's also a "keybinding" command in DFHack which could allow you to bind any key to the functionality, but I didn't use it yet; its help looks like this:

Code: [Select]
Usage:
  keybinding list <key>
  keybinding clear <key>[@context]...
  keybinding set <key>[@context] "cmdline" "cmdline"...
  keybinding add <key>[@context] "cmdline" "cmdline"...
Later adds, and earlier items within one command have priority.
Supported keys: [Ctrl-][Alt-][Shift-](A-Z, or F1-F9, or Enter).
Context may be used to limit the scope of the binding, by
requiring the current context to have a certain prefix.
Current UI context is: dwarfmode/LookAround/Unit


« Last Edit: September 24, 2012, 03:16:44 pm by Akjosch »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #26 on: September 24, 2012, 08:06:24 pm »

Hmm... How about making it universal?

Akjosch

  • Bay Watcher
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #27 on: September 24, 2012, 11:44:40 pm »

Hmm... How about making it universal?

You'll have to be a bit more precise, I'm afraid. What do you mean with "universal"? It already works with everything you can target that has a name, including traders, their guards, invaders or forgotten beasts.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #28 on: September 25, 2012, 11:27:07 pm »

Work for every hist figure on-site without using the cursor.

Akjosch

  • Bay Watcher
    • View Profile
Re: DFusion - a dfhack plugin for who knows what...
« Reply #29 on: September 25, 2012, 11:41:41 pm »

Work for every hist figure on-site without using the cursor.

Almost the same code, I think, though I didn't check it (I don't have a running older fort for it):

Code: [Select]
-- Shorten the surnames of all units on sight to one word
-- Doesn't affect the additional surnames given by heroic deeds
-- Those are stored in .name.words[2] through ...words[6]

function shorten_all_names()
  units = df.global.world.units.all
  for _uid,unit in ipairs(df.global.world.units.all) do
    figs = df.global.world.history.figures
    for _,f in ipairs(figs) do
      if unit.hist_figure_id == f.id then
        f.name.words[1] = -1
        unit.name.words[1] = -1
      end
    end
  end
end
shorten_all_names()
Logged
Pages: 1 [2] 3