Weird problem with dump and delete
by Guimo · in Torque Game Engine · 07/10/2008 (6:58 pm) · 3 replies
Hi,
I have a problem that I really dont understand. Look at this code:
%unit = WSUnit::create( 5000, 1001, %caster.owner, %this.battle, false, "", %caster);
echo(%unit);
%unit.dump();
%unit.delete();
%unit = WSPermanentEffect::create();
echo(%unit);
%unit.dump();
%unit.delete();
The first portion prints the object ID and dumps its contents, then deletes the object.
The second code prints the object ID, meaning the object exists and I can even query information and call script functions on it but any call to dump or delete brings:
warscale/common/WSBattleMap.cs (856): Unknown command dump.
Object WSPermanentEffect(5268) WSPermanentEffect -> ScriptObject -> SimObject
warscale/common/WSBattleMap.cs (857): Unknown command delete.
Object WSPermanentEffect(5268) WSPermanentEffect -> ScriptObject -> SimObject
Which is really weird... my code to create both objects is defined as:
function WSUnit::create(%unitid, %modelid, %owner, %battle, %isarmyunit, %equipment, %parent) {
%unit = new ScriptObject(WSUnit);
%unit.battle = %battle;
... more data initialized here
return %unit;
}
function WSPermanentEffect::create() {
%pef = new ScriptObject(WSPermanentEffect);
%pef.data = "data";
return %pef;
}
All my objects are initialized this way and none of them are failing, only this one. Really weird. Any suggestion will be appreciated.
Luck!
Guimo
I have a problem that I really dont understand. Look at this code:
%unit = WSUnit::create( 5000, 1001, %caster.owner, %this.battle, false, "", %caster);
echo(%unit);
%unit.dump();
%unit.delete();
%unit = WSPermanentEffect::create();
echo(%unit);
%unit.dump();
%unit.delete();
The first portion prints the object ID and dumps its contents, then deletes the object.
The second code prints the object ID, meaning the object exists and I can even query information and call script functions on it but any call to dump or delete brings:
warscale/common/WSBattleMap.cs (856): Unknown command dump.
Object WSPermanentEffect(5268) WSPermanentEffect -> ScriptObject -> SimObject
warscale/common/WSBattleMap.cs (857): Unknown command delete.
Object WSPermanentEffect(5268) WSPermanentEffect -> ScriptObject -> SimObject
Which is really weird... my code to create both objects is defined as:
function WSUnit::create(%unitid, %modelid, %owner, %battle, %isarmyunit, %equipment, %parent) {
%unit = new ScriptObject(WSUnit);
%unit.battle = %battle;
... more data initialized here
return %unit;
}
function WSPermanentEffect::create() {
%pef = new ScriptObject(WSPermanentEffect);
%pef.data = "data";
return %pef;
}
All my objects are initialized this way and none of them are failing, only this one. Really weird. Any suggestion will be appreciated.
Luck!
Guimo
About the author
#2
Thanks for the comment but AFAIK the WSPermanentEffect is a namespace and I need that space. There are functions like:
function WSPermanentEffect::getLifetime(%this) {
return %this.lifetime;
}
Which uses the namespace and they work fine. So If I call:
%unit = WSPermanentEffect::create();
echo(%unit.getLifetime());
The answer is correct. Any call to this namespace works but if I invoke a basic engine SimObject function like dump or delete I get the same error. its like the engine cannot identify the object.
I have tried to force the classname in the namespace:
%ef = new ScriptObject( WSEffectName ) {
class = WSEffect;
};
And I get this result:
warscale/common/WSBattleMap.cs (857): Unknown command dump.
Object WSEffectName(5258) WSEffectName -> WSEffect -> ScriptObject -> SimObject
warscale/common/WSBattleMap.cs (858): Unknown command delete.
Object WSEffectName(5258) WSEffectName -> WSEffect -> ScriptObject -> SimObject
So I know the hierarchy tree is working.
After that I followed your example and did:
%ef = new ScriptObject( WSEffectName ) {
class = WSEffect;
};
And I got:
warscale/common/WSBattleMap.cs (857): Unknown command dump.
Object (5258) WSEffect -> ScriptObject -> SimObject
warscale/common/WSBattleMap.cs (858): Unknown command delete.
Object (5258) WSEffect -> ScriptObject -> SimObject
Which makes me more confident that this is working.
As I said, all my objects are defined the same way and all of them work and I have about 30 of them all working fine and accepting dump and delete.
Do you know where should I check to see how is the engine checking the hierarchy tree?
Luck!
Guimo
07/10/2008 (7:33 pm)
Hi Peter,Thanks for the comment but AFAIK the WSPermanentEffect is a namespace and I need that space. There are functions like:
function WSPermanentEffect::getLifetime(%this) {
return %this.lifetime;
}
Which uses the namespace and they work fine. So If I call:
%unit = WSPermanentEffect::create();
echo(%unit.getLifetime());
The answer is correct. Any call to this namespace works but if I invoke a basic engine SimObject function like dump or delete I get the same error. its like the engine cannot identify the object.
I have tried to force the classname in the namespace:
%ef = new ScriptObject( WSEffectName ) {
class = WSEffect;
};
And I get this result:
warscale/common/WSBattleMap.cs (857): Unknown command dump.
Object WSEffectName(5258) WSEffectName -> WSEffect -> ScriptObject -> SimObject
warscale/common/WSBattleMap.cs (858): Unknown command delete.
Object WSEffectName(5258) WSEffectName -> WSEffect -> ScriptObject -> SimObject
So I know the hierarchy tree is working.
After that I followed your example and did:
%ef = new ScriptObject( WSEffectName ) {
class = WSEffect;
};
And I got:
warscale/common/WSBattleMap.cs (857): Unknown command dump.
Object (5258) WSEffect -> ScriptObject -> SimObject
warscale/common/WSBattleMap.cs (858): Unknown command delete.
Object (5258) WSEffect -> ScriptObject -> SimObject
Which makes me more confident that this is working.
As I said, all my objects are defined the same way and all of them work and I have about 30 of them all working fine and accepting dump and delete.
Do you know where should I check to see how is the engine checking the hierarchy tree?
Luck!
Guimo
#3
I decided to change the function name from
function WSEffect::create()
to:
function WSEffect_create()
And now it works fine. Its really strange but it does. I recall reading a manual which says the :: are meaningless in the function names.
Well... its working now...
Thanks!
Guimo
07/10/2008 (9:06 pm)
Ok,I decided to change the function name from
function WSEffect::create()
to:
function WSEffect_create()
And now it works fine. Its really strange but it does. I recall reading a manual which says the :: are meaningless in the function names.
Well... its working now...
Thanks!
Guimo
Torque 3D Owner Peter Simard
Default Studio Name
function WSPermanentEffect::create() { %pef = new [b]ScriptObject();[/b] %pef.data = "data"; return %pef; }You are naming each object the same thing, which is also a namespace. I suspect the engine is getting confused.