Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Tue 25/09/2012 13:24:38

Title: SOLVED: Change inventory item mouse cursor graphic
Post by: Slasher on Tue 25/09/2012 13:24:38
I have a situation whereby an inventory item graphic changes if another inventory item is used on it.

This happens twice for the same inventory item.

What I am trying to achieve is to change the images graphic on cursor when selected.

At the moment they all share the same graphic as stipulated in the inventory item panel.

How can I change it to show current item after its inventory graphic has changed.

Would it be better to have individual inventory items rather than change its graphics?

Using inventory on the inventory item istaff:
Code (AGS) Select
function istaff_UseInv(
{
if (cELF.ActiveInventory==ithread)
{
istaff.Graphic=615;
cELF.LoseInventory(ithread);
}
else if (cELF.ActiveInventory==ineedle && istaff.Graphic==615)
{
istaff.Graphic=616;
cELF.LoseInventory(ineedle);
Display("You now have a makeshift fishing rod.");
}
else if (cELF.ActiveInventory==ineedle && istaff.Graphic==593)
{
Display("You need to have line on the broom before you add a bent needle so you can have a makeshift fishing rod.");
}
}


When correct inventory image is used on a painting:  // CURSOR SHOULD BE NEW INVENTORY GRAPHIC

Code (AGS) Select
function opainting_UseInv()
{
  cELF.Walk(139, 260, eBlock, eWalkableAreas);
  cELF.Loop=1;
 
  if (cELF.ActiveInventory==istaff && istaff.Graphic==616)
  {
  cELF.StopMoving();
  cELF.SetWalkSpeed(1, 1);
  orod.Visible=true;
  cELF.Move(cELF.x -0, cELF.y +70, eNoBlock, eAnywhere);
  orod.Move(orod.X -0, orod.Y +70, 1, eNoBlock, eAnywhere);
  opainting.Move(opainting.X -0, opainting.Y +70, 1,   eBlock, eAnywhere);
  orod.Visible=false;
  painting=true;
  cELF.Say("What's this?");
  cELF.StopMoving();
  cELF.SetWalkSpeed(5, 5);
  }
  else
  {
  cELF.Say("I don't think that will help move that painting!!");
  }
  }





Title: Re: Change inventory item mouse cursor graphic
Post by: Andail on Tue 25/09/2012 13:36:04
Just create a new inventory item instead. Then use the custom cursor graphic option to change the cursor sprite.

Thus:
Code (ags) Select

function istaff_UseInv()
{
if (cELF.ActiveInventory==ithread) {
    cELF.LoseInventory(ithread);
    cELF.LoseInventory(istaff);
    cELF.AddInventory (ifishingrod);
    }
}
Title: Re: Change inventory item mouse cursor graphic
Post by: Slasher on Tue 25/09/2012 13:48:23
Yeah, have decided separate inventory items were probably the bet way.

But there must be a way to change inventory graphic if the inventory item graphic changes?

cheers
Title: Re: Change inventory item mouse cursor graphic
Post by: Khris on Tue 25/09/2012 14:13:01
Is it really that hard to find in the manual?

Scripting -> Inventory item functions and properties -> CursorGraphic (http://www.adventuregamestudio.co.uk/manual/InventoryItem.CursorGraphic.htm)

It could hardly get more straightforward than this.
Title: Re: Change inventory item mouse cursor graphic
Post by: Slasher on Tue 25/09/2012 14:36:34
Thanks Khris