"Use inventory item with character, only if cursorgraphic=inv item"? [SOLVED]

Started by iamlowlikeyou, Thu 04/11/2010 12:10:09

Previous topic - Next topic

iamlowlikeyou

Sorry for posting so much, but once again after hours of searching, I can't find anything on this anywhere...

I want to make a basic "use inventory with NPC" function, that only applies when the mouse cursor is set to the inventory item graphic, like in Sam n Max Freelance Police (and most probably many other games).

I have tried figuring out the code myself, and ended up with this, but apparently it is not entirely correct;

function Girl_AnyClick(){
 if (iTeddyBear.CursorGraphic){
    //some scripting
}
 else{}
}



I don't know if it's AnyClick I should use, or if there's a better option, and I don't know if the (iTeddyBear.CursorGraphic) makes any sense in this context either...

Any help would be greatly appreciated.

Sslaxx

Depending on the settings you've picked, the cursor item should be the inventory graphic item anyway, so player.ActiveInventory would work?

Code: ags
function Girl_AnyClick()
{
 if (player.ActiveInventory == iTeddyBear)
 {
     //some scripting
 }
 else
 {
 }
}
Stuart "Sslaxx" Moore.

Dualnames

This is a direct approach, though I think player.ActiveInventory==iTeddyBear inside the if would work better, but well, there you go anyhow.

Code: ags

function Girl_AnyClick(){
  if (mouse.GetModeGraphic(mouse.Mode)==iTeddyBear.CursorGraphic){
     //some scripting
}
  else{
}
}


OR

Code: ags

function Girl_AnyClick(){
  if (player.ActiveInventory==iTeddyBear){
     //some scripting
}
  else{
}
}

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

Code: ags
  if (iTeddyBear.CursorGraphic){


This will always be true unless the CursorGraphic is set to 0, in which case it'll always be false.
The correct method was pointed out already, just wanted to say that the proper event would be "Use inventory on character" which will create a function named "Girl_Useinv()".

Girl_AnyClick on the other hand will react to any mouse mode (except Walk I believe).

iamlowlikeyou

Thanks a lot for the kind replies!

I have tried the ActiveInventory function, and it worked - BUT;
when ActiveInventory is active, it still applies even if one of the other cursors are visible (walk, talk, use, etc)...
What I want, is the function only to apply, when the inventory item is the cursor graphic. That's why I thought it would work better, if I used the CursorGraphic function...
I hope I explained this properly.

@Khris: I have actually tried to use the Useinv function also, but that didn't do anything. Obviously I made a mistake somewhere. Can you give me the full script for this function?

Anyone have an idea how to fix this?

Matti

The function is empty when it's created. But if you just use Girl_Useinv instead of Girl_AnyClick (and ActiveInventory instead of CursorGraphic), then everything should work just fine.

Edit: Like this.

Code: ags

function cGirl_UseInv()
{
  if (player.ActiveInventory==iTeddyBear) {
  // whatever
  }
}

iamlowlikeyou


SMF spam blocked by CleanTalk