Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: .M.M. on Fri 09/11/2007 20:45:12

Title: Deleting inv items by pressinig a button
Post by: .M.M. on Fri 09/11/2007 20:45:12
Hi, I need  deleting button, because in my RPG, player can have many old items with no
real function (because he will have better thing).I tried use

player.LoseInventory (player.ActiveInventory); 

it announced me error
---------------------------
Adventure Game Studio
---------------------------
An error has occured. Please contact the game author for support, as this
is likely to be a scripting error and not a bug in AGS.
(ACI version 2.72.920)

in Global script (line 187)

Error: LoseInventoryFromCharacter: invalid invnetory number

---------------------------
OK   
---------------------------

Can I use that button without using if ?
Title: Re: Deleting inv items by pressinig a button
Post by: GarageGothic on Fri 09/11/2007 21:08:40
How did you get the error? Did you click the button without actually having selected an active inventory item?

Have you tried:

if (player.ActiveInventory != null) player.LoseInventory(player.ActiveInventory);

?

Edit: I see now that there was a space between the function and the parenthesis, not sure if that could cause problems.
Title: Re: Deleting inv items by pressinig a button
Post by: Dualnames on Fri 09/11/2007 21:53:46
Actual it was a correct error.
player.ActiveInventory returns inventory item script name
ex
ikey
and loseinventory works with integers
ex 1,2
You get the idea.
Title: Re: Deleting inv items by pressinig a button
Post by: GarageGothic on Fri 09/11/2007 21:59:43
No it doesn't, they both use InventoryItem pointers, you're thinking about the old LoseInventory function. This is Character.LoseInventory(InventoryItem *item).

Title: Re: Deleting inv items by pressinig a button
Post by: Dualnames on Fri 09/11/2007 22:14:49
Maybe he is using AGS 2.72?

Which he is?
Title: Re: Deleting inv items by pressinig a button
Post by: GarageGothic on Fri 09/11/2007 22:17:58
Sure he's using 2.72 as it says in the error message, but hey, you know what? I copied the "Character.LoseInventory(InventoryItem *item)" syntax straight from the 2.72 manual. Please do a bit of research if you want to argue a case.
Title: Re: Deleting inv items by pressinig a button
Post by: Dualnames on Fri 09/11/2007 22:25:12
You sure? I mean no hard feeling but I'm using AGS and ,,,
God damn we're both right
LoseInventoryFromCharacter returns int
cEgo.LoseInventory returns inv item
Sorry. My fault.
But why does he get this

Error: LoseInventoryFromCharacter: invalid invnetory number

on the error message?
Title: Re: Deleting inv items by pressinig a button
Post by: GarageGothic on Fri 09/11/2007 22:31:08
I'm guessing that's the internal function used by AGS when you call Character.LoseInventory. I sometimes get unexpected function names like this in error messages when using RawDraw functions incorrectly.

Mirek, I did check the function I posted above in my own 2.72 game, and it works as it should. Let me know if you have any further problems.

Title: Re: Deleting inv items by pressinig a button
Post by: Khris on Fri 09/11/2007 22:33:07
You aren't both right... ::)
GG is right and you're wrong.

My guess is that player.LoseInventory(player.ActiveInventory); internally calls
LoseInventoryFromCharacter(player.ID, player.ActiveInventory.ID);.
This should throw a null pointer error, but the engine seems to not have been revamped completely, i.e. the oo-style code was added as kind of a front-end.
Since the old code requested a number as parameter, the error message reflects that.
Title: Re: Deleting inv items by pressinig a button
Post by: Dualnames on Sat 10/11/2007 00:49:31
Guess so.
Title: Re: Deleting inv items by pressinig a button
Post by: .M.M. on Sat 10/11/2007 12:58:44
Quote from: GarageGothic on Fri 09/11/2007 21:08:40

Have you tried:

if (player.ActiveInventory != null) player.LoseInventory(player.ActiveInventory);


Thanks, that work great!  :D