Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - turtletennis

#1
I have done, but it doesn't help. I have a work-around where I add HotspotX and HotspotY as properties and duplicate the HotspotX and HotspotY entries in the inventory item and use those. That works fine.
I guess it's because I'm manually overriding the cursor image. Is there a way to automatically set the cursor to the activeInventory item if you're in UseInv mode?

My code is now

Code: ags
  InventoryItem* nextItem = FindNextItem(3, 6);
  player.ActiveInventory = nextItem;
  if(nextItem!=null)
  {
    mouse.ChangeModeGraphic(eModeUseinv, nextItem.CursorGraphic);
    Verbs.SetAction(eGA_UseInv);
    
    mouse.ChangeModeHotspot(eModeUseinv, nextItem.GetProperty("HotspotX"), nextItem.GetProperty("HotspotY"));
  }

but it would be nice to not have to duplicate the values.
#2
Great, thanks, it works. One more problem, I've noticed that when I set the cursor to be the inventory item's CursorGraphic it's using the hotspot offset of the default cursor (7,7) instead of the offset for the item. I saw there's a mouse.ChangeModeHotspot function, but the inventory item doesn't have a variable for the hotspot's location, is there a way to get this?
#3
For a one-button game jam I created a small adventure game using AGS. I am trying to get it so that when you click on the player the use item mode is switched to and the cursor changes to the next item's icon. When there's only one item in my inventory it only works once, if I attempt to repeat it the cursor resets to the default crosshair, even after clicking on the player again.
I'm using the tumbleweed project template. My code works correctly if I have multiple items in my inventory, but only once if I just have one item.
steps:
Pick up spear
click on player
cursor displays as spear
click on a hotspot
cursor resets to crosshair
click on player
expected: cursor displays as spear
actual: cursor stays as crosshair.

Code: ags

function cGreg_AnyClick()
{
  int minIndex=3;
  int maxIndex=6;
  int a=minIndex;
  bool nothingSelected = player.ActiveInventory==null;
  if(nothingSelected) player.Say("Currently nothing is selected");
  
  while(a<=maxIndex)
  {
    if(nothingSelected || player.ActiveInventory==inventory[a])
    {
      int b=a+1;
      
      if(b>maxIndex) b=minIndex;
      
      while(b!=a)
      {

        if(player.HasInventory(inventory[b]))
        {

          player.ActiveInventory=inventory[b];
          player.Say(inventory[b].Name);
          Verbs.SetAction(eGA_UseInv);
          mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.CursorGraphic);
          return;
        }
        b++;
        if(b>maxIndex) b=minIndex;
      }
      if(nothingSelected) break;
    }
    a++;
  }
  if(player.ActiveInventory==null)
  {
    player.Say("Nothing");
  }
  else
  {
    player.Say(player.ActiveInventory.Name);
    Verbs.SetAction(eGA_UseInv);
    mouse.ChangeModeGraphic(eModeUseinv, player.ActiveInventory.CursorGraphic);
    
  }
}
SMF spam blocked by CleanTalk