Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Fedx on Sat 28/02/2009 06:19:19

Title: Using an object with oher in Lucas-Arts like inventory
Post by: Fedx on Sat 28/02/2009 06:19:19
Ok here is the question, for example, I want to use batteries with something in a Lucas-Arts like inventory. The question is, what's the script for changing the label text to "Use batteries with @OVERHOTSPOT@" (Or whatever I have to put if I want the inventory item to appear). Call the batteries iBater and the label "lStats". Thanks!  :)

Edit: Oh, and BTW, supose that I click (In any cursor mode) and object in my Inv, what's the script to change the cursor image to that object? thanks!
Title: Re: Using an object with oher in Lucas-Arts like inventory
Post by: Khris on Sat 28/02/2009 07:04:27
1.
Something like this should work:
  InventoryItem*ai = player.ActiveInventory;
  if (ai != null) lStats = String.Format("Use %s on @OVERHOTSPOT@", ai.Name);


2.
// in on_mouse_click, eMouseLeftInv, handle inv clicks in script: true
  if (mouse.Mode != eModeUseinv) player.ActiveInventory = inventory[game.inv_activated];


Of course I have no idea what your current script looks like, so these might work.
Title: Re: Using an object with oher in Lucas-Arts like inventory
Post by: Fedx on Sat 28/02/2009 07:58:00
Ok, here's the code for 2:
function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseMiddle) {
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    ProcessClick(mouse.x, mouse.y, eModeWalkto);
  }
}


Where should I put that Code 2 you gave me?
And, for Code 1, here's the piece of code for the "Use" Button

function Button3_OnClick(GUIControl *control, MouseButton button)
{
  mouse.Mode = eModeInteract;
  Label6.Text = ("Usar @OVERHOTSPOT@");
}


Do I have to use an If function or something so I can use Code 1?
Title: Re: Using an object with oher in Lucas-Arts like inventory
Post by: Khris on Sat 28/02/2009 08:52:46
You just have to add
  else if (button == eMouseLeftInv) {
    ...
  }

to the end of on_mouse_click, the put in there what's supposed to happen.
Which cursor mode are you using to select an inv item as active? PickUp?
Title: Re: Using an object with oher in Lucas-Arts like inventory
Post by: Fedx on Sat 28/02/2009 19:09:14
No, I'm using "Use" hehe. I'll try that, thanks!!