Blockland Forums > Modification Help
Scriptobjects
lilboarder32:
--- Quote from: HellsHero on March 14, 2011, 02:45:06 PM ---Using your fancy way, how do I refer to a ScriptObject that's in a ScriptGroup?
--- End quote ---
ScriptGroup.getObject(%num);
Can you only add scriptObjects to scriptGroups? Or can a scriptObject "parent" other objects?
HellsHero:
--- Quote from: lilboarder32 on March 14, 2011, 02:48:04 PM ---ScriptGroup.getObject(%num);
--- End quote ---
Thanks, I tried getObject() but wasn't sure what the arg was.
--- Quote from: lilboarder32 on March 14, 2011, 02:48:04 PM ---Can you only add scriptObjects to scriptGroups? Or can a scriptObject "parent" other objects?
--- End quote ---
You can't add an object to ScriptObjects. You can only add them to ScriptGroups.
Bauklotz:
--- Code: ---function scriptObject::removeType(%this, %i) {
%this.type[%i] = "";
for(();%i<%types;%i++)
%this.type[%i - 1] = %this.type[%i];
%this.types--;
%this.type[%this.types] = "";
}
--- End code ---
Might not be optimized, but should work.
Destiny/Zack0Wack0:
--- Quote from: Bauklotz on March 15, 2011, 04:08:02 AM ---
--- Code: ---function scriptObject::removeType(%this, %i) {
%this.type[%i] = "";
for(();%i<%types;%i++)
%this.type[%i - 1] = %this.type[%i];
%this.types--;
%this.type[%this.types] = "";
}
--- End code ---
Might not be optimized, but should work.
--- End quote ---
Yeah well there's a syntax error on that for loop there.
I made this a few months ago for storing dynamic teams:
http://dl.dropbox.com/u/551734/code/torque/genericArraySO.cs
--- Code: ---function genericArraySO::onAdd(%this)
{
%this.count = 0;
}
function genericArraySO::add(%this,%value)
{
%this.value[%this.count] = %value;
%this.count++;
}
function genericArraySO::get(%this,%index)
{
return %this.value[%index];
}
function genericArraySO::search(%this,%value)
{
for(%i=0;%i<%this.count;%i++)
{
if(%this.value[%i] $= %value)
return %i;
}
return -1;
}
function genericArraySO::remove(%this,%index)
{
%this.value[%index] = "";
for(%i=%index+1;%i<%this.count;%i++)
%this.value[%i-1] = %this.value[%i];
}
function genericArraySO::clear(%this)
{
for(%i=0;%i<%this.count;%i++)
{
if(isObject(%this.value[%i]))
%this.value[%i].delete();
%this.value[%i] = "";
}
%this.count = 0;
}
--- End code ---