From cbe5a2de1592e402808e962de8d346829aa5aba4 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 9 Jun 2012 17:18:46 +0200 Subject: Lua: Move "ability" help to C --- lib/mods/theme/scpt/help.lua | 14 -------------- lib/scpt/help.lua | 14 -------------- src/externs.h | 1 + src/help.c | 24 ++++++++++++++++++++++++ src/skills.c | 6 ++++-- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/lib/mods/theme/scpt/help.lua b/lib/mods/theme/scpt/help.lua index 421cdb11..9d53ba40 100644 --- a/lib/mods/theme/scpt/help.lua +++ b/lib/mods/theme/scpt/help.lua @@ -24,20 +24,6 @@ ingame_help -- list of files for classes, { filename, anchor } local t = { - ["ability"] = - { - ["Spread blows"] = { "ability.txt", 02 }, - ["Tree walking"] = { "ability.txt", 03 }, - ["Perfect casting"] = { "ability.txt", 04 }, - ["Extra Max Blow(1)"] = { "ability.txt", 05 }, - ["Extra Max Blow(2)"] = { "ability.txt", 06 }, - ["Ammo creation"] = { "ability.txt", 07 }, - ["Touch of death"] = { "ability.txt", 08 }, - ["Artifact Creation"] = { "ability.txt", 09 }, - ["Far reaching attack"] = { "ability.txt", 10 }, - ["Trapping"] = { "ability.txt", 11 }, - ["Undead Form"] = { "ability.txt", 12 }, - }, } if t[typ][name] then ingame_help_doc(t[typ][name][1], t[typ][name][2]) diff --git a/lib/scpt/help.lua b/lib/scpt/help.lua index 421cdb11..9d53ba40 100644 --- a/lib/scpt/help.lua +++ b/lib/scpt/help.lua @@ -24,20 +24,6 @@ ingame_help -- list of files for classes, { filename, anchor } local t = { - ["ability"] = - { - ["Spread blows"] = { "ability.txt", 02 }, - ["Tree walking"] = { "ability.txt", 03 }, - ["Perfect casting"] = { "ability.txt", 04 }, - ["Extra Max Blow(1)"] = { "ability.txt", 05 }, - ["Extra Max Blow(2)"] = { "ability.txt", 06 }, - ["Ammo creation"] = { "ability.txt", 07 }, - ["Touch of death"] = { "ability.txt", 08 }, - ["Artifact Creation"] = { "ability.txt", 09 }, - ["Far reaching attack"] = { "ability.txt", 10 }, - ["Trapping"] = { "ability.txt", 11 }, - ["Undead Form"] = { "ability.txt", 12 }, - }, } if t[typ][name] then ingame_help_doc(t[typ][name][1], t[typ][name][2]) diff --git a/src/externs.h b/src/externs.h index 6b416e7e..e1f77bc1 100644 --- a/src/externs.h +++ b/src/externs.h @@ -623,6 +623,7 @@ extern void help_subrace(cptr subrace); extern void help_class(cptr klass); extern void help_god(cptr god); extern void help_skill(cptr skill); +extern void help_ability(cptr ability); /* birth.c */ extern void print_desc_aux(cptr txt, int y, int x); diff --git a/src/help.c b/src/help.c index 510fe2dd..a19b7b27 100644 --- a/src/help.c +++ b/src/help.c @@ -281,6 +281,25 @@ context_help_type skill_table[] = { NULL, NULL, 0 }, }; +/** + * Ability help files + */ +context_help_type ability_table[] = +{ + { "Spread blows", "ability.txt", 2 }, + { "Tree walking", "ability.txt", 3 }, + { "Perfect casting", "ability.txt", 4 }, + { "Extra Max Blow(1)", "ability.txt", 5 }, + { "Extra Max Blow(2)", "ability.txt", 6 }, + { "Ammo creation", "ability.txt", 7 }, + { "Touch of death", "ability.txt", 8 }, + { "Artifact Creation", "ability.txt", 9 }, + { "Far reaching attack", "ability.txt", 10 }, + { "Trapping", "ability.txt", 11 }, + { "Undead Form", "ability.txt", 12 }, + { NULL, NULL, 0 }, +}; + /** * Trigger functions */ @@ -707,3 +726,8 @@ void help_skill(cptr skill) { show_context_help(find_context_help(skill_table, skill)); } + +void help_ability(cptr ability) +{ + show_context_help(find_context_help(ability_table, ability)); +} diff --git a/src/skills.c b/src/skills.c index 2a0a4f18..aba838be 100644 --- a/src/skills.c +++ b/src/skills.c @@ -1611,8 +1611,10 @@ if (ab_info[i].name) if (wizard && (c == '-')) ab_info[table[sel]].acquired = FALSE; /* Contextual help */ - if (c == '?') exec_lua(format("ingame_help('select_context', 'ability', '%s')", ab_info[table[sel]].name + ab_name)); - ; + if (c == '?') + { + help_ability(ab_info[table[sel]].name + ab_name); + } /* Handle boundaries and scrolling */ if (sel < 0) sel = max - 1; -- cgit v1.2.3