-// $Id: main.cpp 3275 2006-04-09 00:32:34Z sommer $
-//
+// $Id$
+//
// SuperTux
-// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "timer.hpp"
#include "console.hpp"
+#include "log.hpp"
#include "scripting/wrapper.hpp"
#include "scripting/wrapper_util.hpp"
#include "scripting/squirrel_error.hpp"
ScriptManager::ScriptManager()
: parent(NULL)
{
- vm = sq_open(1024);
+ vm = sq_open(64);
if(vm == 0)
throw std::runtime_error("Couldn't initialize squirrel vm");
sq_setforeignptr(vm, (SQUserPointer) this);
sq_setprintfunc(vm, printfunc);
// register default error handlers
sqstd_seterrorhandlers(vm);
+
+ // try to load default script
+ try {
+ std::string filename = "scripts/default.nut";
+ IFileStream stream(filename);
+ Scripting::compile_and_run(vm, stream, filename);
+ } catch(std::exception& e) {
+ log_warning << "Couldn't load default.nut: " << e.what() << std::endl;
+ }
}
ScriptManager::ScriptManager(ScriptManager* parent)
HSQUIRRELVM
ScriptManager::create_thread(bool leave_thread_on_stack)
{
- HSQUIRRELVM new_vm = sq_newthread(vm, 1024);
+ HSQUIRRELVM new_vm = sq_newthread(vm, 64);
if(new_vm == NULL)
throw SquirrelError(vm, "Couldn't create new VM");
sq_setforeignptr(new_vm, (SQUserPointer) this);