#include "object/text_object.hpp"
#include "object/scripted_object.hpp"
#include "object/display_effect.hpp"
+#include "object/player.hpp"
#include "scripting/sound.hpp"
#include "scripting/scripted_object.hpp"
#include "scripting/display_effect.hpp"
expose_object(scripted_object, scripted_object->get_name());
}
+ expose_object(static_cast<Scripting::Player*> (sector->player), "Tux");
TextObject* text_object = new TextObject();
sector->add_object(text_object);
Scripting::Text* text = static_cast<Scripting::Text*> (text_object);
ScriptInterpreter::run_script(std::istream& in, const std::string& sourcename,
bool remove_when_terminated)
{
- printf("Stackbefore:\n");
- print_squirrel_stack(v);
if(sq_compile(v, squirrel_read_char, &in, sourcename.c_str(), true) < 0)
throw Scripting::SquirrelError(v, "Couldn't parse script");
if(remove_when_terminated) {
remove_me();
}
- printf("ended.\n");
// remove closure from stack
sq_pop(v, 1);
}
- printf("After:\n");
- print_squirrel_stack(v);
}
void
std::auto_ptr<ScriptInterpreter> interpreter(
new ScriptInterpreter(workdir));
interpreter->register_sector(sector);
+
+ // load global default.nut file if it exists
+ //TODO: Load all .nut files from that directory
+ try {
+ std::string filename = "script/default.nut";
+ IFileStream in(filename);
+ interpreter->run_script(in, filename, false);
+ } catch(std::exception& e) {
+ // nothing
+ }
- // load default.nut file if it exists
+ // load world-specific default.nut file if it exists
try {
std::string filename = workdir + "/default.nut";
IFileStream in(filename);