Game Development Community

Game Money

by DejaBlue · in Torque Game Engine · 05/05/2005 (12:12 pm) · 10 replies

I am using the torque demo 1.3 and trying to add money to it not to sure how todo this exactly. is there any tutorials for adding items that can be picked up and adds to your inventory?

I am trying to as a whole picture. add the gold.dts in my game. when i run over one i want to add the amount of 1 and the gold to my inventory. then later have a UI that shows the amount of money i have.

i started with health.cs in server scripts and edited a little as followed

datablock ItemData(Gold)
{
// Mission editor category
category = "Gold";

// Add the Ammo namespace as a parent. The ammo namespace provides
// common ammo related functions and hooks into the inventory system.
className = "Ammo";

// Basic Item properties
shapeFile = "~/data/shapes/items/Gold.dts"
mass = 1;
elasticity = 0.2;
friction = 0.6;

// Dynamic properties defined by the scripts
pickUpName = "Gold Money";
maxInventory = 20;
};

not even sure this is correct......

what do i need to do so that when i go across the gold in game to add it to inventory with a numbering of 1?

#1
05/05/2005 (1:35 pm)
Ok added some to this

datablock ItemData(Gold)
{
// Mission editor category
category = "Gold";

// Add the Ammo namespace as a parent. The ammo namespace provides
// common ammo related functions and hooks into the inventory system.
className = "Ammo";

// Basic Item properties
shapeFile = "~/data/shapes/items/Gold.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;

// Dynamic properties defined by the scripts
pickUpName = "Gold Money";
maxInventory = 20;
};

function ItemData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type. For the mission editor
// we always create "static" re-spawnable rotating objects.
%obj = new Item() {
dataBlock = %data;
static = true;
rotate = true;
};
return %obj;
}


i seem to collide with it and adds to inventory.... how would i go about getting a client message telling me the amount of gold i have in inventory? also should i change the classname to say "gold" ?
#2
05/05/2005 (4:26 pm)
@Deja, If you just did my Inventory tutorial, then this would happen automagically, all you should need to do at this point is open your InventoryGUI and look, and yes you probably want something, anything besides ammo.
#3
05/05/2005 (4:33 pm)
How would i get the total amount for the datablock in the inventory? or am i writing this incorrectly.

want to be able to say echo the total amount for say gold everytime i pickup another one?
#4
05/05/2005 (4:54 pm)
Are you talking about client or server side? On the client, just search the InventoryArray for Money and return the value contained there look at the UpdateInvetoryListView function for some pointers, you will find this in the client/scripts/client_commands.cs file.

On the server side it should already be echoing this figure look in the Inventory.cs file at the function setInventory.
#5
05/05/2005 (4:55 pm)
Thanks dreamer will add this to my own setup and go from there.
#6
05/05/2005 (7:53 pm)
Ok the inventory is adding 3 things
itemdata(name)
amount
and image file(dts)

where is this getting the amount from? i am showing 20 gold from echo's but i never created that value anywhere


maxinventory =20 which should be the MAX amount of this object gold i can have on me.

where does inventory get the value to add to inventory? i show 30 starting ammo for crossbow ammo, and then 20 when i pick up more each time til it is maxed no clue where i am getting this values tho.

echo("Recieved " @%Amount@ " of " @%Item);
echo("Item count " @$Inventory.getValue($Inventory.getIndexFromKey(%Item)));

i have right before
UpdateInventoryListView();

in the client_commands.cs

but cannot figure out where we get the amounts from in itemdata or where ever the amount is set

for example
i have gold
i collide with the gold
i want it to add 1 gold everytime i move over it

where do i specify the amount of 1?
and i am guessing the inventory would also do increments of 1 til i have a total of maxInv. pulling my hair out trying to figure this out
#7
05/05/2005 (9:11 pm)
Ok i am learning i tell yazzzz i really am.

player.cs Max Inv is max you can have of said object

under the data of the item one of the variables is max inv that is the increment.

so say
gold has max inv 1
player.cs has gold max 500

everytime i move over a gold piece i get increments of 1 til i reach a max of 500

still havent found a way to call what value a certain object has in inventory ,but still trying
#8
05/06/2005 (9:22 am)
Welp all night and part of today still to no avail on being able to see inventory of the one i want.

been trying to see the crossbowammo amount in inventory

looking at the updateinventory function i see

$Inventory.getValue(%x)

but how to write it so that i get it from crossbowammo, or gold, or even crossbow itself. i am lost on how to
#9
05/06/2005 (10:31 am)
Anyone??????????????
#10
05/06/2005 (9:17 pm)
Me and my WIfe.. ok ok she found it :P but i tried all day LOL

Goldm.setText(%this.getInventory("Gold"));
Copperm.setText(%this.getInventory("Copper"));
Silverm.setText(%this.getInventory("Silver"));

added inside of the setinventory of inventory.cs works like a charm no matter if the amount goes up or down the text field is always correct.

thanks Dreamer for the help on where to start looking.