function arrangeItems()
player = getObject("Game.GameCurrentCharacter")
items = player:getLinks(VCharacterItems)
table.insert(items, (table.remove(items, 0)))
player.setValue(VCharacterItems, items)
end
bad argument #1 to 'setValue' (Visionaire.TVisionaireObject expected, got number)
function arrangeItems()
player = getObject("Game.GameCurrentCharacter")
items = player:getLinks(VCharacterItems)
table.insert(items, (table.remove(items, 1)))
player:setValue(VCharacterItems, items)
end
local player, items
tblItems = {}
function arrangeItems()
player = game:getLink(VGameCurrentCharacter)
items = player:getLinks(VCharacterItems)
for i = 1, table.maxn(items) do table.insert(tblItems, items[i]:getName()) end
player:setValue(VCharacterItems, tblItems)
end
-- here's a bit of code I tested in LuaEdit. (see attachment)
tbl = {"item1", "item4", "item3", "item2"}
print("-- * before * --")
for i = 1, table.maxn(tbl) do
print(tbl[i])
end
local sort_func = function( a,b ) return a < b end
table.sort( tbl, sort_func )
print("-- * after * --")
for i = 1, table.maxn(tbl) do
print(tbl[i])
end
local player, items -- blank variables
tblItems = {} -- empty table
local sort_func = function( a,b ) return a < b end -- function that sorts alphabetically
function arrangeItems()
player = game:getLink(VGameCurrentCharacter) -- store current character
items = player:getLinks(VCharacterItems) -- store items
-- * add each item into a table; one at a time * --
for i = table.maxn(items) do table.insert(tblItems, items[i]:getName()) end
-- * sort the items alphabetically * --
table.sort( tblItems, sort_func )
-- * amend the new item list to the current character * --
player:setValue(VCharacterItems, tblItems)
end
function shiftFirstItemDown()
for i = 1, table.maxn(items)
do table.insert(tblItems, items[i]:getName())
end
player.setValue(VCharacterItems, tblItems)
end
bad argument #1 to 'setValue' (Visionaire.TVisionaireObject expected, got number)
function arrangeItems()
player = getObject("Game.GameCurrentCharacter")
items = player:getLinks(VCharacterItems)
player.setValue(VCharacterItems, items)
end
Strangely, it still returns "got number", when I was expecting we were feeding in a string?bad argument #1 to 'setValue' (Visionaire.TVisionaireObject expected, got number)
player.setValue
player:setValue
function shiftFirstItemDown()
table.insert(items, (table.remove(items, 1)))
player:setValue(VCharacterItems, items)
end
--[[
Organize Items Alphabetically (v1) [10/02/2014]
By AFRLme
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
--]]
local char, items -- empty variables
local sort_func = function( a,b ) return a:getName() < b:getName() end -- sort function (ascending A-Z, 1-10 etc)
function arrangeItems()
char = game:getLink(VGameCurrentCharacter) -- store current character
items = char:getLinks(VCharacterItems) -- store items
table.sort(items, sort_func) -- sort the items alphabetically
char:setValue(VCharacterItems, items) -- amend new item order to the inventory
end
--[[
Cycle inventory items by ascending or descending order (v1) [11/02/2014]
Written by AFRLme
-- + --
alternatingfrequencies@hotmail.com | 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
cycleItems(true)
cycleItems(false)
wow great script, im going to have to use that one!
crazy how one little typo can crash your whole game!