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 ?
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.
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.
No it doesn't, they both use InventoryItem pointers, you're thinking about the old LoseInventory function. This is Character.LoseInventory(InventoryItem *item).
Maybe he is using AGS 2.72?
Which he is?
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.
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?
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.
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.
Guess so.
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