Skip to content

Commit 0d12bd6

Browse files
committed
Fix most of the remaining luacheck issues in scripts.
Scripts still to do: - gui/*.lua - exportlegends.lua - fixnaked.lua
1 parent 1d1c4fb commit 0d12bd6

57 files changed

Lines changed: 376 additions & 352 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

add-thought.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local utils=require('utils')
1515
function addEmotionToUnit(unit,thought,emotion,severity,strength,subthought)
1616
local emotions=unit.status.current_soul.personality.emotions
1717
if not (tonumber(emotion)) then
18-
emotion=df.emotion_type[emotion]
18+
emotion=df.emotion_type[emotion] --luacheck: retype
1919
end
2020
local properThought = tonumber(thought) --as:df.unit_thought_type
2121
local properSubthought = tonumber(subthought)

adv-max-skills.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if dfhack.gui.getCurFocus() ~= 'setupadventure' then
1111
qerror('Must be called on adventure mode setup screen')
1212
end
1313

14-
adv = dfhack.gui.getCurViewscreen().adventurer
14+
local adv = dfhack.gui.getCurViewscreen().adventurer --hint:df.viewscreen_setupadventurest
1515
for k in pairs(adv.skills) do
1616
adv.skills[k] = df.skill_rating.Legendary5
1717
end

adv-rumors.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Improves the "Bring up specific incident or rumor" menu in Adventure mode.
2828
-- shortenString = will further shorten the line to = slew "XYZ" ( "n time" ago in " Region")
2929
--=======================
3030

31-
utils = require "utils"
31+
local utils = require "utils"
3232

33-
names_blacklist = utils.invert{"a", "an", "you", "attacked", "slew", "was", "slain", "by"}
33+
local names_blacklist = utils.invert{"a", "an", "you", "attacked", "slew", "was", "slain", "by"}
3434

3535
function condenseChoiceTitle(choice)
3636
while #choice.title > 1 do
@@ -46,10 +46,10 @@ function addKeyword(choice, keyword)
4646
end
4747

4848
function rumorUpdate()
49-
improveReadability = true
50-
addKeywordSlew = true
51-
shortenString = true
52-
addKeywordNames = true
49+
local improveReadability = true
50+
local addKeywordSlew = true
51+
local shortenString = true
52+
local addKeywordNames = true
5353

5454
for i, choice in ipairs(df.global.ui_advmode.conversation.choices) do
5555
if choice.choice.type == df.talk_choice_type.SummarizeConflict then

bodyswap.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
--@ module = true
77

88
local utils = require 'utils'
9-
validArgs = utils.invert({
9+
local validArgs = utils.invert({
1010
'unit',
1111
'help'
1212
})
@@ -94,15 +94,15 @@ function swapAdvUnit(newUnit)
9494
if activeUnits[0] == oldUnit then
9595
oldUnitIndex = 0
9696
else -- unlikely; this is just in case
97-
for i,u in pairs(activeUnits) do
97+
for i,u in ipairs(activeUnits) do
9898
if u == oldUnit then
9999
oldUnitIndex = i
100100
break
101101
end
102102
end
103103
end
104104
local newUnitIndex
105-
for i,u in pairs(activeUnits) do
105+
for i,u in ipairs(activeUnits) do
106106
if u == newUnit then
107107
newUnitIndex = i
108108
break

brainwash.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Usage: ``brainwash <type>``, with one of the following types:
2121
function brainwash_unit(profile)
2222
local i,unit_name
2323

24-
unit=dfhack.gui.getSelectedUnit()
24+
local unit=dfhack.gui.getSelectedUnit()
2525
if unit==nil then
2626
print ("No unit under cursor! Aborting.")
2727
return

burial.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ of pets.
1111

1212
local utils=require('utils')
1313

14-
validArgs = utils.invert({
14+
local validArgs = utils.invert({
1515
'pets'
1616
})
1717

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

20-
for k,v in ipairs(df.global.world.buildings.other.COFFIN) do
20+
for k,v in ipairs(df.global.world.buildings.other.COFFIN) do --as:df.building_coffinst
2121
if v.owner_id==-1 then
2222
v.burial_mode.allow_burial=true
2323
if not args.pets then

caravan.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ local function list()
7272
end
7373

7474
local function extend(days, ...)
75-
days = tonumber(days or 7) or qerror('invalid number of days: ' .. days)
75+
days = tonumber(days or 7) or qerror('invalid number of days: ' .. days) --luacheck: retype
7676
for id, car in pairs(caravans_from_ids{...}) do
7777
car.time_remaining = car.time_remaining + (days * 120)
7878
bring_back(car)

catsplosion.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ if list_only then
6767
end
6868

6969
for id in pairs(creatures) do
70-
local females = females[id] or {}
71-
total = total + #females
72-
for _, female in pairs(females) do
70+
total = total + #(females[id] or {})
71+
for _, female in pairs(females[id]) do
7372
if female.pregnancy_timer ~= 0 then
7473
female.pregnancy_timer = math.random(1, 100)
7574
total_changed = total_changed + 1

combine-plants.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Merge stacks of plants or plant growths in the selected container or stockpile.
88
]====]
99
local utils = require 'utils'
1010

11-
validArgs = utils.invert({ 'max', 'stockpile', 'container' })
11+
local validArgs = utils.invert({ 'max', 'stockpile', 'container' })
1212
local args = utils.processArgs({...}, validArgs)
1313

1414
local max = 12
@@ -22,8 +22,8 @@ if args.container then container = df.item.find(tonumber(args.container)) end
2222

2323
function itemsCompatible(item0, item1)
2424
return item0:getType() == item1:getType()
25-
and item0.mat_type == item1.mat_type
26-
and item0.mat_index == item1.mat_index
25+
and item0.mat_type == item1.mat_type --hint:df.item_plantst
26+
and item0.mat_index == item1.mat_index --hint:df.item_plantst
2727
end
2828

2929
function getPlants(items, plants, index)
@@ -32,7 +32,7 @@ function getPlants(items, plants, index)
3232
for _,v in pairs(items) do
3333
-- Skip items currently tasked
3434
if #v.specific_refs == 0 then
35-
if v:getType() == 53 or v:getType() == 55 or v:getType() == 70 then
35+
if v:getType() == df.item_type.PLANT or v:getType() == df.item_type.PLANT_GROWTH or v:getType() == df.item_type.CHEESE then
3636
plants[index] = v
3737
index = index + 1
3838

@@ -70,14 +70,14 @@ else
7070
error("Select a non-empty container")
7171

7272
else
73-
local plants = { }
73+
local plants = { } --as:df.item_actual[]
7474
local plantCount = getPlants(rootItems, plants, 0)
7575
print("found " .. plantCount .. " plants")
7676

77-
local removedPlants = { }
77+
local removedPlants = { } --as:bool[]
7878

7979
for i=0,(plantCount-2) do
80-
local currentPlant = plants[i]
80+
local currentPlant = plants[i] --as:df.item_plantst
8181
local itemsNeeded = max - currentPlant.stack_size
8282

8383
if removedPlants[currentPlant.id] == nil and itemsNeeded > 0 then

devel/export-dt-ini.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local globals = df.global
1414
local global_addr = dfhack.internal.getAddress
1515
local os_type = dfhack.getOSType()
1616
local rdelta = dfhack.internal.getRebaseDelta()
17-
local lines = {}
17+
local lines = {} --as:string[]
1818
local complete = true
1919

2020
local function header(name)

0 commit comments

Comments
 (0)