Use inventory item on something AGS 3

Started by razing32, Fri 16/05/2008 16:23:39

Previous topic - Next topic

razing32

I need some help using an item on a hotspot/character/object.
I searched the forums and downloaded demo games but nothing  :-[.

This is what i have so far
function hHotspot3_Interact()
{
  if (player.InventoryQuantity[iSpear.ID] == 1)
  {
    player.AddInventory(iDrugs,4);
   
  }
  else
  {
    Display("There's something down there but i can;t reach");
   }

}

But i would like it to be something like
function hHotspot3_useItem(iSpear)
{
Display("I found drugs")
player.additem(iDrugs);
}

I want to use cursor 4 but i can;t find any specific example.
PLZ HELP  Embarrassed

I appologise if i did not search good enough. ???

monkey0506

You're on the right track at least! ;) Try this:

Code: ags
function hHotspot3_Useinv()
{
  if (player.ActiveInventory == iSpear) {
    Display("I found drugs!");
    player.AddInventory(iDrugs, 4);
  }
  else Display("There's something down there but I can't reach it.");
}


You need to use the "Use inventory on hotspot" event instead of the "Interact hotspot" event. For future reference you can use the [code][/code] tags to enclose code in your posts.

Also, welcome to the forums!

GarageGothic

Edit: monkey beat me to it, but I'm posting anyway just for the few snippets that are different.

In your Hotspots events pane (the little lightning bolt in the hotspot editor), there should be an option called "Use Inventory on Hotspot". Click that item and then click the three-dots icon to the right. This should create a new function called function hHotspot3_UseInv() (if it's hotspot 3).

Here you check for the currently selected inventory item, like so:

Code: ags
function hHotspot3_UseInv() {
   if (player.ActiveInventory == iSpear) {
      Display("I found drugs")
      player.AddInventory(iDrugs);
      }
   else Display("No, that's just not long enough to reach.");
}


The function "AddItem" is used for listboxes, not inventory items, by the way.

razing32

It works.THANKS !!!  ;D
You also answered amazingly fast ... :o(feels more like IM than forum)
Also , one more question ,how can i play animation during dialogue ?
i have something like this :
From tutorials for animation
Code: ags

function Man_Talk()  
 {       
   cJerk.LockView(2);
   cJerk.Animate(1, 6);    
   cJerk.UnlockView();
 } 


And for actual talk i tried this
Code: ags

function cChar1_Talk()
{
  Man_Talk();
  dDialog1.Start();
  
}


but he only talks at first. I tried to use the function Man_Talk() in the dialog :
Code: ags

// Dialog script file
@S  // Dialog startup entry point
EGO: Who are you ?
Man_Talk();
MAN: A man !
return
@1
MAN: Just a man ...
EGO: ok, ok
Man_Talk();
MAN: No, i can't.
EGO: Please take these drugs to the police.
return
@2
Man_Talk();
MAN: NO !
stop



It's off the topic of this thread, but i don;t want to start another thread for a few more replies. Sorry to the moderators.

razing32

Actually jerk used to be man, it's not a syntax error, i corected in code but not on the post before reply. I wanted to call him jerk because he doesn;t help my character then i changed it to Man.

GarageGothic

#5
Why don't you just set up a talking animation for him (specify a talking view in his character pane)? Then AGS will trigger his talk animation whenever he's speaking.

If it's some other kind of animation (blacksmith stops hammering, then talks to you), you have to specify what you're trying to do. Also, you cannot run functions directly from inside dialog scripts. You'd have to use e.g. "run-script 1" and setup a function call within the global "dialog_request" function ("if (xvalue == 1) DoSomething()").

razing32

One last thing.
How can I "END" the game ?
I can't find a command that says ENDGAME or something.

skuttleman


SMF spam blocked by CleanTalk