summaryrefslogtreecommitdiffstats
path: root/src/script/script.cpp
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2013-05-18 16:58:35 +0200
committerkrzys-h <krzys_h@interia.pl>2013-05-18 18:04:48 +0200
commit8004e689481d01decbde351d1925e0efe23daf94 (patch)
tree41abe27bb35288e53a7e462ab64f0ab8fcf02c05 /src/script/script.cpp
parent47d7b805070e317894efbed653b1d44cd789f2fa (diff)
downloadcolobot-8004e689481d01decbde351d1925e0efe23daf94.tar.gz
colobot-8004e689481d01decbde351d1925e0efe23daf94.tar.bz2
colobot-8004e689481d01decbde351d1925e0efe23daf94.zip
Added object.busy()
Diffstat (limited to 'src/script/script.cpp')
-rw-r--r--src/script/script.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 25a7e73..31ede8d 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -499,6 +499,45 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us
return true;
}
+// Compilation of instruction "object.busy()"
+CBotTypResult CScript::cBusy(CBotVar* thisclass, CBotVar* &var)
+{
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
+ return CBotTypResult(CBotTypBoolean);
+}
+
+// Instruction "object.busy()"
+
+bool CScript::rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception)
+{
+ exception = 0;
+
+ CBotVar* classVars = thisclass->GetItemList(); // "category"
+ classVars = classVars->GetNext(); // "position"
+ classVars = classVars->GetNext(); // "orientation"
+ classVars = classVars->GetNext(); // "pitch"
+ classVars = classVars->GetNext(); // "roll"
+ classVars = classVars->GetNext(); // "energyLevel"
+ classVars = classVars->GetNext(); // "shieldLevel"
+ classVars = classVars->GetNext(); // "temperature"
+ classVars = classVars->GetNext(); // "altitude"
+ classVars = classVars->GetNext(); // "lifeTime"
+ classVars = classVars->GetNext(); // "material"
+ classVars = classVars->GetNext(); // "energyCell"
+ classVars = classVars->GetNext(); // "load"
+ classVars = classVars->GetNext(); // "id"
+ int rank = classVars->GetValInt();
+ CObject* obj = CObjectManager::GetInstancePointer()->SearchInstance(rank);
+ CAuto* automat = obj->GetAuto();
+
+ if ( automat != nullptr )
+ result->SetValInt(automat->GetBusy());
+ else
+ exception = ERR_MANIP_VEH;
+
+ return true;
+}
+
// Instruction "object.factory(cat)"
bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception)