Bay 12 Games Forum

Please login or register.

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

Author Topic: gm-editor  (Read 7494 times)

mineforce

  • Bay Watcher
    • View Profile
gm-editor
« on: January 28, 2015, 12:34:40 am »

Hello everyone, I need help with the gm-editor.

I'm trying to lower the age of my adventurer and set a baby that is mounted onto as my child. But when I retire, the changes revert back to before I edited it. How can I keep the changes?
Logged
Who's born in the fortress, die in the fortress

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: gm-editor
« Reply #1 on: January 28, 2015, 12:52:43 am »

You'll need to edit the hist figure as well as the unit. Start gm-editor like so:

gui/gm-editor df.historical_figure.find(dfhack.gui.getSelectedUnit().hist_figure_id)

mineforce

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #2 on: January 28, 2015, 01:44:12 am »

You'll need to edit the hist figure as well as the unit. Start gm-editor like so:

gui/gm-editor df.historical_figure.find(dfhack.gui.getSelectedUnit().hist_figure_id)

One more question, how do I add histfig links? The child is only associated with the mother and the deity and I have no idea how to add fatherst.

EDIT:never mind I figured it out
« Last Edit: January 28, 2015, 02:25:39 am by mineforce »
Logged
Who's born in the fortress, die in the fortress

Nopenope

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #3 on: January 28, 2015, 06:09:59 am »

EDIT:never mind I figured it out
Please do explain how you did so that others who stumble upon the same problem know what to do.
Logged

mineforce

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #4 on: January 28, 2015, 08:37:55 am »

EDIT:never mind I figured it out
Please do explain how you did so that others who stumble upon the same problem know what to do.

Alt+I and then write the class type, such as

Histfig_hf_childst
Logged
Who's born in the fortress, die in the fortress

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: gm-editor
« Reply #5 on: January 28, 2015, 08:53:37 am »

^that also works for adding preferences (alt+i > unit_preference) and whatnot if you convert hostiles in a stupidly convoluted fashion instead of using tweak makeon
Logged

mineforce

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #6 on: February 03, 2015, 02:17:04 am »

How do edit things with nil? I can't do anything to them.
Logged
Who's born in the fortress, die in the fortress

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: gm-editor
« Reply #7 on: February 03, 2015, 02:57:20 am »

It depends entirely on what in particular is nil here.

mineforce

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #8 on: February 03, 2015, 05:53:38 pm »

It depends entirely on what in particular is nil here.

I wanted to edit things like pregnancy_genes on relations.
Logged
Who's born in the fortress, die in the fortress

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: gm-editor
« Reply #9 on: February 03, 2015, 06:42:52 pm »

pregnancy_genes wants df.unit_genes.

If you're trying to make something pregnant, knock yourself out:

Code: [Select]
-- Allows ectobiology.

-- where doing it man

-- where MAKING THIS HAPEN

local function getNumberOfChildren(unit)
    local children=0
    for k,v in ipairs(df.historical_figure.find(unit.hist_figure_id).histfig_links) do
        if df.histfig_hf_link_childst:is_instance(v) then children=children+1 end
    end
    return children
end

local function getSpouseOrLover(unit)
    local lover_unit=df.unit.find(unit.relations.lover_id) or df.unit.find(unit.relations.spouse_id)
    if lover_unit then
        return lover_unit.hist_figure_id
    else
        local hist_fig=df.historical_figure.find(unit.hist_figure_id)
        for k,v in ipairs(hist_fig.histfig_links) do
            if df.histfig_hf_link_spousest:is_instance(v) or df.histfig_hf_link_loverst:is_instance(v) then
                return v.target_hf
            end
        end
    end
end

local function getCitizenList(lovers_only)
    local citizenTable={}
    if lovers_only then
        for k,u in ipairs(df.global.world.units.active) do
            if dfhack.units.isCitizen(u) and (u.relations.spouse_id~=-1 or u.relations.lover_id~=-1) and u.military.squad_id==-1 then
                table.insert(citizenTable,{dfhack.TranslateName(dfhack.units.getVisibleName(u))..(getSpouseOrLover(u) and (df.historical_figure.find(getSpouseOrLover(u)).sex==u.sex and ' (gay)' or (' (straight)')) or (' (unknown)'))..' ('..getNumberOfChildren(u)..' children)',nil,u})
            end
        end
    else
        for k,u in ipairs(df.global.world.units.active) do
            if dfhack.units.isCitizen(u) then
                table.insert(citizenTable,{dfhack.TranslateName(dfhack.units.getVisibleName(u)),nil,u})
            end
        end
    end
    return citizenTable
