summaryrefslogtreecommitdiffstats
path: root/src/script
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
parent47d7b805070e317894efbed653b1d44cd789f2fa (diff)
downloadcolobot-8004e689481d01decbde351d1925e0efe23daf94.tar.gz
colobot-8004e689481d01decbde351d1925e0efe23daf94.tar.bz2
colobot-8004e689481d01decbde351d1925e0efe23daf94.zip
Added object.busy()
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cbottoken.cpp3
-rw-r--r--src/script/script.cpp39
-rw-r--r--src/script/script.h3
3 files changed, 45 insertions, 0 deletions
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index c101f17..c56482f 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -253,6 +253,7 @@ std::string GetHelpFilename(const char *token)
if ( strcmp(token, "getresearchenable" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresen.txt");
if ( strcmp(token, "getresearchdone" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresdo.txt");
if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt");
+ if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt");
if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt");
if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt");
if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt");
@@ -376,6 +377,7 @@ bool IsFunction(const char *token)
if ( strcmp(token, "getresearchdone" ) == 0 ) return true;
if ( strcmp(token, "retobjectbyid") == 0 ) return true;
if ( strcmp(token, "retobject" ) == 0 ) return true;
+ if ( strcmp(token, "busy" ) == 0 ) return true;
if ( strcmp(token, "factory" ) == 0 ) return true;
if ( strcmp(token, "search" ) == 0 ) return true;
if ( strcmp(token, "radar" ) == 0 ) return true;
@@ -465,6 +467,7 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );";
if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );";
if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );";
+ if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( cat );";
if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat );";
if ( strcmp(token, "search" ) == 0 ) return "search ( );";
if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );";
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)
diff --git a/src/script/script.h b/src/script/script.h
index 481df8e..62e95b3 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -191,7 +191,10 @@ private:
static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user);
public:
+ static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var);
static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var);
+
+ static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
private: