Using an object with oher in Lucas-Arts like inventory

Started by Fedx, Sat 28/02/2009 06:19:19

Previous topic - Next topic

Fedx

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!
- The gamer doesn't dies... he respawns -

Khris

1.
Something like this should work:
Code: ags
  InventoryItem*ai = player.ActiveInventory;
  if (ai != null) lStats = String.Format("Use %s on @OVERHOTSPOT@", ai.Name);


2.
Code: ags
 // 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.

Fedx

Ok, here's the code for 2:
Code: ags
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

Code: ags
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?
- The gamer doesn't dies... he respawns -

Khris

You just have to add
Code: ags
  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?

Fedx

No, I'm using "Use" hehe. I'll try that, thanks!!
- The gamer doesn't dies... he respawns -

SMF spam blocked by CleanTalk