Deleting inv items by pressinig a button

Started by .M.M., Fri 09/11/2007 20:45:12

Previous topic - Next topic

.M.M.

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 ?

GarageGothic

#1
How did you get the error? Did you click the button without actually having selected an active inventory item?

Have you tried:

Code: ags
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.

Dualnames

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.
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)

GarageGothic

#3
No it doesn't, they both use InventoryItem pointers, you're thinking about the old LoseInventory function. This is Character.LoseInventory(InventoryItem *item).


Dualnames

Maybe he is using AGS 2.72?

Which he is?
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)

GarageGothic

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.

Dualnames

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?
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)

GarageGothic

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.


Khris

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.

Dualnames

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)

.M.M.

Quote from: GarageGothic on Fri 09/11/2007 21:08:40

Have you tried:

Code: ags
if (player.ActiveInventory != null) player.LoseInventory(player.ActiveInventory);



Thanks, that work great!  :D

SMF spam blocked by CleanTalk