Displaying number of items in inventory on In-Game GUI
by iHugMedia · in Torque Game Engine · 03/05/2006 (7:03 pm) · 7 replies
In my game, I want the HUD to display the amount of Health Kits the player has in inventory.
I tried using
but at no avail. I've seen resources for Ammo, but these seem different as they need a Weapon Shapebase to work. Is there a simple function that can return the number of an item in the players inventory?
Any help is very appreciated,
Thanks in advance.
I tried using
%healthkits = (%this.getInventory(%this.HealthKit)); return %healthkit();
but at no avail. I've seen resources for Ammo, but these seem different as they need a Weapon Shapebase to work. Is there a simple function that can return the number of an item in the players inventory?
Any help is very appreciated,
Thanks in advance.
About the author
Pretentious arts student
#2
EDIT: I added Beffy's Inventory tutorial, and now the Weapon Ammo never runs out. I added
03/05/2006 (9:39 pm)
Thanks peter. I just looked through Beffy's inventory tutorial and found lots of useful code there aswell.EDIT: I added Beffy's Inventory tutorial, and now the Weapon Ammo never runs out. I added
if ((%obj.getInventory(%this.ammo)) > 0)to the onFire function, but the animation still plays. I can't find a script function to override the animation before it plays.
#3
03/05/2006 (10:25 pm)
Well that's why the default weapon setup has the weapon move to an ammoless state, where you can't call the onFire state. Look at the default crossbow, and see the onAmmo and onNoAmmo states, these are called when setAmmoState(bool) is called on the weapon image.
#4
03/05/2006 (10:53 pm)
I tried adding if ((%obj.getInventory(%this.ammo)) < 1)
%this.setAmmoState(0);
else to the beggining of the onFire datablock, but it doesn't seem to be doing anything.
#5
03/11/2006 (6:48 pm)
*bump* anyone?
#6
03/11/2006 (7:03 pm)
Using the old Ammo HUD tutorial, you can modify it to suit very many things. It's what I had used for displaying the current weapon's name, ammo, and clip count.
#7
03/11/2006 (10:13 pm)
Thanks C2, I'll check it out
Torque 3D Owner Peter Simard
Default Studio Name
should be
return %healthkit;
You only need to add () if its a function your calling. In this case %healthkit is a variable.