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

Topics - turtletennis

#1
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