100 lines
2.3 KiB
C
100 lines
2.3 KiB
C
![]() |
#include <string.h>
|
|||
|
#include "common.h"
|
|||
|
#include "char_talk.h"
|
|||
|
#include "mylua/base.h"
|
|||
|
#include "lua.h"
|
|||
|
#include "lauxlib.h"
|
|||
|
#include "lualib.h"
|
|||
|
#include "mylua/ablua.h"
|
|||
|
#include "magic_base.h"
|
|||
|
#include "lssproto_serv.h"
|
|||
|
#ifdef _ALLBLUES_LUA_1_2
|
|||
|
#include "mylua/mylua.h"
|
|||
|
extern MY_Lua MYLua;
|
|||
|
|
|||
|
static CharBase MagicBaseInt[] = {
|
|||
|
{{"ID"}, MAGIC_ID}
|
|||
|
,{{"<EFBFBD>ֶ<EFBFBD>"}, MAGIC_FIELD}
|
|||
|
,{{"Ŀ<EFBFBD><EFBFBD>"}, MAGIC_TARGET}
|
|||
|
,{{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>"}, MAGIC_TARGET_DEADFLG}
|
|||
|
#ifdef _ATTACK_MAGIC
|
|||
|
,{{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"}, MAGIC_IDX}
|
|||
|
#endif
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
static CharBase MagicBaseChar[] = {
|
|||
|
{{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"}, MAGIC_NAME}
|
|||
|
,{{"ע<EFBFBD><EFBFBD>"}, MAGIC_COMMENT}
|
|||
|
,{{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"}, MAGIC_FUNCNAME}
|
|||
|
,{{"ѡ<EFBFBD><EFBFBD>"}, MAGIC_OPTION}
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
static int addLUAListFunction(lua_State *L)
|
|||
|
{
|
|||
|
size_t l;
|
|||
|
char *luafuncname = luaL_checklstring(L, 1, &l);
|
|||
|
char *luafunctable = luaL_checklstring(L, 2, &l);
|
|||
|
char *luafunctablepath = luaL_checklstring(L, 3, &l);
|
|||
|
const int gmlevel = luaL_checkint(L, 4);
|
|||
|
char *usestring = luaL_checklstring(L, 5, &l);
|
|||
|
|
|||
|
|
|||
|
if(strlen(luafunctablepath) > 0){
|
|||
|
MY_Lua *mylua = &MYLua;
|
|||
|
while(mylua->next != NULL){
|
|||
|
if(strcmp(mylua->luapath, luafunctablepath) == 0){
|
|||
|
return MAGIC_addLUAListFunction( mylua->lua, luafuncname, luafunctable, gmlevel, usestring );
|
|||
|
}
|
|||
|
mylua = mylua->next;
|
|||
|
}
|
|||
|
}else{
|
|||
|
return MAGIC_addLUAListFunction( L, luafuncname, luafunctable, gmlevel, usestring );
|
|||
|
}
|
|||
|
return 1;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
static int getChar(lua_State *L)
|
|||
|
{
|
|||
|
const int magicid = luaL_checkint(L, 1);
|
|||
|
const int element = getCharBaseValue(L, 2, MagicBaseChar, arraysizeof(MagicBaseChar));
|
|||
|
int marray = MAGIC_getMagicArray( magicid);
|
|||
|
if( marray != -1 ){
|
|||
|
lua_pushstring(L, MAGIC_getChar( marray, element));
|
|||
|
}else{
|
|||
|
lua_pushstring(L, "");
|
|||
|
}
|
|||
|
return 1;
|
|||
|
}
|
|||
|
|
|||
|
static int getInt(lua_State *L)
|
|||
|
{
|
|||
|
const int magicid = luaL_checkint(L, 1);
|
|||
|
const int element = getCharBaseValue(L, 2, MagicBaseInt, arraysizeof(MagicBaseInt));
|
|||
|
int marray = MAGIC_getMagicArray( magicid);
|
|||
|
if( marray != -1 ){
|
|||
|
lua_pushinteger(L, MAGIC_getInt( marray, element));
|
|||
|
}else{
|
|||
|
lua_pushinteger(L, -1);
|
|||
|
}
|
|||
|
return 1;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
static const luaL_Reg magiclib[] = {
|
|||
|
{"addLUAListFunction", addLUAListFunction},
|
|||
|
{"getInt", getInt},
|
|||
|
{"getChar", getChar},
|
|||
|
{NULL, NULL}
|
|||
|
};
|
|||
|
|
|||
|
LUALIB_API int luaopen_Magic (lua_State *L) {
|
|||
|
luaL_register(L, "magic", magiclib);
|
|||
|
return 1;
|
|||
|
}
|
|||
|
|
|||
|
#endif
|
|||
|
|