本文整理汇总了C++中LoadScript函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadScript函数的具体用法?C++ LoadScript怎么用?C++ LoadScript使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadScript函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MenuSetup
void MenuSetup(void)
{
if ( ( isMenu = !isMenu ) )
{
STOP_MOBILE_PHONE_RINGING();
DESTROY_MOBILE_PHONE();
TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME( isNetGame?"mpcellphone":"spcellphone" );
DISABLE_FRONTEND_RADIO();
if ( !IS_FONT_LOADED( MYFONT ) ) LOAD_TEXT_FONT( MYFONT );
}
else
{
ENABLE_FRONTEND_RADIO();
if ( !isNetGame ) LoadScript("spcellphone");
else if ( isNetPhoneEnabled ) LoadScript("mpcellphone");
}
DISPLAY_AREA_NAME(FALSE);
DISPLAY_CASH(FALSE);
DISPLAY_FRONTEND_MAP_BLIPS(FALSE);
DISPLAY_HUD(FALSE);
DISPLAY_RADAR(FALSE);
PAUSE_GAME();
DRAW_FRONTEND_HELPER_TEXT("SELECT", "PAD_DPAD_UPDOWN", 0);
DRAW_FRONTEND_HELPER_TEXT("QUIT", "INPUT_F_CANCEL", 0);
DRAW_FRONTEND_HELPER_TEXT("CONFIRM", "INPUT_F_ACCEPT", 0);
}
开发者ID:rodd1981,项目名称:GTA-IV-Mission-Mod-Pack,代码行数:27,代码来源:scriptmgr.c
示例2: assert
void CLuaMain::InitVM()
{
assert(!m_luaVM);
// Create a new VM
m_luaVM = lua_open();
lua_pushlightuserdata(m_luaVM, m_luaVM);
lua_setfield(m_luaVM, LUA_REGISTRYINDEX, "lua.mainstate");
m_pLuaManager->OnLuaMainOpenVM(this, m_luaVM);
// Set the instruction count hook
lua_sethook(m_luaVM, InstructionCountHook, LUA_MASKCOUNT, HOOK_INSTRUCTION_COUNT);
// Load LUA libraries
luaL_openlibs(m_luaVM);
/*
luaopen_base(m_luaVM);
luaopen_math(m_luaVM);
luaopen_string(m_luaVM);
luaopen_table(m_luaVM);
luaopen_debug(m_luaVM);
luaopen_utf8(m_luaVM);
luaopen_os(m_luaVM);
*/
// Initialize security restrictions. Very important to prevent lua trojans and viruses!
//InitSecurity();
// Registering C functions
CLuaCFunctions::RegisterFunctionsWithVM(m_luaVM);
// Create class metatables
InitClasses(m_luaVM);
// Oli: Don't forget to add new ones to CLuaManager::LoadCFunctions. Thanks!
// create global vars
lua_pushelement(m_luaVM, g_pGame->GetMapManager()->GetRootElement());
lua_setglobal(m_luaVM, "root");
lua_pushresource(m_luaVM, m_pResource);
lua_setglobal(m_luaVM, "resource");
lua_pushelement(m_luaVM, m_pResource->GetResourceRootElement());
lua_setglobal(m_luaVM, "resourceRoot");
// Load pre-loaded lua scripts
LoadScript(EmbeddedLuaCode::exports);
LoadScript(EmbeddedLuaCode::coroutine_debug);
LoadScript(EmbeddedLuaCode::inspect);
}
开发者ID:huncrys,项目名称:mtasa-blue,代码行数:51,代码来源:CLuaMain.cpp
示例3: mir_sntprintf
void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir, int iGroup)
{
TCHAR buf[4096];
mir_sntprintf(buf, _T("Loading scripts from %s"), scriptDir);
CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf);
RegisterScriptsFolder(ptrA(mir_utf8encodeT(scriptDir)));
TCHAR searchMask[MAX_PATH];
mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua"));
TCHAR fullPath[MAX_PATH], path[MAX_PATH];
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(searchMask, &fd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, fd.cFileName);
PathToRelativeT(fullPath, path);
if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
LoadScript(fullPath, iGroup);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
开发者ID:kmdtukl,项目名称:miranda-ng,代码行数:30,代码来源:mlua_script_loader.cpp
示例4: RunScript
int PythonIntegration::RunScript(ScriptId scriptId, EventId evt, PyObject* args) {
ScriptRecord script;
if (!LoadScript(scriptId, script)) {
return 1;
}
auto dict = PyModule_GetDict(script.module);
auto eventName = GetFunctionName(evt);
auto callback = PyDict_GetItemString(dict, eventName);
if (!callback || !PyCallable_Check(callback)) {
logger->error("Script {} attached as {} is missing the corresponding function.",
script.filename, eventName);
return 1;
}
auto resultObj = PyObject_CallObject(callback, args);
if (!resultObj) {
logger->error("An error occurred while calling event {} for script {}.", eventName, script.filename);
PyErr_Print();
return 1;
}
auto result = -1;
if (PyInt_Check(resultObj)) {
result = PyInt_AsLong(resultObj);
}
Py_DECREF(resultObj);
return result;
}
开发者ID:ema29,项目名称:TemplePlus,代码行数:33,代码来源:python_integration.cpp
示例5: realPath
bool CDialogLoader::LoadScriptsFromPath(const string& path, TDialogScriptMap& outScriptMap)
{
ICryPak * pCryPak = gEnv->pCryPak;
_finddata_t fd;
int numLoaded = 0;
string realPath (path);
realPath.TrimRight("/\\");
string search (realPath);
search += "/*.xml";
intptr_t handle = pCryPak->FindFirst( search.c_str(), &fd );
if (handle != -1)
{
do
{
// fd.name contains the profile name
string filename = realPath;
filename += "/" ;
filename += fd.name;
bool ok = LoadScript(filename, outScriptMap);
if (ok)
++numLoaded;
} while ( pCryPak->FindNext( handle, &fd ) >= 0 );
pCryPak->FindClose( handle );
}
return numLoaded > 0;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:30,代码来源:DialogLoader.cpp
示例6: switch
void CNetwork::decideParse(char* param1, char* param2) {
CPlugins *plugin = new CPlugins;
char string[256];
for(int i = 0; i < sizeof(GMVars)/sizeof(*GMVars); ++i) {
if(strcmp((char *)GMVars[i].c_str(),param1) == false) {
switch(i) {
case TYPE_GAMEMODE: {
engineModule *engine = new engineModule;
sprintf_s(string, "%s/%s.amx",GAMEMODES_DIR, param2);
loadTime = GetTickCount();
if(LoadScript(string))
initAMXGM();
else
engine->SHOW_TO_CONSOLE_AND_EXIT("The server will now close, please specify an AMX file or run without gamemode support by specifying it in the iniMod.cfg file.\n");
delete engine;
break;
}
case TYPE_UPDATERATE: {
break;
}
case TYPE_PLUGIN: {
plugin->ParsePlugins(param2);
GMLoaded = true;
break;
}
}
}
}
delete plugin;
return;
}
开发者ID:colistro123,项目名称:Nightfire-iniMod,代码行数:31,代码来源:gamemodes.cpp
示例7: PrintException
HRESULT WScriptJsrt::ModuleMessage::Call(LPCSTR fileName)
{
JsErrorCode errorCode;
JsValueRef result = JS_INVALID_REFERENCE;
HRESULT hr;
if (specifier == nullptr)
{
errorCode = ChakraRTInterface::JsModuleEvaluation(moduleRecord, &result);
if (errorCode != JsNoError)
{
PrintException(fileName, errorCode);
}
}
else
{
LPCSTR fileContent = nullptr;
char* specifierStr = nullptr;
size_t length;
errorCode = ChakraRTInterface::JsStringToPointerUtf8Copy(specifier, &specifierStr, &length);
if (errorCode == JsNoError)
{
hr = Helpers::LoadScriptFromFile(specifierStr, fileContent);
if (FAILED(hr))
{
fprintf(stderr, "Couldn't load file.\n");
}
else
{
LoadScript(nullptr, specifierStr, fileContent, "module", true);
}
}
}
return errorCode;
}
开发者ID:ianwjhalliday,项目名称:ChakraCore,代码行数:34,代码来源:WScriptJsrt.cpp
示例8: _u
JsValueRef WScriptJsrt::LoadScriptHelper(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState, bool isSourceModule)
{
HRESULT hr = E_FAIL;
JsErrorCode errorCode = JsNoError;
LPCWSTR errorMessage = _u("");
JsValueRef returnValue = JS_INVALID_REFERENCE;
if (argumentCount < 2 || argumentCount > 4)
{
errorCode = JsErrorInvalidArgument;
errorMessage = _u("Need more or fewer arguments for WScript.LoadScript");
}
else
{
AutoString fileContent;
AutoString fileName;
AutoString scriptInjectType;
size_t fileContentLength;
size_t scriptInjectTypeLength;
IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointerUtf8Copy(arguments[1], &fileContent, &fileContentLength));
if (argumentCount > 2)
{
IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointerUtf8Copy(arguments[2], &scriptInjectType, &scriptInjectTypeLength));
if (argumentCount > 3)
{
size_t unused;
IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointerUtf8Copy(arguments[3], &fileName, &unused));
}
}
if (*fileContent)
{
// TODO: This is CESU-8. How to tell the engine?
// TODO: How to handle this source (script) life time?
returnValue = LoadScript(callee, *fileName, *fileContent, *scriptInjectType ? *scriptInjectType : "self", isSourceModule);
}
}
Error:
if (errorCode != JsNoError)
{
JsValueRef errorObject;
JsValueRef errorMessageString;
if (wcscmp(errorMessage, _u("")) == 0) {
errorMessage = ConvertErrorCodeToMessage(errorCode);
}
ERROR_MESSAGE_TO_STRING(errCode, errorMessage, errorMessageString);
ChakraRTInterface::JsCreateError(errorMessageString, &errorObject);
ChakraRTInterface::JsSetException(errorObject);
}
return returnValue;
}
开发者ID:liminzhu,项目名称:ChakraCore,代码行数:59,代码来源:WScriptJsrt.cpp
示例9: _u
JsValueRef WScriptJsrt::LoadScriptFileHelper(JsValueRef callee, JsValueRef *arguments, unsigned short argumentCount, bool isSourceModule)
{
HRESULT hr = E_FAIL;
JsValueRef returnValue = JS_INVALID_REFERENCE;
JsErrorCode errorCode = JsNoError;
LPCWSTR errorMessage = _u("");
if (argumentCount < 2 || argumentCount > 4)
{
errorCode = JsErrorInvalidArgument;
errorMessage = _u("Need more or fewer arguments for WScript.LoadScript");
}
else
{
LPCSTR fileContent;
AutoString fileName;
AutoString scriptInjectType;
size_t fileNameLength;
size_t scriptInjectTypeLength;
IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointerUtf8Copy(arguments[1], &fileName, &fileNameLength));
if (argumentCount > 2)
{
IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointerUtf8Copy(arguments[2], &scriptInjectType, &scriptInjectTypeLength));
}
if (errorCode == JsNoError)
{
hr = Helpers::LoadScriptFromFile(*fileName, fileContent);
if (FAILED(hr))
{
fwprintf(stderr, _u("Couldn't load file.\n"));
}
else
{
returnValue = LoadScript(callee, *fileName, fileContent, *scriptInjectType ? *scriptInjectType : "self", isSourceModule);
}
}
}
Error:
if (errorCode != JsNoError)
{
JsValueRef errorObject;
JsValueRef errorMessageString;
if (wcscmp(errorMessage, _u("")) == 0) {
errorMessage = ConvertErrorCodeToMessage(errorCode);
}
ERROR_MESSAGE_TO_STRING(errCode, errorMessage, errorMessageString);
ChakraRTInterface::JsCreateError(errorMessageString, &errorObject);
ChakraRTInterface::JsSetException(errorObject);
}
return returnValue;
}
开发者ID:ianwjhalliday,项目名称:ChakraCore,代码行数:59,代码来源:WScriptJsrt.cpp
示例10: lua_open
Script::Script(string scriptName)
{
// init Lua and load all libraries
L = lua_open();
LoadLibraries();
LoadScript(scriptName);
}
开发者ID:Arcanixus,项目名称:PVZ-PSP-Game,代码行数:8,代码来源:scriptingSystem.cpp
示例11: LoadScript
void LuaParser::LoadItemScript(std::string filename, ItemInst *item) {
if (item == nullptr)
return;
std::string package_name = "item_";
package_name += std::to_string(item->GetID());
LoadScript(filename, package_name);
}
开发者ID:vingiarrusso,项目名称:Server,代码行数:8,代码来源:lua_parser.cpp
示例12: IfJsrtErrorSetGo
JsValueRef WScriptJsrt::LoadScriptFileHelper(JsValueRef callee, JsValueRef *arguments, unsigned short argumentCount, bool isSourceModule)
{
HRESULT hr = E_FAIL;
JsValueRef returnValue = JS_INVALID_REFERENCE;
JsErrorCode errorCode = JsNoError;
LPCWSTR errorMessage = L"";
if (argumentCount < 2 || argumentCount > 4)
{
errorCode = JsErrorInvalidArgument;
errorMessage = L"Need more or fewer arguments for WScript.LoadScript";
}
else
{
const wchar_t *fileContent;
const wchar_t *fileName;
const wchar_t *scriptInjectType = L"self";
size_t fileNameLength;
size_t scriptInjectTypeLength;
IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointer(arguments[1], &fileName, &fileNameLength));
if (argumentCount > 2)
{
IfJsrtErrorSetGo(ChakraRTInterface::JsStringToPointer(arguments[2], &scriptInjectType, &scriptInjectTypeLength));
}
if (errorCode == JsNoError)
{
hr = Helpers::LoadScriptFromFile(fileName, fileContent);
if (FAILED(hr))
{
fwprintf(stderr, L"Couldn't load file.\n");
}
else
{
returnValue = LoadScript(callee, fileName, fileNameLength, fileContent, scriptInjectType, isSourceModule);
}
}
}
Error:
if (errorCode != JsNoError)
{
JsValueRef errorObject;
JsValueRef errorMessageString;
if (wcscmp(errorMessage, L"") == 0) {
errorMessage = ConvertErrorCodeToMessage(errorCode);
}
ChakraRTInterface::JsPointerToString(errorMessage, wcslen(errorMessage), &errorMessageString);
ChakraRTInterface::JsCreateError(errorMessageString, &errorObject);
ChakraRTInterface::JsSetException(errorObject);
}
return returnValue;
}
开发者ID:AlexElting,项目名称:ChakraCore,代码行数:58,代码来源:WScriptJsrt.cpp
示例13: main
int main(int argc,char *argv[])
{
aPrefs aP;
char* script;
OptInfo opt;
AlignInfo ainf;
fullPath infile;
//fullPath outfile;
//
SetAdjustDefaults(&aP);
if(argc != 2)
{
printf(PT_OPTIMIZER_VERSION);
printf("Usage: %s /path/to/script.txt\n", argv[0]);
exit(1);
}
StringtoFullPath(&infile, argv[1]);
script = LoadScript( &infile );
if( script != NULL )
{
if (ParseScript( script, &ainf ) == 0)
{
if( CheckParams( &ainf ) == 0 )
{
ainf.fcn = fcnPano;
SetGlobalPtr( &ainf );
opt.numVars = ainf.numParam;
opt.numData = ainf.numPts;
opt.SetVarsToX = SetLMParams;
opt.SetXToVars = SetAlignParams;
opt.fcn = ainf.fcn;
*opt.message = 0;
RunLMOptimizer( &opt );
ainf.data = opt.message;
WriteResults( script, &infile, &ainf, distSquared, 0);
exit(0);
}
//TODO: if optCreatePano is 1 then should call stitcher OR the option removed
//if (ainf.sP.optCreatePano == 1)
//{
// Stitch();
//}
DisposeAlignInfo( &ainf );
}
free( script );
}
exit(1);
}
开发者ID:MWisBest,项目名称:android_external_Focal,代码行数:58,代码来源:PToptimizer.c
示例14: LoadScripts
int LoadScripts() {
int res = 1;
for (int i=0; i<numFiles; i++) {
if (files[i].loaded != -1) continue;
int res2 = LoadScript(i);
res &= res2;
}
return res;
}
开发者ID:ZmeyNet,项目名称:lcdmiscellany,代码行数:9,代码来源:Script.cpp
示例15: LoadScripts
bool CSquirrelVM::LoadScripts(std::list<CScript> scripts)
{
for(auto Script : scripts)
if (Script.GetType() != CLIENT_SCRIPT)
if (!LoadScript(Script.GetScriptFileName()))
return false;
return true;
}
开发者ID:RAG20,项目名称:IV-Network,代码行数:9,代码来源:CSquirrelVM.cpp
示例16: mInterface
CNetwork::CNetwork() :
mInterface( 0 ),
mModule( 0 )
{
//ZeroMemory( mConnectionIndex, sizeof( mConnectionIndex ) );
//ZeroMemory( m_CheckSum, sizeof( m_CheckSum ) );
LoadScript();
}
开发者ID:xianyinchen,项目名称:LUNAPlus,代码行数:9,代码来源:Network.cpp
示例17: LoadScript
bool SceneLuaScript::Load(File* f)
{
std::string filename;
if (!f->GetDataLine(&filename))
{
f->ReportError("Expected lua script file name.");
return false;
}
return LoadScript(filename);
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:10,代码来源:SceneLuaScript.cpp
示例18: CastSpell
void Creature::OnPushToWorld()
{
if(proto)
{
set<uint32>::iterator itr = proto->start_auras.begin();
SpellEntry * sp;
for(; itr != proto->start_auras.end(); ++itr)
{
sp = dbcSpell.LookupEntry((*itr));
if(sp == 0) continue;
CastSpell(this, sp, 0);
}
}
LoadScript();
Unit::OnPushToWorld();
if(_myScriptClass)
_myScriptClass->OnLoad();
if(m_spawn)
{
if(m_aiInterface->m_formationLinkSqlId)
{
// add event
sEventMgr.AddEvent(this, &Creature::FormationLinkUp, m_aiInterface->m_formationLinkSqlId,
EVENT_CREATURE_FORMATION_LINKUP, 1000, 0,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
haslinkupevent = true;
}
if(m_spawn->channel_target_creature)
{
sEventMgr.AddEvent(this, &Creature::ChannelLinkUpCreature, m_spawn->channel_target_creature, EVENT_CREATURE_CHANNEL_LINKUP, 1000, 5, 0); // only 5 attempts
}
if(m_spawn->channel_target_go)
{
sEventMgr.AddEvent(this, &Creature::ChannelLinkUpGO, m_spawn->channel_target_go, EVENT_CREATURE_CHANNEL_LINKUP, 1000, 5, 0); // only 5 attempts
}
}
m_aiInterface->m_is_in_instance = (m_mapMgr->GetMapInfo()->type!=INSTANCE_NULL) ? true : false;
if (this->HasItems())
{
for(std::vector<CreatureItem>::iterator itr = m_SellItems->begin(); itr != m_SellItems->end(); ++itr)
{
if (itr->max_amount == 0)
itr->available_amount=0;
else if (itr->available_amount<itr->max_amount)
sEventMgr.AddEvent(this, &Creature::UpdateItemAmount, itr->itemid, EVENT_ITEM_UPDATE, VENDOR_ITEMS_UPDATE_TIME, 1,0);
}
}
}
开发者ID:AwkwardDev,项目名称:ascent_classic,代码行数:54,代码来源:Creature.cpp
示例19: PROFILE
void JavascriptInstance::Load()
{
PROFILE(JSInstance_Load);
if (!engine_)
CreateEngine();
if (sourceFile.isEmpty() && scriptRefs_.empty())
{
LogError("JavascriptInstance::Load: No script content to load!");
return;
}
// Can't specify both a file source and an Asset API source.
if (!sourceFile.isEmpty() && !scriptRefs_.empty())
{
LogError("JavascriptInstance::Load: Cannot specify both an local input source file and a list of script refs to load!");
return;
}
bool useAssetAPI = !scriptRefs_.empty();
size_t numScripts = useAssetAPI ? scriptRefs_.size() : 1;
// Determine based on code origin whether it can be trusted with system access or not
if (useAssetAPI)
{
trusted_ = true;
for(unsigned i = 0; i < scriptRefs_.size(); ++i)
trusted_ = trusted_ && scriptRefs_[i]->IsTrusted();
}
else // Local file: always trusted.
{
program_ = LoadScript(sourceFile);
trusted_ = true; // This is a file on the local filesystem. We are making an assumption nobody can inject untrusted code here.
// Actually, we are assuming the attacker does not know the absolute location of the asset cache locally here, since if he makes
// the client to load a script into local cache, he could use this code path to automatically load that unsafe script from cache, and make it trusted. -jj.
}
// Check the validity of the syntax in the input.
for (size_t i = 0; i < numScripts; ++i)
{
QString scriptSourceFilename = (useAssetAPI ? scriptRefs_[i]->Name() : sourceFile);
QString &scriptContent = (useAssetAPI ? scriptRefs_[i]->scriptContent : program_);
QScriptSyntaxCheckResult syntaxResult = engine_->checkSyntax(scriptContent);
if (syntaxResult.state() != QScriptSyntaxCheckResult::Valid)
{
LogError("Syntax error in script " + scriptSourceFilename + "," + QString::number(syntaxResult.errorLineNumber()) +
": " + syntaxResult.errorMessage());
// Delete our loaded script content (if any exists).
program_ == "";
}
}
}
开发者ID:360degrees-fi,项目名称:tundra,代码行数:53,代码来源:JavascriptInstance.cpp
示例20: LoadScript
int CEntityClass::GetEventCount()
{
if (m_pEventHandler)
return m_pEventHandler->GetEventCount();
if (!m_bScriptLoaded)
LoadScript(false);
if (!m_pEntityScript)
return 0;
return ((CEntityScript*)m_pEntityScript)->GetEventCount();
}
开发者ID:amrhead,项目名称:eaascode,代码行数:13,代码来源:EntityClass.cpp
注:本文中的LoadScript函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论