Added camerafocus() for changing camera
parent
8d30791595
commit
3d7017525b
|
@ -334,6 +334,7 @@ std::string GetHelpFilename(const char *token)
|
||||||
if ( strcmp(token, "penup" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penup.txt");
|
if ( strcmp(token, "penup" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penup.txt");
|
||||||
if ( strcmp(token, "pencolor" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pencolor.txt");
|
if ( strcmp(token, "pencolor" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pencolor.txt");
|
||||||
if ( strcmp(token, "penwidth" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penwidth.txt");
|
if ( strcmp(token, "penwidth" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penwidth.txt");
|
||||||
|
if ( strcmp(token, "camerafocus" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/camerafocus.txt");
|
||||||
if ( strcmp(token, "extern" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/extern.txt");
|
if ( strcmp(token, "extern" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/extern.txt");
|
||||||
if ( strcmp(token, "class" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/class.txt");
|
if ( strcmp(token, "class" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/class.txt");
|
||||||
if ( strcmp(token, "static" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/static.txt");
|
if ( strcmp(token, "static" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/static.txt");
|
||||||
|
@ -441,6 +442,7 @@ bool IsFunction(const char *token)
|
||||||
if ( strcmp(token, "penup" ) == 0 ) return true;
|
if ( strcmp(token, "penup" ) == 0 ) return true;
|
||||||
if ( strcmp(token, "pencolor" ) == 0 ) return true;
|
if ( strcmp(token, "pencolor" ) == 0 ) return true;
|
||||||
if ( strcmp(token, "penwidth" ) == 0 ) return true;
|
if ( strcmp(token, "penwidth" ) == 0 ) return true;
|
||||||
|
if ( strcmp(token, "camerafocus" ) == 0 ) return true;
|
||||||
if ( strcmp(token, "sizeof" ) == 0 ) return true;
|
if ( strcmp(token, "sizeof" ) == 0 ) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -535,6 +537,7 @@ const char* GetHelpText(const char *token)
|
||||||
if ( strcmp(token, "penup" ) == 0 ) return "penup ( );";
|
if ( strcmp(token, "penup" ) == 0 ) return "penup ( );";
|
||||||
if ( strcmp(token, "pencolor" ) == 0 ) return "pencolor ( color );";
|
if ( strcmp(token, "pencolor" ) == 0 ) return "pencolor ( color );";
|
||||||
if ( strcmp(token, "penwidth" ) == 0 ) return "penwidth ( width );";
|
if ( strcmp(token, "penwidth" ) == 0 ) return "penwidth ( width );";
|
||||||
|
if ( strcmp(token, "camerafocus") == 0 ) return "camerafocus ( object );";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1639,7 +1639,7 @@ CBotTypResult CScript::cCanBuild(CBotVar* &var, void* user)
|
||||||
return CBotTypResult(CBotTypBoolean);
|
return CBotTypResult(CBotTypBoolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instruction "canbuid ( category );"
|
// Instruction "canbuild ( category );"
|
||||||
// returns true if this building can be built
|
// returns true if this building can be built
|
||||||
|
|
||||||
bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||||
|
@ -3407,6 +3407,47 @@ bool CScript::rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* use
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compilation of the instruction with one object parameter
|
||||||
|
|
||||||
|
CBotTypResult CScript::cOneObject(CBotVar* &var, void* user)
|
||||||
|
{
|
||||||
|
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
|
||||||
|
var = var->GetNext();
|
||||||
|
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
|
||||||
|
|
||||||
|
return CBotTypResult(CBotErrOverParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instruction "camerafocus(object)".
|
||||||
|
|
||||||
|
bool CScript::rCameraFocus(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||||
|
{
|
||||||
|
CScript* script = (static_cast<CObject *>(user))->GetRunScript();
|
||||||
|
|
||||||
|
CBotVar* classVars = var->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* object = CObjectManager::GetInstancePointer()->SearchInstance(rank);
|
||||||
|
|
||||||
|
script->m_main->SelectObject(object, false);
|
||||||
|
|
||||||
|
result->SetValInt(ERR_OK);
|
||||||
|
exception = ERR_OK;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
@ -3507,6 +3548,8 @@ void CScript::InitFonctions()
|
||||||
CBotProgram::AddFunction("penup", rPenUp, CScript::cNull);
|
CBotProgram::AddFunction("penup", rPenUp, CScript::cNull);
|
||||||
CBotProgram::AddFunction("pencolor", rPenColor, CScript::cOneFloat);
|
CBotProgram::AddFunction("pencolor", rPenColor, CScript::cOneFloat);
|
||||||
CBotProgram::AddFunction("penwidth", rPenWidth, CScript::cOneFloat);
|
CBotProgram::AddFunction("penwidth", rPenWidth, CScript::cOneFloat);
|
||||||
|
|
||||||
|
CBotProgram::AddFunction("camerafocus", rCameraFocus, CScript::cOneObject);
|
||||||
|
|
||||||
CBotProgram::AddFunction("canbuild", rCanBuild, CScript::cCanBuild);
|
CBotProgram::AddFunction("canbuild", rCanBuild, CScript::cCanBuild);
|
||||||
CBotProgram::AddFunction("build", rBuild, CScript::cOneFloat);
|
CBotProgram::AddFunction("build", rBuild, CScript::cOneFloat);
|
||||||
|
|
|
@ -128,6 +128,7 @@ private:
|
||||||
static CBotTypResult cPenDown(CBotVar* &var, void* user);
|
static CBotTypResult cPenDown(CBotVar* &var, void* user);
|
||||||
static CBotTypResult cOnePoint(CBotVar* &var, void* user);
|
static CBotTypResult cOnePoint(CBotVar* &var, void* user);
|
||||||
static CBotTypResult cPoint(CBotVar* &var, void* user);
|
static CBotTypResult cPoint(CBotVar* &var, void* user);
|
||||||
|
static CBotTypResult cOneObject(CBotVar* &var, void* user);
|
||||||
|
|
||||||
|
|
||||||
static bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user);
|
static bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||||
|
@ -192,6 +193,7 @@ private:
|
||||||
static bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user);
|
static bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||||
static bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user);
|
static bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||||
static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user);
|
static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||||
|
static bool rCameraFocus(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var);
|
static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var);
|
||||||
|
|
Loading…
Reference in New Issue