--- /dev/null
+;; Generated by Flexlay Editor
+(supertux-level
+ (version 2)
+ (name (_ "Scripting Test"))
+ (author "Matthias Braun")
+ (sector
+ (name "main")
+ (music "salcon.mod")
+ (gravity 10.000000)
+ (init-script "wait(2);
+print(\"Hello from the script\\n\");
+")
+ (tilemap
+ (layer "background")
+ (solid #f)
+ (speed 1.000000)
+ (width 25)
+ (height 20)
+ (tiles
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 124 210 210 125 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 124 210 210 125 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 124 210 210 125 0 0 0 0 0 0 0 0 0
+ 0 0 124 125 0 0 0 0 0 0 0 0 124 210 210 125 0 0 0 0 0 0 0 0 0
+ 0 0 124 125 0 0 0 0 0 0 0 0 124 210 210 125 0 0 124 125 0 0 0 0 0
+ 0 0 124 125 0 0 25 0 0 0 24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 0 0 406 407 408 409 122 123 0 0 0 0 0
+ 0 403 404 0 0 0 0 0 0 0 0 0 0 0 410 451 412 413 0 0 0 0 0 0 0
+ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
+ 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14
+ 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
+ 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
+ 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
+ ))
+ (tilemap
+ (layer "foreground")
+ (solid #f)
+ (speed 1.000000)
+ (width 25)
+ (height 20)
+ (tiles
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 402 403 404 405 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 406 407 408 409 0 0 0 0 0 0 0
+ 0 403 404 0 0 0 0 0 0 0 0 0 0 0 410 411 412 413 0 0 0 0 0 0 0
+ 0 407 408 0 0 0 0 0 0 0 0 0 0 0 414 423 416 425 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ ))
+ (camera
+ (mode "normal")
+ )
+
+ (background
+ (image "semi_arctic.jpg")
+ (speed 0.500000)
+ )
+ (spawnpoint (name "main") (x 320) (y 384))
+ (particles-snow
+ )
+ )
+ )
+
+;; EOF ;;
#include <stdexcept>
#include <iostream>
#include <fstream>
+#include <sstream>
#include <stdexcept>
#include "sector.h"
#include "badguy/spike.h"
#include "trigger/sequence_trigger.h"
#include "player_status.h"
+#include "scripting/script_interpreter.h"
//#define USE_GRID
Sector::Sector()
: gravity(10), player(0), solids(0), camera(0),
- currentmusic(LEVEL_MUSIC)
+ interpreter(0), currentmusic(LEVEL_MUSIC)
{
song_title = "Mortimers_chipdisko.mod";
player = new Player(&player_status);
spawnpoint_lisp->get("x", sp->pos.x);
spawnpoint_lisp->get("y", sp->pos.y);
spawnpoints.push_back(sp);
+ } else if(token == "init-script") {
+ iter.value()->get(init_script);
} else {
GameObject* object = parse_object(token, *(iter.lisp()));
if(object) {
} else {
activate(sp->pos);
}
+
+ // Run init script
+ if(init_script != "") {
+ try {
+ // TODO we should keep the interpreter across sessions (or some variables)
+ // so that you can store information across levels/sectors...
+ delete interpreter;
+ interpreter = 0;
+ interpreter = new ScriptInterpreter();
+ std::string sourcename = std::string("Sector(") + name + ") - init";
+ std::istringstream in(init_script);
+ printf("Load script.\n");
+ interpreter->load_script(in, sourcename);
+ printf("run script.\n");
+ interpreter->run_script();
+ } catch(std::exception& e) {
+ std::cerr << "Couldn't execute init script: " << e.what() << "\n";
+ }
+ }
}
void