Game Development Community

Add new item to inventory

by James W Campbell · in Technical Issues · 02/25/2009 (8:37 pm) · 3 replies

Hi guys,

I'm trying to write up some torque script so that after a certain event an item will be added to my inventory. This works fine when adding a crossbow item using the command: %client.player.setInventory("Crossbow",1);

However i have no idea how to add an item named such as say.. a key.

Do i have to create a item datablock named key?
Where would that be stored?
does the item have to exist in data/shapes?

Any help would be great,
cheers :)

#1
02/25/2009 (10:38 pm)
You'll need a datablock for your new item. It's probably a good idea to add it to the allowable inventory list in your player datablock also (player.cs).

The datablock can be added to any script file, server-side, that get's executed, or you could add it to a new script file so long as you exec it in game.cs with the other script exec commands.

The item will require a valid shapefile. Shapes are most often placed in "~/data/shapes" but can be located anywhere in your directory structure, so long as the filepath and filename are correct in your datablock.
#2
02/25/2009 (11:36 pm)
ok cool thanks a lot for your advice :)
#3
07/21/2009 (11:19 am)
exactly what i was looking for thx alot