Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Wed 09/02/2011 11:07:10

Title: Check player has not got an inventory item...
Post by: barefoot on Wed 09/02/2011 11:07:10
Hi

I'm in the middle of doing some scripting and I've come across this:

What would be a script for ' if player has NOT got an inventory item..'

I have other conditions set off by a region as well so it will need to fit in with other bits in the script..

I have used another way but maybe you have a better way?


cheers

barefoot
.




Title: Re: Check player has not got an inventory item...
Post by: Calin Leafshade on Wed 09/02/2011 11:14:42
you can use the ! operator to negate any boolean expression.

so if (!player.HasInventory(iKey)) checks if player does NOT have iKey.
Title: Re: Check player has not got an inventory item...
Post by: barefoot on Wed 09/02/2011 11:59:58
Thank you very much Calin  :=

barefoot
Title: Re: Check player has not got an inventory item...
Post by: Ryan Timothy B on Wed 09/02/2011 18:46:05
It's probably better to get used to using the ! operator, but in case it's troubling for you, this would be exactly the same:

if (player.HasInventory(iKey) == false)
Title: Re: Check player has not got an inventory item...
Post by: barefoot on Wed 09/02/2011 20:27:39
Cheers Ryan

2 ways.. great  :=

barefoot
Title: Re: Check player has not got an inventory item...
Post by: Knox on Wed 09/02/2011 22:10:32
or if you really want to complicate your life you could do this:


if (!(player.HasInventory(iKey) == true))


...hehe
Title: Re: Check player has not got an inventory item...
Post by: Khris on Wed 09/02/2011 22:33:37
Or, without using !, there's
  if (player.InventoryQuantity[iKey] == 0)
Title: Re: Check player has not got an inventory item...
Post by: Knox on Wed 09/02/2011 22:56:29
and if you want a nose-bleed:

if (!(!(player.HasInventory(iKey) == true)) != true)*












*dont try this at home
Title: Re: Check player has not got an inventory item...
Post by: monkey0506 on Thu 10/02/2011 00:35:00
if (player.HasInventory(iKey) ^ true)

Which is an extremely misleading usage of the XOR operator. :)

if ((player.HasInventory(iKey)) ^ (((true) && (false)) ^ ((true) || (false))))

Do I win? :=
Title: Re: Check player has not got an inventory item...
Post by: barefoot on Thu 10/02/2011 05:38:03
Nosebleed and nausea... ::)

great... cheers guys...   :=

barefoot
Title: Re: Check player has not got an inventory item...
Post by: Matti on Thu 10/02/2011 13:11:08
Quote from: monkey_05_06 on Thu 10/02/2011 00:35:00
Do I win?

Quote from: barefoot on Thu 10/02/2011 05:38:03
Nosebleed and nausea...

I'm glad I didn't participate..
Title: Re: Check player has not got an inventory item...
Post by: Knox on Thu 10/02/2011 13:54:14
QuoteI'm glad I didn't participate..
sure sure!!  ;)