end

local function getFemaleCasteWithSameMaxAge(unit)
    local curCaste=df.creature_raw.find(unit.race).caste[unit.caste]
    for k,caste in ipairs(df.creature_raw.find(unit.race).caste) do
        if caste.gender==0 and caste.misc.maxage_min==curCaste.misc.maxage_min and caste.misc.maxage_max==curCaste.misc.maxage_max then return k end
    end
end

local function ectobiologize(freeform)
    local script=require('gui.script')
    script.start(function()
    local citizens=getCitizenList(not freeform)
    if #citizens==0 then script.showMessage('Ectobiology',"Nobody is in a relationship! Best use freeform ectobiology.",COLOR_WHITE) return end
    if freeform then
        local ok1,name1,unit1_t=script.showListPrompt("Ectobiology","Choose first paradox ghost slime target.",COLOR_WHITE,citizens)
        local ok2,name2,unit2_t=script.showListPrompt("Ectobiology","Choose second paradox ghost slime target.",COLOR_WHITE,citizens)
        local unit1=unit1_t[3]
        local unit2=unit2_t[3]
        unit1.relations.pregnancy_timer=1
        unit1.relations.pregnancy_genes=unit1.appearance.genes:new()
        unit1.relations.pregnancy_spouse=unit2.hist_figure_id
        unit1.relations.pregnancy_caste=unit2.caste
        if unit1.sex==1 then
            local normal_caste=unit1.enemy.normal_caste
            unit1.enemy.normal_caste=getFemaleCasteWithSameMaxAge(unit1)
            script.sleep(1,'ticks')
            unit1.enemy.normal_caste=normal_caste
        end
    else
        local ok,name,unit_t=script.showListPrompt("Ectobiology","Choose first genetic material giver.",COLOR_WHITE,citizens)
        if not ok then return false end
        local unit=unit_t[3]
        local lover=getSpouseOrLover(unit)
        unit.relations.pregnancy_timer=1
        unit.relations.pregnancy_genes=unit.appearance.genes:new()
        unit.relations.pregnancy_spouse=lover
        unit.relations.pregnancy_caste=df.historical_figure.find(lover).caste
        dfhack.run_script('modtools/add-syndrome','-syndrome','temp desterilize','-target',unit.id)
        if unit.sex==1 then
            local normal_caste=unit.enemy.normal_caste
            unit.enemy.normal_caste=getFemaleCasteWithSameMaxAge(unit)
            script.sleep(1,'ticks')
            unit.enemy.normal_caste=normal_caste
        end
    end
    end)
end
local utils=require('utils')

validArgs = validArgs or utils.invert({
 'freeform'
})

local args = utils.processArgs({...}, validArgs)

ectobiologize(args.freeform)

I should probably post that somewhere more visible than just Fortbent.

mineforce

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #10 on: February 03, 2015, 09:15:31 pm »

pregnancy_genes wants df.unit_genes.

If you're trying to make something pregnant, knock yourself out:

Code: [Select]
-- Allows ectobiology.

-- where doing it man

-- where MAKING THIS HAPEN

local function getNumberOfChildren(unit)
    local children=0
    for k,v in ipairs(df.historical_figure.find(unit.hist_figure_id).histfig_links) do
        if df.histfig_hf_link_childst:is_instance(v) then children=children+1 end
    end
    return children
end

local function getSpouseOrLover(unit)
    local lover_unit=df.unit.find(unit.relations.lover_id) or df.unit.find(unit.relations.spouse_id)
    if lover_unit then
        return lover_unit.hist_figure_id
    else
        local hist_fig=df.historical_figure.find(unit.hist_figure_id)
        for k,v in ipairs(hist_fig.histfig_links) do
            if df.histfig_hf_link_spousest:is_instance(v) or df.histfig_hf_link_loverst:is_instance(v) then
                return v.target_hf
            end
        end
    end
end

local function getCitizenList(lovers_only)
    local citizenTable={}
    if lovers_only then
        for k,u in ipairs(df.global.world.units.active) do
            if dfhack.units.isCitizen(u) and (u.relations.spouse_id~=-1 or u.relations.lover_id~=-1) and u.military.squad_id==-1 then
                table.insert(citizenTable,{dfhack.TranslateName(dfhack.units.getVisibleName(u))..(getSpouseOrLover(u) and (df.historical_figure.find(getSpouseOrLover(u)).sex==u.sex and ' (gay)' or (' (straight)')) or (' (unknown)'))..' ('..getNumberOfChildren(u)..' children)',nil,u})
            end
        end
    else
        for k,u in ipairs(df.global.world.units.active) do
            if dfhack.units.isCitizen(u) then
                table.insert(citizenTable,{dfhack.TranslateName(dfhack.units.getVisibleName(u)),nil,u})
            end
        end
    end
    return citizenTable
