mirror of
https://github.com/Ragora/T2-BoL.git
synced 2026-03-04 13:00:22 +00:00
Brought up to date with the newest T2BoL I've located
This commit is contained in:
parent
8c96cba3e1
commit
accd31895e
287 changed files with 108557 additions and 107608 deletions
83
scripts/modscripts/shared/Array.cs
Normal file
83
scripts/modscripts/shared/Array.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Array.cs
|
||||
// Array object you can pass around.
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//==============================================================================
|
||||
|
||||
function ArrayFactory::create(%this, %name)
|
||||
{
|
||||
if (isObject(%name))
|
||||
%name = "";
|
||||
%object = new ScriptObject(%name) { class = "ArrayObject"; };
|
||||
%object.elementCount = 0;
|
||||
return %object;
|
||||
}
|
||||
|
||||
function ArrayObject::setElement(%this, %index, %object)
|
||||
{
|
||||
%replaced = false;
|
||||
if (%this.Element[%index] != "")
|
||||
%replaced = true;
|
||||
else
|
||||
{
|
||||
%this.elementIndex[%index] = %this.elementCount;
|
||||
%this.elementIndices[%this.elementCount] = %index;
|
||||
%this.elementCount++;
|
||||
}
|
||||
|
||||
%this.Element[%index] = %object;
|
||||
return %replaced;
|
||||
}
|
||||
|
||||
function ArrayObject::list(%this)
|
||||
{
|
||||
%list = Array.create();
|
||||
for (%i = 0; %i < %this.elementCount; %i++)
|
||||
%list.setElement(%i, %this.Element[%this.elementIndices[%i]]);
|
||||
return %list;
|
||||
}
|
||||
|
||||
function ArrayObject::removeElement(%this, %index)
|
||||
{
|
||||
if (%this.Element[%index] != "")
|
||||
{
|
||||
%this.Element[%index] = "";
|
||||
for (%i = %this.elementIndex[%index]; %i < %this.elementCount; %i++)
|
||||
%this.elementIndices[%i] = %this.elementIndices[%i+1];
|
||||
%this.elementCount--;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function ArrayObject::hasElementValue(%this, %value)
|
||||
{
|
||||
for (%i = 0; %i < %this.elementCount; %i++)
|
||||
if (%this.Element[%i] == %value)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function ArrayObject::isElement(%this, %index)
|
||||
{
|
||||
if (%this.Element[%index] == "")
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function ArrayObject::element(%this, %index)
|
||||
{
|
||||
return %this.Element[%index];
|
||||
}
|
||||
|
||||
function ArrayObject::count(%this)
|
||||
{
|
||||
return %this.elementCount;
|
||||
}
|
||||
|
||||
if (!IsObject(Array))
|
||||
new ScriptObject(Array) { class = "ArrayFactory"; };
|
||||
Loading…
Add table
Add a link
Reference in a new issue