Problem with 2 conditions for if function

Started by barefoot, Sat 11/12/2010 06:46:25

Previous topic - Next topic

barefoot

Hi

I think my mind's gone dead because I can't quite get this to script to work.

I want to check for two conditions if an active inventory item is clicked on another inventory item:

if (player.ActiveInventory == idriver) AND if {player.HasInventory(iwire));  An action happens and of course an ELSE Display("You need some wire first");

In the inventory you can have an electrical plug, screwdriver, pliers and

wire. You should only be able to use the screwdriver on the plug if you have the wire...

Something like this:

Code: ags

function iplug_UseInv()
{
  if (player.ActiveInventory == iscrew)
  if (player.HasInventory(iwire)) 

   
   Display("You use the screwdriver to attach the wire to the plug"); 
   cChris.LoseInventory(iwire);
   cChris.LoseInventory(iplug);
   cChris.LoseInventory(iscrew);
   cChris.AddInventory(iplugwire);
   Display("You now have a plug with some electrical wire attached.");
}


Should i try and use a dummy screwdriver until the wire has been got or is there a better way?

Can someone with a sound mind please advice..?

cheers

barefoot

I May Not Be Perfect but I Have A Big Heart ..

ThreeOhFour

Sounds like you want something like:

Code: ags

function iplug_UseInv()
{
  if (player.ActiveInventory == iscrew && player.HasInventory(iwire))
  {
    Display("You use the screwdriver to attach the wire to the plug"); 
    cChris.LoseInventory(iwire);
    cChris.LoseInventory(iplug);
    cChris.LoseInventory(iscrew);
    cChris.AddInventory(iplugwire);
    Display("You now have a plug with some electrical wire attached.");
  }
}

barefoot

Sounds good Ben.. of course i should have known.. or do but not on all cylinders at the moment...

cheers
barefoot

I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk