Arrays arrays array.. in order to use LUA your going to have to understand arrays. The good news is everyone already knows what an array is they just dont know it.
Imagine a shopping list of things to buy such as
milk
eggs
bacon
Believe it or not but thats a bloody array. Its an array with 3 items (or Elements). Lets call our list/array ShoppingList... now whats the 2nd element/item eggs .. or shoppinglist[2]
What that carnt be an array .. thats 2 dam easy. Lets turn that into lua first we create our shopping list emtpy then add elements, then lets print the second item
shoppinglist = {}
shoppinglist[1] = 'milk'
shoppinglist[2] = 'eggs'
shoppinglist[3] = 'bacon'
print('2nd item: '..shoppinglist[2])
This can also written in lua be done in a simplular way... Note the {} start and end of an array definition
shoppinglist = { 'Milk' , 'eggs', 'bacon'}
print('2nd item: '..shoppinglist[2])
_____________________________________________________________________
Now lets all be clever clogs... the word Bacon is an array
!!!!! You what you say... well it is .. tell me the 3rd letter of the word bacon.... 3rd umm letter or did you mean element... well its c either way. In lua to get an element of a string (array of characters) you have to use a speacil command.
print('3rd element of bacon: '..string.sub(shoppinglist[3], 3,3))
_____________________________________________________________________
Ok interesting... but what is a Table.. a table is an array of arrays... ow jimmy now where going crazy.. but wait you already know what an array of arrays is... its your dam schedule...
Monday
mow lawn
take out garbage
tue
pay the bills ow lord
start on fixing the roof
wed
drink beer
In Lua
MySchedule = {} -- make an empty table/array
MySchedule[1] = { 'Monday' , 'mow lawn', 'take out garbage' }
MySchedule[2] = { 'tue' ,'pay the bills ow lord',' start on fixing the roof' }
MySchedule[3] = { 'wed','drink beer' }
You could also represent this as
MySchedule = { { 'Monday' , 'mow lawn', 'take out garbage' } , { 'tue' ,'pay the bills ow lord',' start on fixing the roof' } , { 'wed','drink beer' } }
Now tell me the second thing to do on tue and the 1st thing to do on the third day
print('Whats the 2nd item to do on TUe: '..MySchedule[2][3]) -- note 2nd thing is 3rd element in array
print('Whats the 1st item to do on the third day: '..MySchedule[3][2])
_____________________________________________________________________
Now thats arrays/list and tables (arrays or arrays/lists of lists) Simplified maybe but the gist of it..
Now to apply to some serious code....
scanitems(visible) makes a array of Variables of all items found
each element of the array .. contains an list of varialbes that apply to that item found (id id,name, position)
to get each element of the talbe we use UO.getitem(INDEX/element number) and it returns all the values...
itemsfoundcount = UO.ScanItems(true) -- visible
local nID,nType,nKind,nContID,nX,nY,nZ,nStack,nRep,nCol = UO.GetItem(5)
print('The fifth item found ID is: ..nID)
_____________________________________________________________________
Please leave a comment to let me know if this was usfull or rocket science.