Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 102 103 [104] 105 106 ... 243

Author Topic: DFHack 50.13-r1  (Read 809550 times)

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1545 on: November 23, 2018, 04:20:57 am »

Hello,
I'm having a bit of trouble with keybindings. I want to switch the mousewheel to execute
twbt tilesize 16 16
and
twbt tilesize 32 32
Within dfhack, one option I can think of is to have invisible lua screen overlaying game screen, set zoom speed to 0 in init, and then have the lua screen catch mousewheels and pass these commands to dfhack.

The reasons why this is not optimal was most recently discussed here.

I think for your idea a much better option might be utilizing things other than plain dfhack; dfhack-run allows execution of command in currently running df(hack) instance, so you could use, say, your OS' mouse gestures binding to call them when mouse is over df (may not be available in all OSes).

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1546 on: November 27, 2018, 10:31:45 am »

I'm having some trouble with the custom screen gui stuff. I can't seem to get the correct widget as the "active" one. I set active to true, and set the other parts widgets on the viewscreen to false, but I'm still not able to scroll through the list. I can hit enter and go deeper in the tree, but I can only ever do it for the first item since I can't change what was selected. I had this working before, but I must have broken something. I do have several viewscreens open/created (but only one visible at a time), do I need to set all of their actives to false? Is there an easier way to change the focus that I don't know about?
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1547 on: November 27, 2018, 10:40:24 am »

Are you sure you're using the correct scrolling keys? The list widgets support either the primary or secondary scroll keys, depending on how they're configured. Otherwise, there's not a lot I can do without code.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1548 on: November 27, 2018, 11:03:43 am »

Are you sure you're using the correct scrolling keys? The list widgets support either the primary or secondary scroll keys, depending on how they're configured. Otherwise, there's not a lot I can do without code.

I thought I tried both. Here is the code, the relevant parts are probably the viewing functions and the screen functions. Sorry for the formatting, it looks a lot better in my text editor with custom colors/indents/etc... I can switch views easy enough, and all the information is displayed correctly it's just the lists are always colored with the inactive_pen color

Code: [Select]
local gui = require 'gui'
local dialog = require 'gui.dialogs'
local widgets =require 'gui.widgets'
local guiScript = require 'gui.script'
local utils = require 'utils'
local split = utils.split_string
local persistTable = require 'persist-table'
local textC     = COLOR_DARYGRAY
local cursorC   = COLOR_LIGHTRED
local inactiveC = COLOR_CYAN
local views = {'main','detailedView','healthView','thoughtView','classView','featView','spellView'}

classSystem     = false
featSystem      = false
spellSystem     = false
civSystem       = false
ECreatureSystem = false

