Hi, I'm trying to see if I can change the positions of individual items in the inventory so I can animate their sliding up/down in turn, instead of moving the entire inventory as a whole. As far as I can see, the only way to change an image position through scripting is by changing the position of an active animation, as x/y co-ords of other things like sprites are not scriptable according to
Data_Structure_3.x. The closest I got to achieving this was to move the animation of an inventory item, and in theory this should work to control the positions of all items, but somehow no matter which item or how many items I specify it moves only 1 item (same one each time).
This is the problematic code:
function prepOpenInv()
local kitems = getObject("Game.GameCurrentCharacter"):getLinks(VCharacterItems)
local VileItem, VileItem2
for i=1,table.maxn(kitems) do
VileItem = kitems[i]:getLink(VObjectAnimation)
print(kitems[i]:getName())
print(VileItem:getName())
VileItem2 = getObject("ActiveAnimations[" .. VileItem:getName() .. "]")
VileItem2:setValue(VAnimationCurrentPosition, {x=0,y=100})
end
end
For each item, I print its name and the name of the animation. As the message log shows below (from the 2 print() lines above), it does manage to iterate through the items alright, but somehow the animations connected to the items are all identical. And yet each animation plays properly.
21:49:57: 1_Weapon
21:49:57: Unbenannt
21:49:57: 2_sharp_rock
21:49:57: Unbenannt
21:49:57: 3_Scanner
21:49:57: Unbenannt
I've included a project file that should work with the demo game so you can see what I mean. Just click anywhere (except the item squares and arrows) on the top inventory and you should see only one image disappear. If the code worked as intended, it would make all the images disappear. Instead, only the second one disappears.
Does anyone know why this happens, or can you suggest a better way to achieve this? Thanks!
P.S. Is it possible to handle inventory scrolling through scripting, so players can scroll through the inventory by hovering on a button instead of clicking? I was thinking of using CharacterItemsScrollPosition for this, but again it seems unscriptable according to
Data_Structure_3.x.