--[[
Cycle inventory items by ascending or descending order [v2] (12/02/2014)
Written by AFRLme [Lee Clarke]
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
-- * local variables * --
local char, items, item, amt -- empty variables
local slots = 0 -- define inventory slot amount here
local cycle = false -- false = only cycle inventory when item amount equals same as or more than inventory slots. true = always cycle
-- * function for changing cycle mode * --
function toggleCycleMode()
if cycle then cycle = false else cycle = true end
end
-- * 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 cycle or amt >= slots then
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
end
scrollItems(false); scrollItems(false); scrollItems(false); scrollItems(false)
if asc then
item = items[amt]; table.remove(items, amt); table.insert(items, 1, item)
item = items[amt]; table.remove(items, amt); table.insert(items, 1, item)
item = items[amt]; table.remove(items, amt); table.insert(items, 1, item)
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)
item = items[1]; table.remove(items, 1); table.insert(items, (table.maxn(items)+1), item)
item = items[1]; table.remove(items, 1); table.insert(items, (table.maxn(items)+1), item)
item = items[1]; table.remove(items, 1); table.insert(items, (table.maxn(items)+1), item)
end
if asc then
for a = 1, 4 do
item = items[amt]; table.remove(items, amt); table.insert(items, 1, item)
end
else
for b = 1, 4 do
item = items[1]; table.remove(items, 1); table.insert(items, (table.maxn(items)+1), item)
end
end
15:16:24: Warning: Tried to access invalid field. Field CharacterItemsScrollPosition (id: 518) does not exist in table Character (id: 148).
15:16:24: Warning: TDataGroup::GetValue: Cannot find field in object: CharacterItemsScrollPosition
15:16:24: value for TLink is NULL
15:16:24: ---Empty---
print(Characters["Tom"].ItemsScrollPosition)
Error: Unknown data-field "ItemsScrollPosition".
15:47:42: nil