end

local function getFemaleCasteWithSameMaxAge(unit)
    local curCaste=df.creature_raw.find(unit.race).caste[unit.caste]
    for k,caste in ipairs(df.creature_raw.find(unit.race).caste) do
        if caste.gender==0 and caste.misc.maxage_min==curCaste.misc.maxage_min and caste.misc.maxage_max==curCaste.misc.maxage_max then return k end
    end
end

local function ectobiologize(freeform)
    local script=require('gui.script')
    script.start(function()
    local citizens=getCitizenList(not freeform)
    if #citizens==0 then script.showMessage('Ectobiology',"Nobody is in a relationship! Best use freeform ectobiology.",COLOR_WHITE) return end
    if freeform then
        local ok1,name1,unit1_t=script.showListPrompt("Ectobiology","Choose first paradox ghost slime target.",COLOR_WHITE,citizens)
        local ok2,name2,unit2_t=script.showListPrompt("Ectobiology","Choose second paradox ghost slime target.",COLOR_WHITE,citizens)
        local unit1=unit1_t[3]
        local unit2=unit2_t[3]
        unit1.relations.pregnancy_timer=1
        unit1.relations.pregnancy_genes=unit1.appearance.genes:new()
        unit1.relations.pregnancy_spouse=unit2.hist_figure_id
        unit1.relations.pregnancy_caste=unit2.caste
        if unit1.sex==1 then
            local normal_caste=unit1.enemy.normal_caste
            unit1.enemy.normal_caste=getFemaleCasteWithSameMaxAge(unit1)
            script.sleep(1,'ticks')
            unit1.enemy.normal_caste=normal_caste
        end
    else
        local ok,name,unit_t=script.showListPrompt("Ectobiology","Choose first genetic material giver.",COLOR_WHITE,citizens)
        if not ok then return false end
        local unit=unit_t[3]
        local lover=getSpouseOrLover(unit)
        unit.relations.pregnancy_timer=1
        unit.relations.pregnancy_genes=unit.appearance.genes:new()
        unit.relations.pregnancy_spouse=lover
        unit.relations.pregnancy_caste=df.historical_figure.find(lover).caste
        dfhack.run_script('modtools/add-syndrome','-syndrome','temp desterilize','-target',unit.id)
        if unit.sex==1 then
            local normal_caste=unit.enemy.normal_caste
            unit.enemy.normal_caste=getFemaleCasteWithSameMaxAge(unit)
            script.sleep(1,'ticks')
            unit.enemy.normal_caste=normal_caste
        end
    end
    end)
end
local utils=require('utils')

validArgs = validArgs or utils.invert({
 'freeform'
})

local args = utils.processArgs({...}, validArgs)

ectobiologize(args.freeform)

I should probably post that somewhere more visible than just Fortbent.

So I just need to copy this to a txt and put .lua at the end?
Logged
Who's born in the fortress, die in the fortress

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: gm-editor
« Reply #11 on: February 03, 2015, 09:26:44 pm »

Well, replace .txt with .lua, but yeah, and it'll be named whatever the file is.

mineforce

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #12 on: February 03, 2015, 09:54:08 pm »

Well, replace .txt with .lua, but yeah, and it'll be named whatever the file is.

Unexpected symbol near char(194)

Stack trackback:
                      [C]: in function  "error" l


It's not working, but thanks for helping me though.
Logged
Who's born in the fortress, die in the fortress

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: gm-editor
« Reply #13 on: February 03, 2015, 10:10:25 pm »

um

can you give me more traceback there

mineforce

  • Bay Watcher
    • View Profile
Re: gm-editor
« Reply #14 on: February 03, 2015, 11:01:04 pm »

um

can you give me more traceback there


 there
[/quote]
Stack trackback:
                  [C]: in function "error"
                  ...ts and Settings\Sylix\Desktop\df\hack\lua\dfhack.lua:422: in function <...ts and settings\Sylix\Desktop\df\hack\lua\dfhack.lua:407>
Logged
Who's born in the fortress, die in the fortress
Pages: [1] 2 3