Beispiel #1
0
/**
 * @brief Constructor.
 * @param enemy the enemy to control with this script
 */
EnemyScript::EnemyScript(CustomEnemy& enemy):
  Script(MAIN_API | GAME_API | MAP_API | ENEMY_API),
  game(enemy.get_game()),
  enemy(enemy) {

  std::string script_name = std::string("enemies/" + enemy.get_breed());
  load_if_exists(script_name);
}
Beispiel #2
0
/**
 * @brief Initializes the Lua context and loads the script from a file.
 *
 * The script file must exist.
 *
 * @param script_name name of a Lua script file (without extension)
 */
void Script::load(const std::string &script_name) {

  load_if_exists(script_name);
  Debug::check_assertion(is_loaded(),
      StringConcat() << "Cannot load script '" << script_name << "'");
}