So, I am trying to remove (delete) the floating inventory icon that I click outside the inventory bag. I created a callback function called item_was_dropped() . Here are both of my callback functions so far:
function slot_was_clicked ( int occurrence, int bag_id, int slot_id, int placed_item_id, int removed_item_id )
{
if ( ( occurrence == INV_ITEM_REMOVED ) || ( occurrence == INV_ITEM_SWAPPED ) )
{
if (bag_id == MAIN_BAG_ID)
{
if (slot_id == ACTIV_WPN_SLOT_ID)
{
ent_remove ( active_weapon );
}
}
}
if ( ( occurrence == INV_ITEM_PLACED ) || ( occurrence == INV_ITEM_SWAPPED ) )
{
if (bag_id == MAIN_BAG_ID)
{
if (slot_id == ACTIV_WPN_SLOT_ID)
{
switch ( placed_item_id )
{
case SWORD: active_weapon_mdl = "sword.mdl"; active_weapon = ent_create ( active_weapon_mdl, player.x, attach_weapon ); break;
case MACE: active_weapon_mdl = "mace.mdl"; active_weapon = ent_create ( active_weapon_mdl, player.x, attach_weapon ); break;
}
}
}
}
}
function item_was_dropped()
{
Item* floatingItem;
if ( !mouse_panel )
{
if ( inv_is_floating() )
{
if ( mouse_left )
{
bmap_remove(floatingItem.floating_icon);
}
}
}
}
In my main function, I make some calls to these callback functions:
set_on_click_callback("slot_was_clicked");
set_on_float_end_callback("item_was_dropped");
My "slot_was_clicked" function is used for arming the player with a weapon, if a player places a weapon icon into the active weapon slot of the inventory bag. The "slot_was_clicked" callback function works great.
I am trying to make my "item_was_dropped" function to drop items out of my inventory bag when drag/clicking an item icon outside the inventory bag. I am not sure if I am on the right path with this. Am I using the right command ( bmap_remove ) to delete the floating inventory icon when drag/clicking it outside the inventory bag? I know that the code used above for the "item_was_dropped" callback function is not performing what I want it to do (i.e. it is not performing anything).