Added object.busy()
parent
47d7b80507
commit
8004e68948
|
@ -873,6 +873,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
|
|||
bc->AddItem("energyCell", CBotTypResult(CBotTypPointer, "object"), PR_READ);
|
||||
bc->AddItem("load", CBotTypResult(CBotTypPointer, "object"), PR_READ);
|
||||
bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ);
|
||||
bc->AddFunction("busy", CScript::rBusy, CScript::cBusy);
|
||||
bc->AddFunction("factory", CScript::rFactory, CScript::cClassOneFloat);
|
||||
|
||||
// Initializes the class FILE.
|
||||
|
|
|
@ -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 );";
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue