| Message |
It turned out to be a bit more complicated than I thought because I hadn't allowed for purging from someone else's inventory. Here is what I had in mind for the subtask:
{ -- subtask 1
description = "Bread obtained",
type = "give",
item = 21021,
count = 1,
vnums = { 10399 },
complete = function ()
mud.destroy_item (10399, 10300, 21021) -- get rid of the bread
end -- complete function
}, -- end subtask
Note that on completion (ie. I gave mob 10399 in room 10300 item 21021) I immediately destroy that item.
However to make that work I had to amend the function destroy_item like this:
/* remove an item from the character's top-level inventory */
static int L_destroy_item (lua_State *L)
{
CHAR_DATA * ch = L_find_character (L); /* get character pointer */
int iItem = 2;
if (!ch)
luaL_error (L, "Cannot find character/mob to destroy an item for.");
/* if character was (vnum, boolean) then item is 3rd argument */
if ((lua_type (L, 1) == LUA_TNUMBER || lua_type (L, 1) == LUA_TLIGHTUSERDATA)
&& (lua_type (L, 2) == LUA_TBOOLEAN || lua_type (L, 2) == LUA_TNUMBER))
iItem++;
OBJ_DATA * obj;
int vnum = luaL_checkint (L, iItem);
if ( vnum < 1 || vnum > MAX_VNUM )
luaL_error (L, "Vnum %d is out of range 1 to %d", vnum, MAX_VNUM);
int count = luaL_optint (L, iItem + 1, 1);
// rest is the same
This lets you specify the mob/room as well as the item number. You should probably make a different function, I think it will get confusing with all those vnums there (like, mob_destroy_item or something).
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|