Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Cycle inventory items by ascending or descending order (v1) [11/02/2014]
- Written by AFRLme
- -- + --
- [email protected] | skype @ AFRLme
- --]]
- -- * local variables * --
- local char, items, item, amt -- empty variables
- -- * function for cycling through the inventory items * --
- function cycleItems(asc)
- char = game:getLink(VGameCurrentCharacter) -- store current character
- items = char:getLinks(VCharacterItems) -- store inventory items into a table
- amt = table.maxn(items) -- get index number of last item
- -- if asc is true (ascending) then item = last item, remove last item from table & insert into slot 1 else (descending) item = first item, remove first item & insert into last slot
- if asc then item = items[amt]; table.remove(items, amt); table.insert(items, 1, item) else item = items[1]; table.remove(items, 1); table.insert(items, (table.maxn(items)+1), item) end
- char:setValue(VCharacterItems, items) -- update the inventory
- end
Advertisement
Add Comment
Please, Sign In to add comment