Eliminate magic numbers from the fixnaked script.
parent
6be752454d
commit
eae94693f7
@ -1,58 +1,41 @@
|
|||||||
function fixnaked()
|
function fixnaked()
|
||||||
local total_fixed = 0
|
local total_fixed = 0
|
||||||
local total_uncovered = 0
|
local total_removed = 0
|
||||||
local total_noshirt = 0
|
|
||||||
local total_noshoes = 0
|
|
||||||
|
|
||||||
for fnUnitCount,fnUnit in ipairs(df.global.world.units.all) do
|
for fnUnitCount,fnUnit in ipairs(df.global.world.units.all) do
|
||||||
if fnUnit.race == df.global.ui.race_id then
|
if fnUnit.race == df.global.ui.race_id then
|
||||||
local listEvents = fnUnit.status.recent_events
|
local listEvents = fnUnit.status.recent_events
|
||||||
--for lkey,lvalue in pairs(listEvents) do
|
--for lkey,lvalue in pairs(listEvents) do
|
||||||
-- print(df.unit_thought_type[lvalue.type],lvalue.type,lvalue.age,lvalue.subtype,lvalue.severity)
|
-- print(df.unit_thought_type[lvalue.type],lvalue.type,lvalue.age,lvalue.subtype,lvalue.severity)
|
||||||
--end
|
--end
|
||||||
|
|
||||||
local found = 1
|
local found = 1
|
||||||
local fixed = 0
|
local fixed = 0
|
||||||
while found == 1 do
|
while found == 1 do
|
||||||
local events = fnUnit.status.recent_events
|
local events = fnUnit.status.recent_events
|
||||||
found = 0
|
found = 0
|
||||||
for k,v in pairs(events) do
|
for k,v in pairs(events) do
|
||||||
if v.type == 109 then
|
if v.type == df.unit_thought_type.Uncovered
|
||||||
events:erase(k)
|
or v.type == df.unit_thought_type.NoShirt
|
||||||
found = 1
|
or v.type == df.unit_thought_type.NoShoes
|
||||||
total_uncovered = total_uncovered + 1
|
or v.type == df.unit_thought_type.NoCloak
|
||||||
fixed = 1
|
or v.type == df.unit_thought_type.OldClothing
|
||||||
break
|
or v.type == df.unit_thought_type.TatteredClothing
|
||||||
end
|
or v.type == df.unit_thought_type.RottedClothing then
|
||||||
if v.type == 110 then
|
events:erase(k)
|
||||||
events:erase(k)
|
found = 1
|
||||||
found = 1
|
total_removed = total_removed + 1
|
||||||
total_noshirt = total_noshirt + 1
|
fixed = 1
|
||||||
fixed = 1
|
break
|
||||||
break
|
end
|
||||||
end
|
end
|
||||||
if v.type == 111 then
|
end
|
||||||
events:erase(k)
|
if fixed == 1 then
|
||||||
found = 1
|
total_fixed = total_fixed + 1
|
||||||
total_noshoes = total_noshoes + 1
|
print(total_fixed, total_removed, dfhack.TranslateName(dfhack.units.getVisibleName(fnUnit)))
|
||||||
fixed = 1
|
end
|
||||||
break
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if fixed == 1 then
|
|
||||||
total_fixed = total_fixed + 1
|
|
||||||
print(total_fixed, total_uncovered+total_noshirt+total_noshoes,dfhack.TranslateName(dfhack.units.getVisibleName(fnUnit)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
print("thought 109 = "..df.unit_thought_type[109])
|
|
||||||
print("thought 110 = "..df.unit_thought_type[110])
|
|
||||||
print("thought 111 = "..df.unit_thought_type[111])
|
|
||||||
print("Total Fixed: "..total_fixed)
|
print("Total Fixed: "..total_fixed)
|
||||||
print("Total thoughts removed: "..total_uncovered)
|
|
||||||
print("Total thoughts removed: "..total_noshirt)
|
|
||||||
print("Total thoughts removed: "..total_noshoes)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
fixnaked()
|
fixnaked()
|
||||||
|
Loading…
Reference in New Issue