if you.turns() > 1 then
pskill = c_persist.pskill
pgoal = c_persist.pgoal
end
skill_list = {f="Fighting",s="Short Blades",l="Long Blades",x="Axes",
m="Maces & Flails",p="Polearms",v="Staves",u="Unarmed Combat",b="Bows",
c="Crossbows",r="Throwing",g="Slings",a="Armour",d="Dodging",h="Shields",
S="Spellcasting",J="Conjurations",H="Hexes",C="Charms",U="Summonings",
N="Necromancy",L="Translocations",M="Transmutations",F="Fire Magic",
I="Ice Magic",A="Air Magic",E="Earth Magic",P="Poison Magic",i="Invocations",
e="Evocations",t="Stealth"}
function train_only(sk)
for k, v in pairs(skill_list) do you.train_skill(v, 0) end
you.train_skill(sk, 1)
end
local _ready = ready
function ready()
if _ready then _ready() end
if pskill and you.skill(pskill) >= pgoal then
crawl.mpr(('Finished training %s to level %1.1f.'):format(pskill, pgoal))
crawl.more()
pskill = nil; pgoal = nil
skillto()
end
c_persist.pskill = pskill
c_persist.pgoal = pgoal
end
>
{
function skillto()
function f(s)
s = string.gsub(s, '((%S*)([%[%{])(%w)[%]%}](%S*))',
function(full, pre, brace, letter, post)
local k = brace == '[' and letter:lower() or letter:upper()
local skill = skill_list[k]
local stripped = pre .. letter .. post
if pskill and skill == pskill then
return '' .. full .. ''
elseif you.skill(skill) == 27.0 then
return '' .. stripped .. ''
elseif you.can_train_skill(skill) then
return full
else
return '' .. stripped .. ''
end
end)
s = string.gsub(s, '%[', '')
s = string.gsub(s, '%]', '')
s = string.gsub(s, '%{', '')
s = string.gsub(s, '%}', '')
return s
end
function print_skills()
crawl.clear_messages(true)
crawl.mpr(f('[F]gt [S]bl [L]bl A[x]s [M]&F [P]la St[v] [U]C [B]ws '
..'[C]rb Th[r] Sl[g] [A]rm [D]dg S[h]d'), 2)
crawl.mpr(f('{S}pc Cn{J} {H}ex {C}ha S{U}m {N}ec Tr{L} Tr{M} {F}ir {I}ce '
..'{A}ir {E}ar {P}oi [I]nv [E]vo S[t]h'), 2)
end
print_skills()
crawl.mpr(f('Train which skill ([Letter] or {Shift+Letter})? '), 2)
new_pskill = skill_list[string.char(crawl.getch())]
print_skills()
if not new_pskill then
crawl.mpr('Okay, then.', 2)
return
elseif not you.can_train_skill(new_pskill) then
crawl.mpr("You can't currently train " .. new_pskill .. ".", 29)
crawl.more()
return skillto()
end
local current = you.skill(new_pskill)
local goalstring = ''
if pskill and new_pskill == pskill then
goalstring = (' -> %1.1f'):format(pgoal)
end
crawl.mpr(('Train %s to which level (currently at %1.1f%s)? '):
format(new_pskill, current, goalstring), 2)
new_pgoal = tonumber(crawl.c_input_line())
if not new_pgoal then
return skillto()
elseif current >= new_pgoal then
crawl.mpr(("You're already at level %1.1f!"):format(current), 29)
crawl.more()
return skillto()
end
pskill = new_pskill
pgoal = new_pgoal
train_only(pskill)
crawl.mpr(("Started training %s to %1.1f."):format(pskill, pgoal), 2)
end
function unskillto()
if pskill then
crawl.mpr("Skills adjusted manually; disabling skillto.", 29)
pskill = nil; pgoal = nil
end
crawl.sendkeys("m")
end
function skillto_info()
if pskill then
crawl.mpr(("You are training %s (%1.1f -> %1.1f)."):
format(pskill, you.skill(pskill), pgoal))
end
crawl.sendkeys("@")
end
}