Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Can someone help me with DFusion  (Read 1679 times)

HavingPhun

  • Bay Watcher
    • View Profile
Can someone help me with DFusion
« on: September 22, 2012, 02:46:44 pm »

I have some questions.

1. How do I use it?

2. How can I learn how to use it. There are no tutorials anywhere (I couldn't find any).

3. Does anyone have a dfusion script that will turn a dwarf into a legendary soldier, in all the military skills? How do I use it?

Could someone help me please. Thanks.
Logged

HavingPhun

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #2 on: September 22, 2012, 03:13:38 pm »

http://dwarffortresswiki.org/index.php?title=Utility:DFusion
I looked at that before and all it did was confuse me,
It isn't really specific about anything, like where to put the code and how it all works. I know where the lua manual is too.
« Last Edit: September 22, 2012, 03:15:26 pm by HavingPhun »
Logged

smakemupagus

  • Bay Watcher
  • [CANOPENDOORS]
    • View Profile
Re: Can someone help me with DFusion
« Reply #3 on: September 22, 2012, 04:16:27 pm »

Well, unfortunately the answer to your question #2 is basically "learn C," which is beyond the scope of what people can probably help you with here on the bayforums.  I don't believe there is currently anything more tutorial than that wiki page and the thread it links too.  Good luck!

The code goes in a lua script file anywhere on your computer, a convenient place being maybe <your Dwarf fortress path>/dfusion.  Then you point to that filepath when you call the script.  Typically you are using DFusion with DFhack, in which case at the DFhack console you type

Code: [Select]
lua dfusion/yourfile.lua
« Last Edit: September 22, 2012, 04:22:09 pm by smakemupagus »
Logged

HavingPhun

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #4 on: September 22, 2012, 05:08:08 pm »

Well, unfortunately the answer to your question #2 is basically "learn C," which is beyond the scope of what people can probably help you with here on the bayforums.  I don't believe there is currently anything more tutorial than that wiki page and the thread it links too.  Good luck!

The code goes in a lua script file anywhere on your computer, a convenient place being maybe <your Dwarf fortress path>/dfusion.  Then you point to that filepath when you call the script.  Typically you are using DFusion with DFhack, in which case at the DFhack console you type

Code: [Select]
lua dfusion/yourfile.lua

Ok, that explains it better. So I can just put the example on the wiki into a dot lua file and then run the file from dfhack? I know c++, im not a master or very good at it. But why would I need to know c if the scripts are in lua? Just wondering. Thanks for the help though.
Logged

HavingPhun

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #5 on: September 22, 2012, 05:52:38 pm »

Ok so I gave it a try and the lines at the top and bottom that mention tools make dfhack spit out errors and i got the file to not have errors but nothing happens.
This is the code:

Code: [Select]

function morul(unit)

  utils = require 'utils'

  if unit==nil then
    unit=getCreatureAtPointer() 
  end
 
  unit.name.first_name = "Morul"
  unit.name.words[0] = 1416  --[T_WORD:CHANNEL:catten]
  unit.name.words[1] = 1304  --[T_WORD:BEND:mat]


  labor_rating = 15

  military_rating = 70
 

  skill = { 0,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47,48,49,54,55,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,95,96,97,98,99,100,101,102,103,104,105,109,110,111,112,113,114,115 }

  military = { 38,39,41,42,43,44,45,46,54,99,100,101,102,103,104,105 }

 
  for sk,sv in ipairs(skill) do
   
    new_rating = labor_rating
   
    for _,v in ipairs(military) do
     
      if v == sv then
       
        new_rating = military_rating
      end
    end
   
    utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = sv, rating = new_rating, experience = (new_rating * 500) + (new_rating * (new_rating - 1)) * 50}, 'id')
  end
 
 
  for sk,sv in ipairs(unit.status.current_soul.skills) do
   
    printall(sv)
  end
end




If I put the k cursor over the guy and then run that script file how you said to above then nothing happens. The game is paused when i do it but nothing happens. So what did i do wrong?
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: Can someone help me with DFusion
« Reply #6 on: September 22, 2012, 07:13:47 pm »

Well, unfortunately the answer to your question #2 is basically "learn C," which is beyond the scope of what people can probably help you with here on the bayforums.  I don't believe there is currently anything more tutorial than that wiki page and the thread it links too.  Good luck!

The code goes in a lua script file anywhere on your computer, a convenient place being maybe <your Dwarf fortress path>/dfusion.  Then you point to that filepath when you call the script.  Typically you are using DFusion with DFhack, in which case at the DFhack console you type

Code: [Select]
lua dfusion/yourfile.lua

Strictly speaking, the "lua" command is just the Lua interactive interpreter (which will eventually be removed from the DFusion plugin) - the interactive DFusion system is triggered using the "dfusion" command, and that stuff works a bit differently.

Also, if you just have a Lua script you want to run as a command, you don't even need DFusion - jjust place it in the hack/scripts/ folder and run it as an ordinary plugin command (e.g. type "yourfile" just as you'd type "reveal").
« Last Edit: September 22, 2012, 07:45:40 pm by Quietust »
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.

