/* * compile script from path * * @param script file name */ SQInteger emoRuntimeCompile(HSQUIRRELVM v) { if (sq_gettype(v, 2) == OT_STRING) { const SQChar *fname; sq_tostring(v, 2); sq_getstring(v, -1, &fname); sq_poptop(v); // check if the file type exists if (sq_gettype(v, 3) == OT_INTEGER) { SQInteger fileType = TYPE_ASSET; sq_getinteger(v, 3, &fileType); if (fileType == TYPE_ASSET) { // load script from resource loadScriptFromAsset((char*) fname); } else if (fileType == TYPE_DOCUMENT) { // load script from user document directory loadScriptFromUserDocument(fname); } else { // load script from path loadScript(fname); } } else { // load script from path loadScript(fname); } } return 0; }
GM_SettingsScriptInfo::GM_SettingsScriptInfo(GM_Script* script, QWidget* parent) : QDialog(parent) , ui(new Ui::GM_SettingsScriptInfo) , m_script(script) { ui->setupUi(this); loadScript(); connect(m_script, SIGNAL(scriptChanged()), this, SLOT(loadScript())); connect(ui->editInEditor, SIGNAL(clicked()), this, SLOT(editInTextEditor())); }
void gep::ScriptingManager::loadAllRegisteredScripts() { for (auto& scriptFileName : m_scriptsToLoad) { loadScript(scriptFileName, LoadOptions::None); } }
void ScriptManager::findScripts() //SLOT { const QStringList allFiles = kapp->dirs()->findAllResources( "data", "amarok/scripts/*", true ); // Add found scripts to listview: { foreach( allFiles ) if( QFileInfo( *it ).isExecutable() ) loadScript( *it ); } // Handle auto-run: KConfig* const config = amaroK::config( "ScriptManager" ); const QStringList runningScripts = config->readListEntry( "Running Scripts" ); { foreach( runningScripts ) if( m_scripts.contains( *it ) ) { debug() << "Auto-running script: " << *it << endl; m_gui->listView->setCurrentItem( m_scripts[*it].li ); slotRunScript(); } } m_gui->listView->setCurrentItem( m_gui->listView->firstChild() ); slotCurrentChanged( m_gui->listView->currentItem() ); }
int main(int argc, char** argv) { if(!parseOption(argc, argv)) { fprintf(stderr, "failed to parse option\n"); return 1; } BCCScriptRef script; if((script = loadScript()) == NULL) { fprintf(stderr, "failed to load source\n"); return 2; } #if 0 if(printTypeInformation && !reflection(script, stderr)) { fprintf(stderr, "failed to retrieve type information\n"); return 3; } #endif printPragma(script); if(printListing && !disassemble(script, stderr)) { fprintf(stderr, "failed to disassemble\n"); return 5; } if(runResults && !runMain(script, argc, argv)) { fprintf(stderr, "failed to execute\n"); return 6; } return 0; }
void Script::o_loadscript() { Common::String filename; char c; while ((c = readScript8bits())) { filename += c; } debugScript(1, true, "LOADSCRIPT %s", filename.c_str()); // Just 1 level of sub-scripts are allowed if (_savedCode) { error("Tried to load a level 2 sub-script"); } // Save the current code _savedCode = _code; _savedCodeSize = _codeSize; _savedInstruction = _currentInstruction; // Save the filename of the current script _savedScriptFile = _scriptFile; // Load the sub-script if (!loadScript(filename)) { error("Couldn't load sub-script %s", filename.c_str()); } // Save the current stack top _savedStacktop = _stacktop; // Save the variables memcpy(_savedVariables, _variables + 0x107, 0x180); }
void ScriptConsole::createDialogContent() { ui->setupUi(dialog); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); highlighter = new StelScriptSyntaxHighlighter(ui->scriptEdit->document()); ui->includeEdit->setText(StelFileMgr::getInstallationDir() + "/scripts"); ui->quickrunCombo->addItem(q_("quickrun...")); ui->quickrunCombo->addItem(q_("selected text")); ui->quickrunCombo->addItem(q_("clear text")); ui->quickrunCombo->addItem(q_("clear images")); ui->quickrunCombo->addItem(q_("natural")); ui->quickrunCombo->addItem(q_("starchart")); connect(ui->scriptEdit, SIGNAL(cursorPositionChanged()), this, SLOT(rowColumnChanged())); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); connect(ui->loadButton, SIGNAL(clicked()), this, SLOT(loadScript())); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveScript())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearButtonPressed())); connect(ui->preprocessSSCButton, SIGNAL(clicked()), this, SLOT(preprocessScript())); connect(ui->runButton, SIGNAL(clicked()), this, SLOT(runScript())); connect(ui->stopButton, SIGNAL(clicked()), &StelApp::getInstance().getScriptMgr(), SLOT(stopScript())); connect(ui->includeBrowseButton, SIGNAL(clicked()), this, SLOT(includeBrowse())); connect(ui->quickrunCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(quickRun(int))); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptRunning()), this, SLOT(scriptStarted())); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptStopped()), this, SLOT(scriptEnded())); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptDebug(const QString&)), this, SLOT(appendLogLine(const QString&))); connect(&StelApp::getInstance().getScriptMgr(), SIGNAL(scriptOutput(const QString&)), this, SLOT(appendOutputLine(const QString&))); ui->tabs->setCurrentIndex(0); ui->scriptEdit->setFocus(); }
int main(int argc, char *argv[]) { auto kampf = Kampf(enumInitType::Basic); auto lua = kampf.getLua(); lua->loadScript("kampf_render.lua"); return 0; }
Monster::Monster(MonsterClass *specy): Being(OBJECT_MONSTER), mSpecy(specy), mTargetListener(&monsterTargetEventDispatch), mOwner(NULL), mCurrentAttack(NULL) { LOG_DEBUG("Monster spawned! (id: " << mSpecy->getId() << ")."); setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER); /* * Initialise the attribute structures. */ const AttributeManager::AttributeScope &mobAttr = attributeManager->getAttributeScope(MonsterScope); for (AttributeManager::AttributeScope::const_iterator it = mobAttr.begin(), it_end = mobAttr.end(); it != it_end; ++it) { mAttributes.insert(std::pair< unsigned int, Attribute > (it->first, Attribute(*it->second))); } /* * Set the attributes to the values defined by the associated monster * class with or without mutations as needed. */ int mutation = specy->getMutation(); for (AttributeMap::iterator it2 = mAttributes.begin(), it2_end = mAttributes.end(); it2 != it2_end; ++it2) { double attr = 0.0f; if (specy->hasAttribute(it2->first)) { attr = specy->getAttribute(it2->first); setAttribute(it2->first, mutation ? attr * (100 + (rand()%(mutation << 1)) - mutation) / 100.0 : attr); } } setSize(specy->getSize()); setGender(specy->getGender()); // Set positions relative to target from which the monster can attack int dist = specy->getAttackDistance(); mAttackPositions.push_back(AttackPosition(dist, 0, LEFT)); mAttackPositions.push_back(AttackPosition(-dist, 0, RIGHT)); mAttackPositions.push_back(AttackPosition(0, -dist, DOWN)); mAttackPositions.push_back(AttackPosition(0, dist, UP)); // Load default script loadScript(specy->getScript()); }
bool ScriptEvent::configureRaidEvent(xmlNodePtr eventNode) { if(!RaidEvent::configureRaidEvent(eventNode)) return false; std::string scriptsName = Raids::getInstance()->getScriptBaseName(); if(!m_interface.loadDirectory(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/lib/")))) std::cout << "[Warning - ScriptEvent::configureRaidEvent] Cannot load " << scriptsName << "/lib/" << std::endl; std::string strValue; if(readXMLString(eventNode, "file", strValue)) { if(!loadScript(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/scripts/" + strValue)), true)) { std::cout << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script file (" << strValue << ")." << std::endl; return false; } } else if(!parseXMLContentString(eventNode->children, strValue) && !loadBuffer(strValue)) { std::cout << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script buffer." << std::endl; return false; } return true; }
void CGEEngine::movie(const char *ext) { assert(ext); if (_quitFlag) return; char fn[12]; sprintf(fn, "CGE.%s", (*ext == '.') ? ext +1 : ext); if (_resman->exist(fn)) { loadScript(fn); expandSprite(_vga->_spareQ->locate(999)); feedSnail(_vga->_showQ->locate(999), kTake); _vga->_showQ->append(_mouse); _keyboard->setClient(_sys); while (!_commandHandler->idle() && !_quitFlag) mainLoop(); _keyboard->setClient(NULL); _commandHandler->addCommand(kCmdClear, -1, 0, NULL); _commandHandlerTurbo->addCommand(kCmdClear, -1, 0, NULL); _vga->_showQ->clear(); _vga->_spareQ->clear(); } }
bool ScriptApiBase::loadMod(const std::string &script_path, const std::string &mod_name, std::string *error) { ModNameStorer mod_name_storer(getStack(), mod_name); return loadScript(script_path, error); }
void ScriptablePrivate::loadScriptEngine() { if(_scriptLoaded || !_parent) return; _scriptLoaded = true; QStringList scriptList; // load scripts by class heirarchy name const QMetaObject *m = _parent->metaObject(); while(m) { scriptList.prepend(m->className()); m = m->superClass(); } // load scripts by object name QStringList parts = _parent->objectName().split(" "); QStringList search_parts; QString oName; while(!parts.isEmpty()) { search_parts.append(parts.takeFirst()); oName = search_parts.join(" "); scriptList.append(oName); } scriptList.removeDuplicates(); for (int i = 0; i < scriptList.size(); ++i) loadScript(scriptList.at(i)); }
bool ScriptEditorWidget::setRunning(bool run) { if (run && isModified() && !save()) { return false; } if (_scriptEngine != NULL) { disconnect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged); disconnect(_scriptEngine, &ScriptEngine::update, this, &ScriptEditorWidget::onScriptModified); disconnect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); } auto scriptEngines = DependencyManager::get<ScriptEngines>(); if (run) { const QString& scriptURLString = QUrl(_currentScript).toString(); // Reload script so that an out of date copy is not retrieved from the cache _scriptEngine = scriptEngines->loadScript(scriptURLString, true, true, false, true); connect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged); connect(_scriptEngine, &ScriptEngine::update, this, &ScriptEditorWidget::onScriptModified); connect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); } else { connect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); const QString& scriptURLString = QUrl(_currentScript).toString(); scriptEngines->stopScript(scriptURLString); _scriptEngine = NULL; } _console->setScriptEngine(_scriptEngine); return true; }
void enblt_load(EnemyBullet *blt, std::string type, float srcx, float srcy, float tgtx, float tgty) { std::string filename = "enblt_" + type + ".lua"; loadScript(&blt->script, filename); regFunction(&blt->script, "init", enblt_init); regFunction(&blt->script, "updatePos", enblt_getPos); runFunction(&blt->script, "start", srcx, srcy, tgtx, tgty); enblt_loadValues(blt); }
void CServer::reloadScript(const char *script) { assert(_lua && "No se ha hecho la inicialización de lua"); if (loadScript(script, false) && executeLastLoadScript(script)) showMessage("Fichero \"" + std::string(script) + "\" cargado y ejecutado correctamente"); } // reloadScript
void ScriptEngine::loadScripts(){ DEBUG_BLOCK QStringList enabled = QString(QByteArray::fromBase64(WSGET(WS_APP_ENABLED_SCRIPTS).toLatin1())).split("\n"); for (const auto &s : enabled) loadScript(s); }
void ScriptManager::registerElement(Scripted* scripted, string script) { active = this; lastInsertedRef++; list.insert(std::pair<int, Scripted*>(lastInsertedRef, scripted)); scripted->luaRef = loadScript(script, scripted->getPath(), lastInsertedRef); cout << "Set luaref to " << scripted->luaRef << " in " << script << std::endl; scripted->name = script.substr(0,script.find_last_of('.')); }
//-------------------------------------------------------------- void ofApp::keyPressed(int key) { if(key == 'r') { lua.scriptExit(); lua.init(true); // stop on error loadScript(); return; } lua.scriptKeyPressed(key); }
void loadScriptLibrary() { StringVectorPtr names = ResourceGroupManager::getSingleton().listResourceNames("DefaultLuaScripts"); for(int i = 0; i < names->size(); ++i) { loadScript(names->at(i)); } names.setNull(); }
void SmsScriptsManager::loadScripts(const QDir &dir) { if (!dir.exists()) return; QFileInfoList gateways = dir.entryInfoList(QStringList("gateway-*.js")); foreach (const QFileInfo &gatewayFile, gateways) loadScript(gatewayFile); }
void CGE2Engine::resetGame() { _busyPtr = nullptr; busy(false); _spare->clear(); _vga->_showQ->clear(); loadScript("CGE.INI", true); delete _infoLine; _infoLine = new InfoLine(this, kInfoW); }
void plblt_load(PlayerBullet *blt, std::string type, float srcx, float srcy, float tgtx, float tgty) { std::string filename = "plblt_" + type + ".lua"; loadScript(&blt->script, filename); regFunction(&blt->script, "init", plblt_init); regFunction(&blt->script, "updatePos", plblt_getPos); regFunction(&blt->script, "kill", plblt_kill); runFunction(&blt->script, "start", srcx, srcy, tgtx, tgty); plblt_loadValues(blt); }
void ScriptDataEngine::parse(sofa::core::objectmodel::BaseObjectDescription *arg) { Inherit1::parse(arg); // load & bind script loadScript(); // call script notifications... //script_onLoaded( down_cast<simulation::Node>(getContext()) ); //script_createGraph( down_cast<simulation::Node>(getContext()) ); }
int main(int argc, char *argv[]) { auto kampf = Kampf(enumInitType::Basic); auto lua = kampf.getLua(); //include scripts folder from kampf lua->addPath("../scripts/engine/?.lua"); lua->loadScript("pong.lua"); return 0; }
// NOTE: The load() command is similar to the include() command except that it loads the script // as a stand-alone script. To accomplish this, the ScriptEngine class just emits a signal which // the Application or other context will connect to in order to know to actually load the script void ScriptEngine::load(const QString& loadFile) { if (_stoppingAllScripts) { qCDebug(scriptengine) << "Script.load() while shutting down is ignored... " << "loadFile:" << loadFile << "parent script:" << getFilename(); return; // bail early } QUrl url = resolvePath(loadFile); emit loadScript(url.toString(), false); }
void loadMenu(std::string menu) { clearMenu(); danmakux.menuChoice = 0; if (danmakux.level.running) closeScript(&danmakux.level); std::string menufile = menu + ".lua"; loadScript(&danmakux.menu, menufile); regFunction(&danmakux.menu, "addMenuChoice", addMenuItem); regFunction(&danmakux.menu, "setBGM", setBGM); regFunction(&danmakux.menu, "setBG", setBG); runFunction(&danmakux.menu, "start"); }
void LuaCommands::registerCommands() { std::cout << "Trying to load all scripts in " << scriptsPath_ << std::endl; if (boost::filesystem::exists(scriptsPath_) && boost::filesystem::is_directory(scriptsPath_)) { std::vector<boost::filesystem::path> files; copy(boost::filesystem::directory_iterator(scriptsPath_), boost::filesystem::directory_iterator(), std::back_inserter(files)); foreach (boost::filesystem::path file, files) { if (boost::filesystem::is_regular_file(file) && file.extension() == ".lua") { loadScript(file); } } }
void CServer::reloadScripts() { assert(_lua && "No se ha hecho la inicialización de lua"); for (TScriptList::iterator it = _scriptList.begin(); it != _scriptList.end(); it++) { if (loadScript(it._Ptr->_Myval, false) && executeLastLoadScript(it._Ptr->_Myval)) showMessage("Fichero \"" + std::string(it._Ptr->_Myval) + "\" cargado y ejecutado correctamente"); } } // reloadScripts
void TagEditor::createActions(){ connect(LoadScriptButton,SIGNAL(clicked()),this,SLOT(loadScript())); connect(SaveScriptButton,SIGNAL(clicked()),this,SLOT(saveScript())); connect(RunScriptButton,SIGNAL(clicked()),this, SLOT(runScript())); QAction* searchOnlineAction = new QAction(tr("Search for selected file/album in online musicdatabases..."), this); searchOnlineAction->setShortcut(tr("Ctrl+S")); connect(searchOnlineAction, SIGNAL(triggered()), this, SLOT(searchOnline())); QAction* searchForFilesAction = new QAction(tr("Search for files to add to workspace..."), this); //searchForFilesAction->setShortcut(tr("Ctrl+S")); connect(searchForFilesAction, SIGNAL(triggered()), this, SLOT(searchAndAddFiles())); TreeView->setContextMenuPolicy(Qt::ActionsContextMenu); TreeView->addAction(searchOnlineAction); TreeView->addAction(searchForFilesAction); connect( TreeView, SIGNAL( expanded( const QModelIndex & ) ), this, SLOT( resizeColumn() ) ); connect( TreeView, SIGNAL( collapsed( const QModelIndex & ) ), this, SLOT( resizeColumn() ) ); //connect( TreeWidget_, SIGNAL( currentRowChanged( int ) ), this, SLOT( showTagInfo(int) ) ); connect( TreeWidget_, SIGNAL( itemSelectionChanged() ), this, SLOT( showTagInfo() ) ); connect( AddButton, SIGNAL( clicked() ), this, SLOT(addFiles() ) ); connect( RemoveButton, SIGNAL( clicked() ), this, SLOT(removeFiles() ) ); connect( ClearButton, SIGNAL( clicked() ), this, SLOT(removeAllFiles() ) ); connect( SaveButton, SIGNAL( clicked() ), this, SLOT(saveTag() ) ); connect( ChooseDirButton, SIGNAL( clicked() ), this, SLOT(chooseDir() ) ); connect( actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) ); connect( actionRewriteTag, SIGNAL( triggered() ), this, SLOT( rewriteTag() ) ); connect( actionRenameFiles, SIGNAL( triggered() ), this, SLOT( renameFiles() ) ); connect( actionReplaceTags, SIGNAL( triggered() ), this, SLOT( replaceTags() ) ); connect( actionSerialize, SIGNAL( triggered() ), this, SLOT( serialize() ) ); connect( actionClearTags, SIGNAL( triggered() ), this, SLOT( clearTags() ) ); //connect( actionRemoveFrames, SIGNAL( triggered() ), this, SLOT( removeFrames() ) ); //styles QSignalMapper *styleMapper = new QSignalMapper(this); QStringList styles = QStyleFactory::keys(); for(int i=0;i<styles.size();i++){ QAction *a = new QAction(styles[i],menuStyle); a->setCheckable(true); connect(a, SIGNAL(triggered()), styleMapper, SLOT(map())); styleMapper->setMapping(a, styles[i]); menuStyle->addAction(a); } menuStyle->addSeparator(); QAction *actionCustomStyleSheet = new QAction("Custom...",menuStyle); actionCustomStyleSheet->setCheckable(true); connect(actionCustomStyleSheet, SIGNAL(triggered()), this, SLOT(openStyleSheet())); menuStyle->addAction( actionCustomStyleSheet ); connect(styleMapper, SIGNAL(mapped(const QString &)), this, SLOT(setGUIStyle(const QString &))); }