This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials
--[[
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
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 freescrollItems(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
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.