function center(str, length)
 local string1 = str
 local string2 = string.format("%"..tostring(math.floor((length-#string1)/2)).."s"..string1,"")
 local string3 = string.format(string2.."%"..tostring(math.ceil((length-#string1)/2)).."s","")
 return string3
end

function tchelper(first, rest)
  return first:upper()..rest:lower()
end

function Set (list)
  local set = {}
  for _, l in ipairs(list) do set[l] = true end
  return set
end

function getTargetFromScreens()
 local my_trg
 if dfhack.gui.getSelectedUnit(true) then
  my_trg=dfhack.gui.getSelectedUnit(true)
 else
  qerror("No valid target found")
 end
 return my_trg
end

local guiFunctions = dfhack.script_environment('functions/gui')
 
DetailedUnitView = defclass(DetailedUnitView, gui.FramedScreen)
DetailedUnitView.ATTRS={
                        frame_style = gui.BOUNDARY_FRAME,
                        frame_title = "Detailed Unit Viewer",
               }

function DetailedUnitView:init(args)
 self.target = args.target
 if persistTable.GlobalTable.roses then
  systems = persistTable.GlobalTable.roses.Systems
  if systems.Class            == 'true' then classSystem     = true end
  if systems.Feat             == 'true' then featSystem      = true end
  if systems.Spell            == 'true' then spellSystem     = true end
  if systems.Civilization     == 'true' then civSystem       = true end
  if systems.EnhancedCreature == 'true' then ECreatureSystem = true end
 end
 self.ClassSystem    = classSystem
 self.SpellSystem    = spellSystem
 self.FeatSystem     = featSystem
 self.CivSystem      = civSystem
 self.EnhancedSystem = ECreatureSystem

 -- Bottom UI
 self:addviews{
   widgets.Panel{
     view_id  = 'bottomView',
     frame    = { b = 0, h = 1},
     subviews = {
       widgets.Label{
         view_id = 'bottom_ui',
         frame   = { l = 0, t = 0},
         text    = 'filled by updateBottom()'
       }
     }
   }
 }
 self.subviews.bottomView.visible = true -- Alwayes true

 -- Create Frames
 ---- Main
 self:addMainScreen()     -- 3x3 - AX, AY, AZ, BX, BY, BZ, CX, CY, CZ

 ---- Sub Views
 self:addDetailsScreen()  -- 3x2 - D_ABX, D_ABY, D_AZ, D_BZ
 self:addHealthScreen()   -- 2x1 - H_AX, H_AY
 self:addThoughtsScreen() -- 3x1 - T_AX, T_AY, T_AZ
 self:addClassScreen()    -- 2x2 - C_AX, C_BX, C_ABY
 self:addFeatScreen()     -- 2x2 - F_AX, F_BX, F_ABY
 self:addSpellScreen()    -- 2x2 - S_AX, S_BX, S_ABY

 -- Fill Frames
 self:fillMain()
 self:fillDetails()
 self:fillHealth()
 self:fillThoughts()
 if self.ClassSystem then self:fillClasses('All','List') end
 if self.FeatSystem  then self:fillFeats('All','List')   end
 if self.SpellSystem then self:fillSpells('All','List')  end

 -- Set Starting View
 for _,view in pairs(self.subviews) do
  view.visible = true
 end
 self:viewMain()
end

--= Screen Functions (create the screens)
function DetailedUnitView:addMainScreen()
---- Main
 --[[ Positioning
 Main:
   |       X            |      Y         |       Z           |
 --|--------------------|----------------|-------------------|
 A | Base Information   | Description    | Attributes        |
 --|--------------------|----------------|-------------------|
 B | Membership/Worship | Appearance     | Skills            |
 --|--------------------|----------------|-------------------|
 C | Class Information  | Health         | Stats/Resistances |
 -------------------------------------------------------------
 Bottom UI:
  Details
 ]]
 self:getPositioningMain()
 self:addviews{
   widgets.Panel{
     view_id     = 'main',
     frame       = { l = 0, r = 0 },
     frame_inset = 1,
     subviews    = {
       widgets.List{
         view_id = 'AX',
         frame   = {l = self.AX.anchor.left, t = self.AX.anchor.top, w = self.X_width, h = self.AX.height},
       },
       widgets.List{
         view_id = 'AY',
         frame   = {l = self.AY.anchor.left, t = self.AY.anchor.top, w = self.Y_width, h = self.AY.height},
       },
       widgets.List{
         view_id = 'AZ',
         frame   = {l = self.AZ.anchor.left, t = self.AZ.anchor.top, w = self.Z_width, h = self.AZ.height},
       },
       widgets.List{
         view_id = 'BX',
         frame   = {l = self.BX.anchor.left, t = self.BX.anchor.top, w = self.X_width, h = self.BX.height},
       },
       widgets.List{
         view_id = 'BY',
         frame   = {l = self.BY.anchor.left, t = self.BY.anchor.top, w = self.Y_width, h = self.BY.height},
       },
       widgets.List{
         view_id = 'BZ',
         frame   = {l = self.BZ.anchor.left, t = self.BZ.anchor.top, w = self.Z_width, h = self.BZ.height},
       },
       widgets.List{
         view_id = 'CX',
         frame   = {l = self.CX.anchor.left, t = self.CX.anchor.top, w = self.X_width, h = self.CX.height},
       },
       widgets.List{
         view_id = 'CY',
         frame   = {l = self.CY.anchor.left, t = self.CY.anchor.top, w = self.Y_width, h = self.CY.height},
       },
       widgets.List{
         view_id = 'CZ',
         frame   = {l = self.CZ.anchor.left, t = self.CZ.anchor.top, w = self.Z_width, h = self.CZ.height},
       },
     }
   }
 }
end
function DetailedUnitView:addDetailsScreen()
------ Detailed Information
 --[[
 Detailed Information:
   |      X       |      Y      |      Z      |
 --|--------------|-------------|-------------|
 A |              |             | Resistances |
 --| Attributes   | Skills      |-------------|
 B |              |             | Stats       |
 ----------------------------------------------
 Bottom UI:
  Back
 ]]
 self:getPositioningDetails()
 self:addviews{
   widgets.Panel{
     view_id     = 'detailedView',
     frame       = { l = 0, r = 0 },
     frame_inset = 1,
     subviews    = {
       widgets.List{
         view_id = 'D_ABX',
         frame   = {l = self.D_ABX.anchor.left, t = self.D_ABX.anchor.top, w = self.D_X_width, h = self.D_ABX.height},
       },
       widgets.List{
         view_id = 'D_ABY',
         frame   = {l = self.D_ABY.anchor.left, t = self.D_ABY.anchor.top, w = self.D_Y_width, h = self.D_ABY.height},
       },
       widgets.List{
         view_id = 'D_AZ',
         frame   = {l = self.D_AZ.anchor.left, t = self.D_AZ.anchor.top, w = self.D_Z_width, h = self.D_AZ.height},
       },
       widgets.List{
         view_id = 'D_BZ',
         frame   = {l = self.D_BZ.anchor.left, t = self.D_BZ.anchor.top, w = self.D_Z_width, h = self.D_BZ.height},
       },
     }
   }
 }
end
function DetailedUnitView:addHealthScreen()
------ Health
 --[[
 Health Information:
   |      X       |      Y      |
 --|--------------|-------------|
 A | Health Stats | Syndromes   |
 --------------------------------
 Bottom UI:
  Back
 ]]
 self:getPositioningHealth()
 self:addviews{
   widgets.Panel{
     view_id     = 'healthView',
     frame       = { l = 0, r = 0 },
     frame_inset = 1,
     subviews    = {
       widgets.List{
         view_id = 'H_AX',
         frame   = {l = self.H_AX.anchor.left, t = self.H_AX.anchor.top, w = self.H_X_width, h = self.H_AX.height},
       },
       widgets.List{
         view_id = 'H_AY',
         frame   = {l = self.H_AY.anchor.left, t = self.H_AY.anchor.top, w = self.H_Y_width, h = self.H_AY.height},
       },
     }
   }
 }
end
function DetailedUnitView:addThoughtsScreen()
------ Thoughts
 --[[
 Thoughts and Preferences:
   |    X     |      Y      |   Z    |
 --|----------|-------------|--------|
 A | Thoughts | Preferences | Traits |
 -------------------------------------
 Bottom UI:
  Back
 ]]
 self:getPositioningThoughts()
 self:addviews{
   widgets.Panel{
     view_id     = 'thoughtView',
     frame       = { l = 0, r = 0 },
     frame_inset = 1,
     subviews    = {
       widgets.List{
         view_id = 'T_AX',
         frame   = {l = self.T_AX.anchor.left, t = self.T_AX.anchor.top, w = self.T_X_width, h = self.T_AX.height},
       },
       widgets.List{
         view_id = 'T_AY',
         frame   = {l = self.T_AY.anchor.left, t = self.T_AY.anchor.top, w = self.T_Y_width, h = self.T_AY.height},
       },
       widgets.List{
         view_id = 'T_AZ',
         frame   = {l = self.T_AZ.anchor.left, t = self.T_AZ.anchor.top, w = self.T_Z_width, h = self.T_AZ.height},
       },
     }
   }
 }
end
function DetailedUnitView:addClassScreen()
------ Class Information
 --[[
 Classes:
   |      X       |      Y      |
 --|--------------|-------------|
 A | Header       |             |
 --|--------------| Details     |
 B | Class List   |             |
 --------------------------------
 Bottom UI:
  Back
 ]]
 self:getPositioningClasses()
 self:addviews{
   widgets.Panel{
     view_id     = 'classView',
     frame       = { l = 0, r = 0 },
     frame_inset = 1,
     subviews    = {
       widgets.List{
         view_id = 'C_AX',
         frame   = {l = self.C_AX.anchor.left, t = self.C_AX.anchor.top, w = self.C_X_width, h = self.C_AX.height},
       },
       widgets.List{
         view_id    = 'C_BX',
         frame      = {l = self.C_BX.anchor.left, t = self.C_BX.anchor.top, w = self.C_X_width, h = self.C_BX.height},
         on_select  = self:callback('fillClasses'),
         text_pen   = textC,
         cursor_pen = cursorC,
inactive_pen = inactiveC
       },
       widgets.List{
         view_id = 'C_ABY',
         frame   = {l = self.C_ABY.anchor.left, t = self.C_ABY.anchor.top, w = self.C_Y_width, h = self.C_ABY.height},
       },
     }
   }
 }
end
function DetailedUnitView:addFeatScreen()
------ Feat Information
 --[[
 Feats:
   |      X       |      Y      |
 --|--------------|-------------|
 A | Header       |             |
 --|--------------| Details     |
 B | Feat List    |             |
 --------------------------------
 Bottom UI:
  Back
 ]]
 self:getPositioningFeats()
 self:addviews{
   widgets.Panel{
     view_id     = 'featView',
     frame       = { l = 0, r = 0 },
     frame_inset = 1,
     subviews    = {
       widgets.List{
         view_id = 'F_AX',
         frame   = {l = self.F_AX.anchor.left, t = self.F_AX.anchor.top, w = self.F_X_width, h = self.F_AX.height},
       },
       widgets.List{
         view_id    = 'F_BX',
         frame      = {l = self.F_BX.anchor.left, t = self.F_BX.anchor.top, w = self.F_X_width, h = self.F_BX.height},
         on_select  = self:callback('fillFeats'),
         text_pen   = textC,
         cursor_pen = cursorC,
       },
       widgets.List{
         view_id = 'F_ABY',
         frame   = {l = self.F_ABY.anchor.left, t = self.F_ABY.anchor.top, w = self.F_Y_width, h = self.F_ABY.height},
       },
     }   
   }
 }
end
function DetailedUnitView:addSpellScreen()
------ Spell Information
 --[[
 Spells:
   |      X       |      Y      |
 --|--------------|-------------|
 A | Header       |             |
 --|--------------| Details     |
 B | Spell List   |             |
 --------------------------------
 Bottom UI:
  Back
 ]]
 self:getPositioningSpells()
 self:addviews{
   widgets.Panel{
     view_id     = 'spellView',
     frame       = { l = 0, r = 0 },
     frame_inset = 1,
     subviews    = {
       widgets.List{
         view_id = 'S_AX',
         frame   = {l = self.S_AX.anchor.left, t = self.S_AX.anchor.top, w = self.S_X_width, h = self.S_AX.height},
       },
       widgets.List{
         view_id    = 'S_BX',
         frame      = {l = self.S_BX.anchor.left, t = self.S_BX.anchor.top, w = self.S_X_width, h = self.S_BX.height},
         on_select  = self:callback('fillSpells'),
         text_pen   = textC,
         cursor_pen = cursorC,
       },
       widgets.List{
         view_id = 'S_ABY',
         frame   = {l = self.S_ABY.anchor.left, t = self.S_ABY.anchor.top, w = self.S_Y_width, h = self.S_ABY.height},
       },
     }   
   }
 }
end

--= Positioning Functions (get the width, height, and anchor points for each screen)
function DetailedUnitView:getPositioningMain()
 local AX = {anchor = {}, width = 40, height = 10}
 local AY = {anchor = {}, width = 40, height = 10}
 local AZ = {anchor = {}, width = 40, height = 10}
 local BX = {anchor = {}, width = 40, height = 10}
 local BY = {anchor = {}, width = 40, height = 10}
 local BZ = {anchor = {}, width = 40, height = 10}
 local CX = {anchor = {}, width = 40, height = 10}
 local CY = {anchor = {}, width = 40, height = 10}
 local CZ = {anchor = {}, width = 40, height = 10}
 local X_width = math.max(AX.width,BX.width,CX.width)
 local Y_width = math.max(AY.width,BY.width,CY.width)
 local Z_width = math.max(AZ.width,BZ.width,CZ.width)
----
 AX.anchor.top  = 0
 AY.anchor.top  = 0
 AZ.anchor.top  = 0
 AX.anchor.left = 0
 AY.anchor.left = X_width + 4
 AZ.anchor.left = X_width + Y_width + 8
 BX.anchor.top  = AX.height + 1
 BY.anchor.top  = AY.height + 1
 BZ.anchor.top  = AZ.height + 1
 BX.anchor.left = 0
 BY.anchor.left = X_width + 4
 BZ.anchor.left = X_width + Y_width + 8
 CX.anchor.top  = AX.height + BX.height + 2
 CY.anchor.top  = AY.height + BY.height + 2
 CZ.anchor.top  = AZ.height + BZ.height + 2
 CX.anchor.left = 0
 CY.anchor.left = X_width + 4
 CZ.anchor.left = X_width + Y_width + 8
----
 self.AX = AX
 self.AY = AY
 self.AZ = AZ
 self.BX = BX
 self.BY = BY
 self.BZ = BZ
 self.CX = CX
 self.CY = CY
 self.CZ = CZ
 self.X_width = X_width
 self.Y_width = Y_width
 self.Z_width = Z_width
end
function DetailedUnitView:getPositioningDetails()
 local ABX = {anchor = {}, width = 40, height = 40}
 local ABY = {anchor = {}, width = 40, height = 40}
 local AZ  = {anchor = {}, width = 40, height = 20}
 local BZ  = {anchor = {}, width = 40, height = 20}
 local X_width = ABX.width
 local Y_width = ABY.width
 local Z_width = math.max(AZ.width,BZ.width)
----
 ABX.anchor.top  = 0
 ABY.anchor.top  = 0
 ABX.anchor.left = 0
 ABY.anchor.left = X_width + 4
 AZ.anchor.top  = 0
 AZ.anchor.left = X_width + Y_width + 8
 BZ.anchor.top  = AZ.height + 1
 BZ.anchor.left = X_width + Y_width + 8
----
 self.D_ABX = ABX
 self.D_ABY = ABY
 self.D_AZ  = AZ
 self.D_BZ  = BZ
 self.D_X_width = X_width
 self.D_Y_width = Y_width
 self.D_Z_width = Z_width
end
function DetailedUnitView:getPositioningHealth()
 local AX = {anchor = {}, width = 60, height = 40}
 local AY = {anchor = {}, width = 60, height = 40}
 local X_width = AX.width
 local Y_width = AY.width
----
 AX.anchor.top  = 0
 AY.anchor.top  = 0
 AX.anchor.left = 0
 AY.anchor.left = X_width + 4
----
 self.H_AX = AX
 self.H_AY = AY
 self.H_X_width = X_width
 self.H_Y_width = Y_width
end
function DetailedUnitView:getPositioningThoughts()
 local AX = {anchor = {}, width = 40, height = 40}
 local AY = {anchor = {}, width = 40, height = 40}
 local AZ = {anchor = {}, width = 40, height = 40}
 local X_width = AX.width
 local Y_width = AY.width
 local Z_width = AZ.width
----
 AX.anchor.top = 0
 AY.anchor.top = 0
 AZ.anchor.top = 0
 AX.anchor.left = 0
 AY.anchor.left = X_width + 4
 AZ.anchor.left = X_width + Y_width + 8
----
 self.T_AX = AX
 self.T_AY = AY
 self.T_AZ = AZ
 self.T_X_width = X_width
 self.T_Y_width = Y_width
 self.T_Z_width = Z_width
end
function DetailedUnitView:getPositioningClasses()
 local AX  = {anchor = {}, width = 40, height = 3}
 local BX  = {anchor = {}, width = 40, height = 37}
 local ABY = {anchor = {}, width = 80, height = 40}
 local X_width = math.max(AX.width,BX.width)
 local Y_width = ABY.width
----
 AX.anchor.top  = 0
 AX.anchor.left = 0
 BX.anchor.top  = AX.height + 1
 BX.anchor.left = 0
 ABY.anchor.top  = 0
 ABY.anchor.left = X_width + 4
----
 self.C_AX  = AX
 self.C_BX  = BX
 self.C_ABY = ABY
 self.C_X_width = X_width
 self.C_Y_width = Y_width
end
function DetailedUnitView:getPositioningFeats()
 local AX  = {anchor = {}, width = 40, height = 3}
 local BX  = {anchor = {}, width = 40, height = 37}
 local ABY = {anchor = {}, width = 80, height = 40}
 local X_width = math.max(AX.width,BX.width)
 local Y_width = ABY.width
----
 AX.anchor.top  = 0
 AX.anchor.left = 0
 BX.anchor.top  = AX.height + 1
 BX.anchor.left = 0
 ABY.anchor.top  = 0
 ABY.anchor.left = X_width + 4
----
 self.F_AX  = AX
 self.F_BX  = BX
 self.F_ABY = ABY
 self.F_X_width = X_width
 self.F_Y_width = Y_width
end
function DetailedUnitView:getPositioningSpells()
 local AX  = {anchor = {}, width = 40, height = 3}
 local BX  = {anchor = {}, width = 40, height = 37}
 local ABY = {anchor = {}, width = 80, height = 40}
 local X_width = math.max(AX.width,BX.width)
 local Y_width = ABY.width
----
 AX.anchor.top  = 0
 AX.anchor.left = 0
 BX.anchor.top  = AX.height + 1
 BX.anchor.left = 0
 ABY.anchor.top  = 0
 ABY.anchor.left = X_width + 4
----
 self.S_AX  = AX
 self.S_BX  = BX
 self.S_ABY = ABY
 self.S_X_width = X_width
 self.S_Y_width = Y_width
end

--= Filling Functions (call functions/gui to get the information to put on the screen)
function DetailedUnitView:fillMain()
 local unit = self.target
 local grid = {'AX', 'AY', 'AZ', 'BX', 'BY', 'BZ', 'CX', 'CY', 'CZ'}
 local output = {}
 for i,g in pairs(grid) do
  output[g] = guiFunctions.getMainOutput(g, unit, self[g].width, self.ClassSystem)
  self.subviews[g]:setChoices(output[g])
 end
end
function DetailedUnitView:fillDetails()
 local unit = self.target
 local grid = {'D_ABX', 'D_ABY', 'D_AZ', 'D_BZ'}
 local output = {}
 for i,g in pairs(grid) do
  output[g] = guiFunctions.getDetailsOutput(g, unit, self[g].width)
  self.subviews[g]:setChoices(output[g])
 end
end
function DetailedUnitView:fillHealth()
 local unit = self.target
 local grid = {'H_AX', 'H_AY'}
 local output = {}
 for i,g in pairs(grid) do
  output[g] = guiFunctions.getHealthOutput(g, unit, self[g].width)
  self.subviews[g]:setChoices(output[g])
 end
end
function DetailedUnitView:fillThoughts()
 local unit = self.target
 local grid = {'T_AX', 'T_AY', 'T_AZ'}
 local output = {}
 for i,g in pairs(grid) do
  output[g] = guiFunctions.getThoughtsOutput(g, unit, self[g].width)
  self.subviews[g]:setChoices(output[g])
 end
end
function DetailedUnitView:fillClasses(filter,details)
 local unit = self.target
 local output = {}
 if details == nil then return end
 
 if details and details ~= 'List' then
  output = guiFunctions.getClassesOutput('C_ABY', unit, self.C_ABY.width, details)
  self.subviews.C_ABY:setChoices(output)
 else
  local grid = {'C_AX','C_BX'}
  local output = {}
  for i,g in pairs(grid) do
   output[g] = guiFunctions.getClassesOutput(g, unit, self[g].width, filter)
   self.subviews[g]:setChoices(output[g])
  end
 end
end
function DetailedUnitView:fillFeats(filter,details)
 local unit = self.target
 local output = {}
 if details == nil then return end
 
 if details and details ~= 'List' then
  output = guiFunctions.getFeatsOutput('F_ABY', unit, self.F_ABY.width, details)
  self.subviews.F_ABY:setChoices(output)
 else
  local grid = {'F_AX','F_BX'}
  for i,g in pairs(grid) do
   output[g] = guiFunctions.getFeatsOutput(g, unit, self[g].width, filter)
   self.subviews[g]:setChoices(output[g])
  end
 end
end
function DetailedUnitView:fillSpells(filter,details)
 local unit = self.target
 local output = {}
 if details == nil then return end
 
 if details and details ~= 'List' then
  output = guiFunctions.getSpellsOutput('S_ABY', unit, self.S_ABY.width, details)
  self.subviews.S_ABY:setChoices(output)
 else
  local grid = {'S_AX','S_BX'}
  local output = {}
  for i,g in pairs(grid) do
   output[g] = guiFunctions.getSpellsOutput(g, unit, self[g].width, filter)
   self.subviews[g]:setChoices(output[g])
  end
 end
end

--= Viewing Functions (change which screen is active and visible)
function DetailedUnitView:updateBottom(screen)
 if      screen == 'Main' then
   text = {
           { key = 'CUSTOM_SHIFT_A', text = ': Details   ', on_activate = self:callback('viewDetails')  },
           { key = 'CUSTOM_SHIFT_H', text = ': Health    ', on_activate = self:callback('viewHealth')   },
           { key = 'CUSTOM_SHIFT_T', text = ': Thoughts  ', on_activate = self:callback('viewThoughts') },
          }
   if self.ClassSystem then table.insert(text, {key = 'CUSTOM_SHIFT_C', text = ': Classes  ', on_activate = self:callback('viewClasses')}) end
   if self.ClassSystem then table.insert(text, {key = 'CUSTOM_SHIFT_F', text = ': Feats    ', on_activate = self:callback('viewFeats')  }) end
   if self.ClassSystem then table.insert(text, {key = 'CUSTOM_SHIFT_S', text = ': Spells   ', on_activate = self:callback('viewSpells') }) end
  elseif screen == 'Details' then
   text = {
           { text = 'ESC: Back  '},
          }
  elseif screen == 'Health' then
   text = {
           { text = 'ESC: Back  '},
          }
  elseif screen == 'Thoughts' then
   text = {
           { text = 'ESC: Back  '},
          }
  elseif screen == 'Classes' then
   text = {
           { key = 'CUSTOM_SHIFT_A', text = ': Show All Classes          ', on_activate = function () self:fillClasses('All','List')       end },
           { key = 'CUSTOM_SHIFT_C', text = ': Show Civilization Classes ', on_activate = function () self:fillClasses('Civ','List')       end },
           { key = 'CUSTOM_SHIFT_K', text = ': Show Known Classes        ', on_activate = function () self:fillClasses('Learned','List')   end },
           { key = 'CUSTOM_SHIFT_V', text = ': Show Available Classes    ', on_activate = function () self:fillClasses('Available','List') end },
           { text = 'ESC: Back'}
          }
  elseif screen == 'Feats' then
   text = {
           { key = 'CUSTOM_SHIFT_A', text = ': Show All Feats   ', on_activate = function () self:fillFeats('All','List')     end },
           { key = 'CUSTOM_SHIFT_C', text = ': Show Class Feats ', on_activate = function () self:fillFeats('Class','List')   end },
           { key = 'CUSTOM_SHIFT_K', text = ': Show Known Feats ', on_activate = function () self:fillFeats('Learned','List') end },
           { text = 'ESC: Back'}
          }
  elseif screen == 'Spells' then
   text = {
           { key = 'CUSTOM_SHIFT_A', text = ': Show All Spells          ', on_activate = function () self:fillSpells('All','List')     end },
           { key = 'CUSTOM_SHIFT_C', text = ': Show Civilization Spells ', on_activate = function () self:fillSpells('Civ','List')     end },
           { key = 'CUSTOM_SHIFT_K', text = ': Show Known Spells        ', on_activate = function () self:fillSpells('Learned','List') end },
           { key = 'CUSTOM_SHIFT_L', text = ': Show Classes Spells      ', on_activate = function () self:fillSpells('Class','List')   end },
           { text = 'ESC: Back'}
          }
  end
  self.subviews.bottom_ui:setText(text)
end
function DetailedUnitView:resetView()
 for _,view in pairs(views) do
  self.subviews[view].visible = false
  self.subviews[view].active  = false
 end
 --self.subviews.bottom_ui.visible = true
end
function DetailedUnitView:viewMain()
 self:updateBottom('Main')
 self:resetView()

 self.subviews.main.visible = true
end
function DetailedUnitView:viewDetails()
 self:updateBottom('Details')
 self:resetView()

 self.subviews.detailedView.visible = true
end
function DetailedUnitView:viewHealth()
 self:updateBottom('Health')
 self:resetView()

 self.subviews.healthView.visible = true
end
function DetailedUnitView:viewThoughts()
 self:updateBottom('Thoughts')
 self:resetView()

 self.subviews.thoughtView.visible = true
end
function DetailedUnitView:viewClasses()
 self:updateBottom('Classes')
 self:resetView()

 self.subviews.classView.visible = true
 self.subviews.classView.active = true
 self.subviews.C_BX.active  = true
 self.subviews.C_BX:setSelected(2)
printall(self.subviews.classView.subviews.C_BX.frame)
end
function DetailedUnitView:viewFeats()
 self:updateBottom('Feats')
 self:resetView()

 self.subviews.featView.visible = true
 self.subviews.F_BX.active      = true
end
function DetailedUnitView:viewSpells()
 self:updateBottom('Spells')
 self:resetView()
 
 self.subviews.spellView.visible = true
 self.subviews.S_BX.active       = true
end

--= Base Functions
function DetailedUnitView:onInput(keys)
 if keys.LEAVESCREEN then
  if self.subviews.main.visible then
   self:dismiss()
  else
   self:viewMain()
  end
 else
  DetailedUnitView.super.onInput(self, keys)
 end
end
function show_editor(trg)
 local screen = DetailedUnitView{target=trg}
 screen:show()
end

show_editor(getTargetFromScreens())
Logged

Silverwing235

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1549 on: November 29, 2018, 04:01:41 pm »

Apologies if its the wrong place....How to put this? You know how the default of exportlegends unpacking into DF root can be rather annoying for some people, myself included? Well,  I suggest that it unpack into the empty folder 'legends' in DF root instead.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1550 on: November 29, 2018, 07:17:51 pm »

It matches the behavior of the vanilla legends exporter, which we cannot change (in particular, it directly triggers some of the vanilla export features, e.g. maps). It might be possible to do this by comparing the contents of the DF folder before and after exporting and moving any new files, although that seems potentially risky if users make their own files for whatever reason. In any case, this is a good place to ask.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Droggarth

  • Bay Watcher
  • Ischrotaur Axe Lord [SUPERNATURAL][STRANGE_MOODS]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1551 on: December 01, 2018, 08:39:06 pm »

Is there a way to change one's species after selecting a species during character creation with dfhack? I've been doing that with DF Tool previously but he hasn't updated it for a while and so it doesn't work for .44.12.

Mainly posting for curiosity and in hopes of being able to do same with dfhack.
Logged
"I'll make my own way." - Max Rockatansky

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1552 on: December 01, 2018, 09:05:58 pm »

Everything that can be done with DF Tool can be done with DFHack. I don't know the exact field in question off the top of my head, but it's probably in the adventurer setup viewscreen.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Droggarth

  • Bay Watcher
  • Ischrotaur Axe Lord [SUPERNATURAL][STRANGE_MOODS]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1553 on: December 01, 2018, 10:37:26 pm »

Ah, nice so it's doable. All I need then now are some commands, windows.. something, more info basically. Gonna look up some.
Logged
"I'll make my own way." - Max Rockatansky

Droggarth

  • Bay Watcher
  • Ischrotaur Axe Lord [SUPERNATURAL][STRANGE_MOODS]
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1554 on: December 01, 2018, 10:38:09 pm »

(Accidental double post)
« Last Edit: December 01, 2018, 11:01:51 pm by Droggarth »
Logged
"I'll make my own way." - Max Rockatansky

bloop_bleep

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1555 on: December 09, 2018, 09:43:04 pm »

I have two questions.
  • df::item::addWear takes three arguments, an int16_t (which I assume is the amount of wear) and two other Booleans. What do these last two arguments mean? I ask because steam-engine.cpp seems to use both the (true, false) and (true, true) combinations, and neither of these seem to actually change the wear value when inspected with lua.
  • How do I make DFHack compile a plugin with certain compiler flags? The plugin I'm writing generates a lot of narrowing-conversion warnings which are entirely unhelpful and in fact probably obscured a useful warning that would've saved me a lot of debugging. If this is not possible, how I add to global compilation flags?
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1556 on: December 10, 2018, 04:00:12 am »

@bloop_bleep: Firstly, why do you perform all of these narrowing type conversions, rather than keep the original types? Secondly, if you actually need to perform a narrowing type conversion and are sure it actually is safe, it's usually better to perform an explicit conversion in each of those cases than to turn off warnings.
Logged

FantasticDorf

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1557 on: December 10, 2018, 09:36:42 am »

the ones that might be relevant to social/break-related things being "TIME_SINCE_BREAK" and "ON_BREAK". In lua, these counters (and a lot more) can be found in the unit's status.misc_traits (provided they're active/whatever)
Hm, I can try those, although I'm not sure they're used any more in the current game version; in my fort of 112 citizens, not a single one has a misc_trait with id 16 (TimeSinceBreak) or 17 (OnBreak). Also, the problem I'm having isn't just with dwarves aborting my forced social activity for an actual job (teal text); they'll take a few steps pathing toward my activity and then stop and switch to a different idle activity (i.e. stop walking to the temple and instead go to Individual Combat Drill or to the library to read). That's why I was hoping to figure out the criteria for Purple! idle activities, to maybe get them to stick with what I assigned and not switch to something else.

'SeekStation' goal paths in 'Path' of gui/editor causes a lot of this erratic behaviour in conjunction with how locations are defined . I believe Toady fixed up a blew up error regarding this when he fixed museum zones not working (they still dont work but they don't flat out not work) by simply tagging it to correct the mistake so that in theory dwarves without 'buildings/locations' would go there.

Seekstation is not voluntarily shut off either, as the most blatent effects can be seen by setting to idle activitity none <1> or (MeetingLocation <18> / MeetingLocationBuilding <19>) which do the same but are location-friendly. Dwarves will run into libraries without books or meeting zones without location areas and immediately reroute to the nearest other one upon realising there's nowhere to go for the goal.

When they arrive at a 'building' they will unset their goalpathing to 'none' and remain -3000 xyz still until they have a job or pressing need presented to them. Which is the critical flaw why setting needs in 'status' to 10,000 will never yield any kind of result because the actual pathfinding is abysmally poor and will always throw and abandon them in a room to fill needs they dont need endlessly.

Taking a guess, combat drills must probably also be doing this.
Logged

Zeronet

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1558 on: December 10, 2018, 05:09:52 pm »

Is stonesense maintained by anybody? There seems to be an issue where constructed walls & floors are using the sprite for smoothed stone walls & floors, rather than the sprite for constructed walls.

Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.12-r1
« Reply #1559 on: December 10, 2018, 07:07:56 pm »

@bloop_bleep: Firstly, why do you perform all of these narrowing type conversions, rather than keep the original types?

Haha, believe me, I tried. It usually happens in the case where I’m dividing two values, and I can’t seem to be able to find the right combination of types such that the division is allowed and works as expected while also the end result matches the type desired by DF.

As for explicit typecasting, I might do that, but honestly sometimes I just can’t be bothered. Besides, it produces the same effect, and probably hurts readability.

If you know, is there any way to set compiler options globally (i.e. for the entire DFHack build)?

Additionally, could I have the username of the person who wrote steam-engine.cpp, so I could message them.
« Last Edit: December 10, 2018, 07:10:41 pm by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.
Pages: 1 ... 102 103 [104] 105 106 ... 243