`Here we setup the unit type for my inventory array
type UnitType
itemName$ as string
itemGID as integer
itemPrice as integer
endtype
dim objectsARR$(0) as UnitType
`===================================================
`This is the examples, calling the functions
`add a new item to the current inventory
inventory_add("Plank of wood",9,10)
inventory_add("Bar of gold",120,1000)
inventory_show()
wait key
`===================================================
function inventory_add(a$,b,c)
`populate the item into the array from
`data sent to this function
array insert at bottom objectsARR$()
objectsARR$().itemName$ = a$
objectsARR$().itemGID = b
objectsARR$().itemPrice = c
endfunction
function inventory_show()
`find out how many items we have for our loop at bottom
totalitems = Array count (objectsARR$())
Print "You have "; totalitems ;" items in your inventory!"
Print "These are the items in your inventory:"
print "" ` spacer
Print "Local item id / item name / item global id / prices"
for i=1 to totalitems
print i ; ". " ; objectsARR$(i).itemName$; "( Global ID: "; objectsARR$(i).itemGID ;" ) = £"; objectsARR$(i).itemPrice
print "" `spacer
next i
endfunction
My nice neat function for adding and displaying inventory - im really starting to get the hang of this dbpro coding now
quite proud of it actually