Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Flyman on Sat 04/02/2012 20:40:31

Title: Inventory item animated!?
Post by: Flyman on Sat 04/02/2012 20:40:31
mmmm, I ask's me if with AGS is possible animated a Inventory item.
Command like this:
iInventory[17].SetView(51, 0);
iInventory[17].Visible = true;
iInventory[17].Animate(0, 1, eRepeat, eNoBlock);
Title: Re: Inventory item animated!?
Post by: Khris on Sun 05/02/2012 05:46:31
mmmmmmmm, First of all, it's EITHER inventory[17] OR iInventory.

The inventory[] array is a built in list of all InventoryItems. But, since InventoryItems are global, you use the actual name in any script.

mmmm, As for animating them, you have to change the graphic manually in repeatedly_execute_always, here's a code example from MMM 61:

// Animate acid
 if (player.InventoryQuantity[iMiSo.ID]==1 && IsTimerExpired(11)) {
   int a=iMiSo.Graphic;
   a++;
   if (a==392) a=389;
   iMiSo.Graphic=a;
   SetTimer(11, 10);
 }


mmmmmmmmmmm, Pretty simple actually. The graphic slot is incremented every ten frames, and set back to the first after it has reached the last frame.
Title: Re: Inventory item animated!?
Post by: Ryan Timothy B on Wed 08/02/2012 04:24:08
mmmmm Here's a much nicer solution, a module that uses extender functions for the inventory items. Eg: inventory[17].Animate(0, 1, eRepeat, eForward);

The only thing I didn't do was blocking animations, a flipped frame in the view, or frame sounds. I was too lazy. But this works for blocking animations:

iPizza.Animate(0, 1);
while (iPizza.Animating()) Wait();

I just don't recommend doing that if eRepeat is set, unless you have the inventory stop animating at another point.

Here are the extender methods:
Inventory.SetView(int view, OPTIONAL int loop, OPTIONAL int frame);
Inventory.Animate(int loop, int delay, OPTIONAL RepeatStyle, OPTIONAL Direction);
Inventory.Animating();
Inventory.StopAnimating();


http://www.bryvis.com/entertainment/other/agsf/InventoryAnimate.scm
(right click and save as)

Let me know if it has any issues, I didn't test it to the extreme, but it seemed to work just fine.
Title: Re: Inventory item animated!?
Post by: Flyman on Thu 09/02/2012 22:57:59
Is possible implemented the animated function for inventory item in AGS?  ::)
Title: Re: Inventory item animated!?
Post by: Ryan Timothy B on Fri 10/02/2012 01:57:31
mmmm apparently you have troubles reading. But I suppose I never did walk you through what that file was. You simply import it into AGS by right clicking on scripts and then import module script.
Title: Re: Inventory item animated!?
Post by: bx83 on Mon 19/06/2017 04:31:45
Ryan Timoothy, do you still have this script file? Link leads to a domian squatter, download is gone.
Could you run me through what the script does maybe?