This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials
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
The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.Until 1 Dec 2026 all licenses are 30 % off, for example the Indie Bundle for €69.30 instead of €99. The code BLACKFRIDAY is applied automatically at checkout.
See licenses Try it for freelocal 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.setValueplayer:setValuefunction 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!
This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.
New threadDeponia, The Whispered World and more than 160 other games were made with Visionaire Studio. The free version covers up to 25 scenes. For more scenes there is Visionaire Studio PRO from €75, and to sell your game the Indie Bundle for €99.
Through December 1: all licenses 30% off, for example the Indie Bundle for €69.30 instead of €99. Applied automatically at checkout.