I wrote it after seeing that someone else had created code for a different purpose.
I don’t know the principle, But it just works.
I tried to write for dcss(game) RC
The content of the image is a list of orders that are being memorised.
The purpose of the code is to enable efficient training of memorized spells
It works normally when training 1 spell (now only have 1 memorized spell in total)
When memorizing multiple spells saved in SetSpellTraining
Start training it all
But, starting to train multiple spells “at the same time” is very inefficient.
(image situation, memorising a few orders.)
function ready()
SetSpellTraining("Passwall","Earth Magic","Earth Magic","Earth Magic",1)
SetSpellTraining("Mephitic Cloud","Conjurations","Air Magic","Alchemy",5)
SetSpellTraining("Ensorcelled Hibernation","Hexes","Ice Magic","Ice Magic",1)
SetSpellTraining("Corpse Rot","Air","Necromancy","Poison",5)
.
.
.
-- I have over 20 SetSpellTraining but I didn't write them here.
end
local school_a_cost = tonumber(you.skill_cost(school_a))
local school_b_cost = tonumber(you.skill_cost(school_b))
local school_c_cost = tonumber(you.skill_cost(school_c))
local school_2_min_cost = tonumber(math.min(school_a_cost,school_b_cost))
local school_3_min_cost = tonumber(math.min(school_a_cost,school_b_cost,school_c_cost))
if spells.memorised(spell_name) then
if school_a == school_b then
if spells.fail(spell_name) > fail_chance then
you.train_skill(school_a, 1)
else
you.train_skill(school_a, 0)
end
elseif school_a ~= school_b and school_b == school_c then
if spells.fail(spell_name) > fail_chance then
if school_a_cost == school_2_min_cost then
you.train_skill(school_a, 1)
you.train_skill(school_b, 0)
else
you.train_skill(school_a, 0)
you.train_skill(school_b, 1)
end
else
you.train_skill(school_a, 0)
you.train_skill(school_b, 0)
end
else
if spells.fail(spell_name) > fail_chance then
if school_a_cost == school_3_min_cost then
you.train_skill(school_a, 1)
you.train_skill(school_b, 0)
you.train_skill(school_c, 0)
elseif school_b_cost == school_3_min_cost then
you.train_skill(school_a, 0)
you.train_skill(school_b, 1)
you.train_skill(school_c, 0)
else
you.train_skill(school_a, 0)
you.train_skill(school_b, 0)
you.train_skill(school_c, 1)
end
else
you.train_skill(school_a, 0)
you.train_skill(school_b, 0)
you.train_skill(school_c, 0)
end
end
end
end
Q
Currently the code written in the text works, but if there are multiple memorized spells like in the image, they “start training at the same time”. While training one spell, I want to stop training another spell.
zocn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5