diff -c src/act_info.c ../smaugfuss.lua/src/act_info.c *** src/act_info.c 2006-09-08 13:17:41.000000000 +1000 --- ../smaugfuss.lua/src/act_info.c 2007-07-02 15:35:03.000000000 +1000 *************** *** 1023,1028 **** --- 1023,1029 ---- show_list_to_char( ch->in_room->first_content, ch, FALSE, FALSE ); show_char_to_char( ch->in_room->first_person, ch ); + call_lua (ch, "looking", NULL); return; } diff -c src/comm.c ../smaugfuss.lua/src/comm.c *** src/comm.c 2007-01-07 04:32:15.000000000 +1100 --- ../smaugfuss.lua/src/comm.c 2007-07-02 16:02:27.000000000 +1000 *************** *** 2054,2059 **** --- 2054,2061 ---- ch->position = POS_STANDING; log_printf_plus( LOG_COMM, UMAX( sysdata.log_level, ch->level ), "%s (%s) has connected.", ch->name, d->host ); + open_lua (ch); /* fire up Lua state */ + call_lua (ch, "reconnected", ch->name); show_title( d ); break; *************** *** 2320,2325 **** --- 2322,2329 ---- log_string_plus( log_buf, LOG_COMM, sysdata.log_level ); to_channel( log_buf, CHANNEL_MONITOR, "Monitor", LEVEL_IMMORTAL ); write_to_buffer( d, "Press [ENTER] ", 0 ); + open_lua (ch); /* fire up Lua state */ + call_lua (ch, "new_player", ch->name); show_title( d ); ch->level = 0; ch->position = POS_STANDING; *************** *** 2536,2541 **** --- 2540,2547 ---- else if( !ch->was_in_room ) ch->was_in_room = ch->in_room; + call_lua (ch, "entered_game", ch->name); + break; } diff -c src/db.c ../smaugfuss.lua/src/db.c *** src/db.c 2007-01-28 18:26:11.000000000 +1100 --- ../smaugfuss.lua/src/db.c 2007-07-01 08:27:44.000000000 +1000 *************** *** 3000,3005 **** --- 3000,3007 ---- return; } + close_lua (ch); /* close down Lua state */ + if( ch->desc ) bug( "%s: char still has descriptor.", __FUNCTION__ ); diff -c src/handler.c ../smaugfuss.lua/src/handler.c *** src/handler.c 2006-12-31 14:33:51.000000000 +1100 --- ../smaugfuss.lua/src/handler.c 2007-07-02 17:04:31.000000000 +1000 *************** *** 1221,1226 **** --- 1221,1228 ---- add_timer( ch, TIMER_SHOVEDRAG, 10, NULL, 0 ); /*-30 Seconds-*/ + call_lua_num (ch, "entered_room", pRoomIndex->vnum); + /* * Delayed Teleport rooms -Thoric * Should be the last thing checked in this function *************** *** 1360,1365 **** --- 1362,1370 ---- } else if( !xIS_SET( extra_flags, ITEM_MAGIC ) ) ch->carry_weight += oweight; + + call_lua_num (ch, "got_object", obj->pIndexData->vnum); + return ( oret ? oret : obj ); } *************** *** 4452,4457 **** --- 4457,4465 ---- return; } vnum = mob->pIndexData->vnum; + + call_lua_num (ch, "killed_mob", vnum); + track = URANGE( 2, ( ( ch->level + 3 ) * MAX_KILLTRACK ) / LEVEL_AVATAR, MAX_KILLTRACK ); for( x = 0; x < track; x++ ) if( ch->pcdata->killed[x].vnum == vnum ) diff -c src/Makefile ../smaugfuss.lua/src/Makefile *** src/Makefile 2006-12-30 15:50:59.000000000 +1100 --- ../smaugfuss.lua/src/Makefile 2007-07-01 12:44:25.000000000 +1000 *************** *** 21,27 **** W_FLAGS = -Wall -Werror -Wshadow -Wformat-security -Wpointer-arith -Wcast-align -Wredundant-decls -Wstrict-prototypes C_FLAGS = -g2 $(W_FLAGS) $(SOLARIS_FLAG) $(PROF) $(EXPORT_SYMBOLS) ! L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) #D_FLAGS : For the DNS Slave process. No need in linking all the extra libs for this. D_FLAGS = -g2 -O $(PROF) $(SOLARIS_LINK) --- 21,27 ---- W_FLAGS = -Wall -Werror -Wshadow -Wformat-security -Wpointer-arith -Wcast-align -Wredundant-decls -Wstrict-prototypes C_FLAGS = -g2 $(W_FLAGS) $(SOLARIS_FLAG) $(PROF) $(EXPORT_SYMBOLS) ! L_FLAGS = $(PROF) $(SOLARIS_LINK) -lz $(NEED_DL) -llua -lm #D_FLAGS : For the DNS Slave process. No need in linking all the extra libs for this. D_FLAGS = -g2 -O $(PROF) $(SOLARIS_LINK) *************** *** 30,36 **** handler.c hashstr.c hotboot.c imm_host.c interp.c magic.c makeobjs.c mapout.c mccp.c \ misc.c mpxset.c mud_comm.c mud_prog.c planes.c player.c polymorph.c \ reset.c save.c services.c sha256.c shops.c skills.c special.c tables.c \ ! track.c update.c ifdef IMC C_FILES := imc.c $(C_FILES) --- 30,37 ---- handler.c hashstr.c hotboot.c imm_host.c interp.c magic.c makeobjs.c mapout.c mccp.c \ misc.c mpxset.c mud_comm.c mud_prog.c planes.c player.c polymorph.c \ reset.c save.c services.c sha256.c shops.c skills.c special.c tables.c \ ! track.c update.c \ ! lua_scripting.c lua_bits.c ifdef IMC C_FILES := imc.c $(C_FILES) diff -c src/mud.h ../smaugfuss.lua/src/mud.h *** src/mud.h 2007-01-28 18:26:10.000000000 +1100 --- ../smaugfuss.lua/src/mud.h 2007-07-02 15:33:40.000000000 +1000 *************** *** 25,30 **** --- 25,40 ---- #include #endif + /* + + Lua includes :) + + NJG + + */ + + #include + #ifdef WIN32 #include #include *************** *** 2224,2229 **** --- 2234,2240 ---- short mobinvis; /* Mobinvis level SB */ short colors[MAX_COLORS]; int home_vnum; /* hotboot tracker */ + lua_State *L; /* for Lua scripting - NJG */ }; struct killed_data *************** *** 4110,4115 **** --- 4122,4129 ---- * in this directory is the name of the immortal who requested the watch */ + #define LUA_DIR "../lua/" /* Where Lua source files are kept */ + #define AREA_LIST "area.lst" /* List of areas */ #define WATCH_LIST "watch.lst" /* List of watches */ #define BAN_LIST "ban.lst" /* List of bans */ *************** *** 4147,4152 **** --- 4161,4167 ---- #define COMMAND_FILE SYSTEM_DIR "commands.dat" /* Commands */ #define PROJECTS_FILE SYSTEM_DIR "projects.txt" /* For projects */ #define PLANE_FILE SYSTEM_DIR "planes.dat" /* For planes */ + #define LUA_STARTUP LUA_DIR "startup.lua" /* script initialization */ /* * Our function prototypes. *************** *** 4844,4846 **** --- 4859,4871 ---- #define GET_ADEPT(ch,sn) ( skill_table[(sn)]->skill_adept[(ch)->Class]) #define LEARNED(ch,sn) (IS_NPC(ch) ? 80 : URANGE(0, ch->pcdata->learned[sn], 101)) + + /* + * Lua stuff (Nick Gammon) + */ + + void open_lua (CHAR_DATA * ch); + void close_lua (CHAR_DATA * ch); + void call_lua (CHAR_DATA * ch, const char * fname, const char * argument); + void call_lua_num (CHAR_DATA * ch, const char * fname, const int argument); + diff -c src/save.c ../smaugfuss.lua/src/save.c *** src/save.c 2007-01-28 18:26:10.000000000 +1100 --- ../smaugfuss.lua/src/save.c 2007-07-02 16:57:27.000000000 +1000 *************** *** 197,202 **** --- 197,204 ---- saving_char = ch; + call_lua (ch, "saving", NULL); + if( ch->desc && ch->desc->original ) ch = ch->desc->original; *************** *** 765,771 **** ch->pcdata->lt_index = 0; /* last tell index */ ch->morph = NULL; ch->pcdata->hotboot = FALSE; /* Never changed except when PC is saved during hotboot save */ ! #ifdef IMC imc_initchar( ch ); #endif --- 767,774 ---- ch->pcdata->lt_index = 0; /* last tell index */ ch->morph = NULL; ch->pcdata->hotboot = FALSE; /* Never changed except when PC is saved during hotboot save */ ! ch->L = NULL; /* no Lua state yet */ ! #ifdef IMC imc_initchar( ch ); #endif diff -c src/update.c ../smaugfuss.lua/src/update.c *** src/update.c 2006-12-03 16:49:36.000000000 +1100 --- ../smaugfuss.lua/src/update.c 2007-07-01 11:13:42.000000000 +1000 *************** *** 880,885 **** --- 880,887 ---- return; } + call_lua (ch, "char_update", NULL); + /* * Do a room_prog rand check right off the bat * if ch disappears (rprog might wax npc's), continue