Thanks.Then I make mine like yours,a bigger one like dfusion.
Sorry.I chack it in a new way(a popular way) and find it dosen't work. Now error has been fixed.(putin DF_Phoebus_34_10\hack\scripts)
--skill.lua
--by zkm2erjfdb, version 1, 20120530
--usage is: target a unit in DF, and execute this script in dfhack
--via ' lua /path/to/script skillname '
--check/add/delete skills. also can make skill to 20 (Legendary +5),or delete it
--Greetings to you from China,play happier
function sbname(unit)
return dfhack.TranslateName(dfhack.units.getVisibleName(unit))
end
function skid_post(skid)
return list_post[skid+1]
end
function skid_job(skid)
return df.job_skill[skid]
end
function skid_work(skid)
return df.job_skill.attrs[skid].caption
end
function post_skid(skillname)
for sk,sv in ipairs(list_post) do
if sv==skillname then
return sk-1
end
end
end
function job_skid(skillname)
return df.job_skill[skillname]
end
function work_skid(skillname)
local i = 0
for i=0, 115 do
if df.job_skill.attrs[i].caption==skillname then
return i
end
end
end
function get_skid(skid)
while true do
local skenter=dfhack.lineedit("Enter the skill id/name/post.. or ('q'/just Enter to quit):")
if skenter=='q' or skenter=='' then return end
skid=tonumber(skenter)
if skid==nil then
skid=post_skid(skenter)
if skid==nil then
skid=job_skid(skenter)
if skid==nil then
skid=work_skid(skenter)
end
end
end
if skid==nil then
print("Sorry no such skill")
elseif skid<0 or skid>115 then
print("Sorry no such skill")
else
return skid
end
end
end
function sbsk_list(unit)
if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.")
return
end
print("skill's list for ---"..sbname(unit))
print(string.format("%18s|%3s|%3s|%3s|%5s|%3s%5s","post('v'sb.->'g')","No.","ID","Lv","exp"," ","rusty?"))
for sk,sv in ipairs(unit.status.souls[0].skills) do
print(string.format("%18s|%3s|%3s|%3s|%5s|%3s|%3s|%3s|%3s|%3s",skid_post(sv.id),sk,sv.id,sv.rating,sv.experience,sv.unk_c,sv.rusty,sv.unk_14,sv.unk_18,sv.unk_1c))
end
end
function all_list(unit)
for _,unit in ipairs(df.global.world.units.all) do
if unit.race == df.global.ui.race_id then
sbsk_list(unit)
end
end
end
function skill_del(unit)
while true do
if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.")
return
end
local i = 0
print("Enter a skill to ---Delete---"..sbname(unit))
skid=get_skid()
if skid==nil then return end
for sk,sv in ipairs(unit.status.souls[0].skills) do
if sv.id==skid then
print(string.format("%18s|%3s|%3s|%3s|%5s|%3s%5s","post('v'sb.->'g')","No.","ID","Lv","exp"," ","rusty?"))
print(string.format("%18s|%3s|%3s|%3s|%5s|%3s|%3s|%3s|%3s|%3s",skid_post(skid),sk,sv.id,sv.rating,sv.experience,sv.unk_c,sv.rusty,sv.unk_14,sv.unk_18,sv.unk_1c))
print("The skill above have been Deleted")
unit.status.souls[0].skills:erase(sk)
i=1
break
end
end
if i==0 then
sbsk_list(unit)
print("He has no such skill")
end
end
end
function skill_add(unit)
while true do
if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.")
return
end
print("Enter a skill to ---Add---"..sbname(unit))
skid=get_skid()
if skid==nil then return end
local ratn=dfhack.lineedit("Enter the skill rating (number) or (press Enter rating=20):")
ratn=tonumber(ratn)
if ratn==nil then ratn=20 end
local expn=dfhack.lineedit("Enter the skill experience (number) or (press Enter exp=0)[unimportance]:")
expn=tonumber(expn)
if expn==nil then expn=0 end
print("To Add :"..skid_post(skid),"rating = "..ratn,"experience = "..expn)
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = skid, rating = ratn,experience = expn }, 'id')
for sk,sv in ipairs(unit.status.souls[0].skills) do
if sv.id==skid then
print(string.format("%18s|%3s|%3s|%3s|%5s|%3s%5s","post('v'sb.->'g')","No.","ID","Lv","exp"," ","rusty?"))
print(string.format("%18s|%3s|%3s|%3s|%5s|%3s|%3s|%3s|%3s|%3s",skid_post(skid),sk,sv.id,sv.rating,sv.experience,sv.unk_c,sv.rusty,sv.unk_14,sv.unk_18,sv.unk_1c))
print("The skill above have been Add,choose 'List' to check all his skills")
end
end
end
end
function skill_clean(unit)
if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.")
return
end
print ("--------Clean skill's list for --->"..sbname(unit))
for sk,sv in ipairs(unit.status.souls[0].skills) do
sv.unk_c=0
sv.rusty=0
sv.unk_14=0
sv.unk_18=0
sv.unk_1c=0
end
print("--------Clean over")
end
function skill_cleanall(unit)
for _,unit in ipairs(df.global.world.units.all) do
if unit.race == df.global.ui.race_id then
skill_clean(unit)
end
end
end
function skill_find(skid)
while true do
skid=get_skid()
if skid==nil then return end
print(string.format("%18s|%3s|%22s|%18s|","post('v'sb.->'g')","ID","JOB","Work"))
print(string.format("%18s|%3d|%22s|%18s|",skid_post(skid),skid,skid_job(skid),skid_work(skid)))
end
end
function skill_list(skid)
local i
print("These all may work")
print(string.format("%18s|%3s|%22s|%18s|","post('v'sb.->'g')","ID"," JOB "," Work"))
for i=0, 115 do
print(string.format("%18s|%3d|%22s|%18s|",skid_post(i),i,skid_job(i),skid_work(i)))
end
print("These all may work")
end
function mainmenu(t1)
print(string.format("%30s","skill ID or name like Miner / MINING / Mining"))
print(string.format("%30s","IF you don't now all.choose 'Find all'"))
while true do
unit=dfhack.gui.getSelectedUnit()
print(string.format("%30s","For Skills"))
print(string.format("%5s %15s %5s","No.","Name","Desc"))
for k,v in pairs(t1) do
print(string.format("%5d %13s ->%s",k,v[1],v[2]))
end
local q=dfhack.lineedit("Select plugin to run (q or Enter to quit):")
if q=='q' then return end
q=tonumber(q)
if q~=nil then
if q>=1 and q<=#t1 then
t1[q][3](unit)
end
else
return
end
end
end
list_post={"Miner","Wood Cutter","Carpenter","Engraver","Mason","Animal Trainer","Animal Caretaker","Fish Dissector","Animal Dissector","Fish Cleaner","Butcher","Trapper","Tanner","Weaver","Brewer","Alchemist","Clothier","Miller","Thresher","Cheese Maker","Milker","Cook","Grower","Herbalist","Fisherdwarf","Furnace Operator","Strand Extractor","Weaponsmith","Armorsmith","Metalsmith","Gem Cutter","Gem Setter","Wood Crafter","Stone Crafter","Metal Crafter","Glassmaker","Leatherworker","Bone Carver","Axedwarf","Swordsdwarf","Knife User","Macedwarf","Hammerdwarf","Speardwarf","Marksdwarf","Shield User","Armor User","Siege Engineer","Siege Operator","Bowyer","Pikeman","Lasher","Bowman","Blowgunner","Thrower","Mechanic","Druid","Ambusher","Building Designer","Wound Dresser","Diagnostician","Surgeon","Bone Doctor","Suturer","Crutch Walker","Wood Burner","Lye Maker","Soaper","Potash Maker","Dyer","Pump Operator","Swimmer","Persuader","Negotiator","Judge of Intent","Appraiser","Organizer","Record Keeper","Liar","Intimidator","Conversationalist","Comedian","Flatterer","Consoler","Pacifier","Tracker","Student","Concentration","Discipline","Observer","Wordsmith","Writer","Poet","Reader","Speaker","Coordination","Balance","Leader","Teacher","Fighter","Archer","Wrestler","Biter","Striker","Kicker","Dodger","Misc. Object User","Knapper","Military tactics","Shearer","Spinner","Potter","Glazer","Presser","Bee Keeper","Wax Worker"}
utils = require 'utils'
plugins={}
table.insert(plugins,{"List","All skills list of sb.",sbsk_list})
table.insert(plugins,{"Add","Add skill to sb.",skill_add})
table.insert(plugins,{"Del","Delete skill from sb.",skill_del})
table.insert(plugins,{"find","Find one skill massage",skill_find})
table.insert(plugins,{"Find all","Check all skills",skill_list})
table.insert(plugins,{"Clean","Clean sb skill rusty?(maybe)",skill_clean})
table.insert(plugins,{"clean all","Clean all skill rusty?(maybe)",skill_cleanall})
table.insert(plugins,{"ListALL","All skills list of all people.",all_list})
mainmenu(plugins)
I'm trying to make it a better view.Is it works?I find : just 'u' In Unit List is also work.
legendary is not I want..
But "put it into the dfhack scripts directory" mean what? I don't know about dfhack scripts directory,where can I find it?
I sleep you wake up,you sleep I wake up ......