HavingPhun

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #7 on: September 23, 2012, 10:50:26 am »

Well, unfortunately the answer to your question #2 is basically "learn C," which is beyond the scope of what people can probably help you with here on the bayforums.  I don't believe there is currently anything more tutorial than that wiki page and the thread it links too.  Good luck!

The code goes in a lua script file anywhere on your computer, a convenient place being maybe <your Dwarf fortress path>/dfusion.  Then you point to that filepath when you call the script.  Typically you are using DFusion with DFhack, in which case at the DFhack console you type

Code: [Select]
lua dfusion/yourfile.lua


Strictly speaking, the "lua" command is just the Lua interactive interpreter (which will eventually be removed from the DFusion plugin) - the interactive DFusion system is triggered using the "dfusion" command, and that stuff works a bit differently.

Also, if you just have a Lua script you want to run as a command, you don't even need DFusion - jjust place it in the hack/scripts/ folder and run it as an ordinary plugin command (e.g. type "yourfile" just as you'd type "reveal").
Ok, I put the script above in the hack/scripts/ folder and named it lsoldier.lua . But when I put the k cursor over the dwarf i want to affect and then type in lsoldier, nothing happens. Is that script up there wrong. I just want it to make the  soldier a legendary soldier in all the soldier skills, none are changed at all.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Can someone help me with DFusion
« Reply #8 on: September 23, 2012, 02:37:36 pm »

Add a little line
Code: [Select]
morul()
to that code.

HavingPhun

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #9 on: September 23, 2012, 02:44:52 pm »

Add a little line
Code: [Select]
morul()
to that code.
Where? Im sorry, im not good at coding.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Can someone help me with DFusion
« Reply #10 on: September 24, 2012, 02:19:14 am »

Code: [Select]
function morul(unit)

  utils = require 'utils'

  if unit==nil then
    unit=getCreatureAtPointer() 
  end
 
  unit.name.first_name = "Morul"
  unit.name.words[0] = 1416  --[T_WORD:CHANNEL:catten]
  unit.name.words[1] = 1304  --[T_WORD:BEND:mat]


  labor_rating = 15

  military_rating = 70
 

  skill = { 0,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47,48,49,54,55,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,95,96,97,98,99,100,101,102,103,104,105,109,110,111,112,113,114,115 }

  military = { 38,39,41,42,43,44,45,46,54,99,100,101,102,103,104,105 }

 
  for sk,sv in ipairs(skill) do
   
    new_rating = labor_rating
   
    for _,v in ipairs(military) do
     
      if v == sv then
       
        new_rating = military_rating
      end
    end
   
    utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = sv, rating = new_rating, experience = (new_rating * 500) + (new_rating * (new_rating - 1)) * 50}, 'id')
  end
 
 
  for sk,sv in ipairs(unit.status.current_soul.skills) do
   
    printall(sv)
  end
end

morul()
and put it in "hack/scripts/lsoldier.lua"

HavingPhun

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #11 on: September 24, 2012, 04:41:45 pm »

Code: [Select]
function morul(unit)

  utils = require 'utils'

  if unit==nil then
    unit=getCreatureAtPointer() 
  end
 
  unit.name.first_name = "Morul"
  unit.name.words[0] = 1416  --[T_WORD:CHANNEL:catten]
  unit.name.words[1] = 1304  --[T_WORD:BEND:mat]


  labor_rating = 15

  military_rating = 70
 

  skill = { 0,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47,48,49,54,55,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,95,96,97,98,99,100,101,102,103,104,105,109,110,111,112,113,114,115 }

  military = { 38,39,41,42,43,44,45,46,54,99,100,101,102,103,104,105 }

 
  for sk,sv in ipairs(skill) do
   
    new_rating = labor_rating
   
    for _,v in ipairs(military) do
     
      if v == sv then
       
        new_rating = military_rating
      end
    end
   
    utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = sv, rating = new_rating, experience = (new_rating * 500) + (new_rating * (new_rating - 1)) * 50}, 'id')
  end
 
 
  for sk,sv in ipairs(unit.status.current_soul.skills) do
   
    printall(sv)
  end
end

morul()
and put it in "hack/scripts/lsoldier.lua"

I get an error that says that call for the global 'getCreatureAtPointer' (a nil value)
So this code that i posted is wrong does anyone know the code i am looking for off the top of there head?
Logged

Akjosch

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #12 on: September 24, 2012, 04:52:11 pm »

I get an error that says that call for the global 'getCreatureAtPointer' (a nil value)
So this code that i posted is wrong does anyone know the code i am looking for off the top of there head?

Try dfhack.gui.getSelectedUnit()

Logged

HavingPhun

  • Bay Watcher
    • View Profile
Re: Can someone help me with DFusion
« Reply #13 on: September 25, 2012, 03:22:16 pm »

I get an error that says that call for the global 'getCreatureAtPointer' (a nil value)
So this code that i posted is wrong does anyone know the code i am looking for off the top of there head?

Try dfhack.gui.getSelectedUnit()
That worked. Thanks y'all some much for the help.
Logged