diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-05-15 21:29:50 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-05-16 06:03:31 +0200 |
commit | 7c95b69311bcbadb84fba499584fe721612ca144 (patch) | |
tree | 95f0880109e7728b07b02740138751ae232c1bb2 /src/cmd5.c | |
parent | b446c8368b172aa29d312cf7eeca5e8547e73c81 (diff) |
Lua: Move 'print_spell_desc' and 'spell_x' to C
Diffstat (limited to 'src/cmd5.c')
-rw-r--r-- | src/cmd5.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -17,6 +17,20 @@ extern lua_State *L; +static int spell_x(int sval, int pval, int i) +{ + if (sval == 255) + { + return pval; + } + else + { + char buf[128]; + sprintf(buf, "school_book[%d][%d]", sval, i+1); + return get_lua_int(buf); + } +} + /* Maximum number of tries for teleporting */ #define MAX_TRIES 300 @@ -2327,14 +2341,14 @@ s32b get_school_spell(cptr do_what, cptr check_fct, s16b force_book) /* Display a list of spells */ call_lua("print_book", "(d,d,O)", "d", sval, pval, o_ptr, &where); - exec_lua(format("print_spell_desc(spell_x(%d, %d, %d), %d)", sval, pval, i, where)); + print_spell_desc(spell_x(sval, pval, i), where); } else { s32b ok; /* Save the spell index */ - spell = exec_lua(format("return spell_x(%d, %d, %d)", sval, pval, i)); + spell = spell_x(sval, pval, i); /* Do we need to do some pre test */ call_lua(check_fct, "(d,O)", "d", spell, o_ptr, &ok); @@ -2479,7 +2493,7 @@ void browse_school_spell(int book, int pval, object_type *o_ptr) /* Display a list of spells */ call_lua("print_book", "(d,d,O)", "d", book, pval, o_ptr, &where); - exec_lua(format("print_spell_desc(spell_x(%d, %d, %d), %d)", book, pval, i, where)); + print_spell_desc(spell_x(book, pval, i), where); } |