Items don't show
by Toks · in RTS Starter Kit · 12/27/2006 (3:22 am) · 2 replies
Hi all, ive got the following problem with my RTSStarterkit:
im trying to get some items in my world using ItemData datablocks like this:
datablock ItemData(Potion1)
{
// Mission editor category, this datablock will show up in the
// specified category under the "shapes" root category.
category = "Health";
// Basic Item properties
shapeFile = "~/data/shapes/items/potion/potion.dts";
mass = 1;
friction = 1;
elasticity = 0.3;
// Dynamic properties defined by the scripts
pickUpName = "a health potion";
repairAmount = 50;
};
and this:
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;
}
both were kind of copied from garagegames (sorry about that) so they should be working, at least thats what I thought. The file with the datablock in it is executed from game.cs where the other datablocks are loaded too.
Everything looks fine so far, right? Well, when I fire up my game and I spawn this test object (either through the mission editor or through a test-function) it does not show. When I go to the mission editor inspector function, I can find my object, and it indeed does have the right datablock, rotation, position and all the things you'd expect, and when I have an echo through the console like this: echo(%obj.getDatablock().shapeFile); it does return the right value however I cannot see it, and I also don't see why not.
Thanks for reading (and maybe some help)
P.S. The file DOES exist and when I try the same with the standard crossbow or crossbowammo they have the same problem.
im trying to get some items in my world using ItemData datablocks like this:
datablock ItemData(Potion1)
{
// Mission editor category, this datablock will show up in the
// specified category under the "shapes" root category.
category = "Health";
// Basic Item properties
shapeFile = "~/data/shapes/items/potion/potion.dts";
mass = 1;
friction = 1;
elasticity = 0.3;
// Dynamic properties defined by the scripts
pickUpName = "a health potion";
repairAmount = 50;
};
and this:
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;
}
both were kind of copied from garagegames (sorry about that) so they should be working, at least thats what I thought. The file with the datablock in it is executed from game.cs where the other datablocks are loaded too.
Everything looks fine so far, right? Well, when I fire up my game and I spawn this test object (either through the mission editor or through a test-function) it does not show. When I go to the mission editor inspector function, I can find my object, and it indeed does have the right datablock, rotation, position and all the things you'd expect, and when I have an echo through the console like this: echo(%obj.getDatablock().shapeFile); it does return the right value however I cannot see it, and I also don't see why not.
Thanks for reading (and maybe some help)
P.S. The file DOES exist and when I try the same with the standard crossbow or crossbowammo they have the same problem.
#2
12/28/2006 (8:54 am)
No offence, but that is exactly what I did, except for that you have posted the onUse function too, though this is kind of useless when the object doesnt really appear in the world. the problem also isnt that it doesn't show in the mission editor, but that when you place it in the world, the object does indeed have the right datablock (potion1) but it appears it does not have a shapeFile. (sorry if i was unclear about that)
Torque Owner Fucifer
datablock ItemData(Potion1) { // Mission editor category, this datablock will show up in the // specified category under the "shapes" root category. category = "Health"; // Basic Item properties shapeFile = "~/data/shapes/items/potion/potion.dts"; mass = 1; friction = 1; elasticity = 0.3; // Dynamic properties defined by the scripts pickUpName = "a health potion"; repairAmount = 50; }; function Potion1::onUse(%this,%user) { // Apply some health to whoever uses it, the health kit is only // used if the user is currently damaged. if (%user.getDamageLevel() != 0) { %user.decInventory(%this,1); %user.applyRepair(%this.repairAmount); if (%user.client) messageClient(%user.client, 'MsgPotion1Used', '\c2Health Kit Applied'); } }