the '2' represents the sprite number you want to drag. This sprite number is referenced by the variable 'detector' in the drag_sprite function.
Don't know if this will help you or not, but this is an inventory system I made awhile back for other folks. However, it is DBP code but you might dig through it and find something useful.
set display mode 800,600,32
RANDOMIZE TIMER()
REM IMAGES
load image "grid.bmp", 1
load image "i_potion.bmp", 2
load image "i_scroll.bmp", 3
load image "i_dagger.bmp", 4
REM inventory grid sizes
grid_x = 10
grid_y = 4
REM size of item icons
icon_size = 16
REM 1 - potion
REM 2 - scroll
REM 3 - dagger
type item_type
description as string
image as integer
stackable as integer
endtype
type item
id as integer
sprt as integer
static as integer
gx as integer
gy as integer
endtype
REM This sets up the data for all different types of items
dim item_types(3) as item_type
for t = 1 to 3
read a$
item_types(t).description = a$
read a
item_types(t).image = a
read a
item_types(t).stackable = a
next t
REM Create inventory grid(area where items are kept)
dim grid_items(grid_x, grid_y)
REM keeps track of how many items are in 1 grid spot(can only be more
REM than 1 if item at the spot is stackable)
dim grid_count(grid_x, grid_y)
item_total = 10
REM items in the grid
dim items(item_total) as item
REM inventory grid location(top left-hand corner)
inv_x = 100
inv_y = 100
for t = 1 to item_total
id = rnd(2)+1
items(t).id = id
items(t).sprt = 100 + t
items(t).static = 1
items(t).gx = t
items(t).gy = 3
grid_items(items(t).gx, items(t).gy) = id
grid_count(items(t).gx, items(t).gy) = grid_count(items(t).gx, items(t).gy) + 1
next t
DO
cls
gosub inv_mouse
rem position inventory grid
sprite 1001, inv_x, inv_y, 1
for t = 1 to item_total
REM only draw sprites which are static(not moving)
REM (sprite only moves if its been selected and being dragged with the mouse
if items(t).static = 1
offset_x = inv_x+1 + (items(t).gx-1)*icon_size
offset_y = inv_y+1 + (items(t).gy-1)*icon_size
sprite items(t).sprt, offset_x, offset_y, item_types(items(t).id).image
endif
next t
for x = 1 to 10
for y = 1 to 4
if grid_count(x,y) > 1 then text inv_x+x*16, inv_y+y*16, str$(grid_count(x,y))
next y
next x
text 90, 120, "adshfajdslh alk asdlhflakshdflkashfdkasdfasdfas d"
LOOP
REM Control the click and drag
inv_mouse:
if mouseclick() = 1 and click = 0
found = 0
click = 1
for t = 1 to item_total
if found = 0
offset_x = inv_x+1 + (items(t).gx-1)*icon_size
offset_y = inv_y+1 + (items(t).gy-1)*icon_size
if mousex()>offset_x and mousex()<offset_x+icon_size and mousey()>offset_y and mousey()<offset_y+icon_size
found = t
items(t).static = 0
mouse_offset_x = mousex() - offset_x
mouse_offset_y = mousey() - offset_y
endif
endif
next t
endif
REM Make item sprite follow mouse
if mouseclick() = 1 and click = 1 and found <> 0
sprite items(found).sprt, mousex()-mouse_offset_x, mousey()-mouse_offset_y, item_types(items(found).id).image
endif
REM When mouse button is released, assign item to new grid location
if mouseclick() = 0
click = 0
if found <> 0
items(found).static = 1
temp_x = (mousex()-inv_x)/icon_size + 1
temp_y = (mousey()-inv_y)/icon_size + 1
if temp_x < 1 OR temp_x > grid_x OR temp_y < 1 OR temp_y > grid_y
REM item is positioned outside of inventory grid, so do nothing and keep old position
else
REM if grid spot is occupied
if grid_count(temp_x, temp_y) > 0
REM if item in occupied slot matches selected item, and its a stackable item
if grid_items(temp_x, temp_y) = items(found).id AND item_types(grid_items(temp_x, temp_y)).stackable = 1
REM item is within inventory grid, assign the new position
grid_count(items(found).gx, items(found).gy) = grid_count(items(found).gx, items(found).gy) - 1
grid_items(items(found).gx, items(found).gy) = 0
items(found).gx = temp_x
items(found).gy = temp_y
grid_count(temp_x, temp_y) = grid_count(temp_x, temp_y) + 1
grid_items(temp_x, temp_y) = items(found).id
endif
else
REM item is within inventory grid, assign the new position
grid_count(items(found).gx, items(found).gy) = grid_count(items(found).gx, items(found).gy) - 1
grid_items(items(found).gx, items(found).gy) = 0
items(found).gx = temp_x
items(found).gy = temp_y
grid_count(temp_x, temp_y) = grid_count(temp_x, temp_y) + 1
grid_items(temp_x, temp_y) = items(found).id
endif
endif
found = 0
endif
endif
RETURN
REM Available item types
REM name, icon image number, 1 for stackable item(0 if not)
data "potion", 2,1
data "scroll", 3,1
data "dagger", 4,0