tuxjumps <- 2;
while(true) {
wait(0.8);
- Sound.play(\"jump\");
+ Sound.play(\"sounds/jump.ogg\");
if(tuxjumps >= 0) {
TUX.set_velocity(50, 300);
} else {
} else if(PENNY.get_animation() == \"jump\") {
PENNY.set_animation(\"dead\");
} else {
- Sound.play(\"grow\");
+ Sound.play(\"sounds/grow.ogg\");
PENNY.set_animation(\"stand\");
PENNY.set_velocity(0, 900);
}
sq_setprintfunc(v, printfunc);
// register supertux API
- register_functions(v, supertux_global_functions);
- register_classes(v, supertux_classes);
+ register_supertux_wrapper(v);
// expose some "global" objects
sound = new Scripting::Sound();
}
}
+static void _register_functions(HSQUIRRELVM v, WrappedFunction* functions)
+{
+ for(WrappedFunction* func = functions; func->name != 0; ++func) {
+ register_function(v, func->f, func->name);
+ }
+}
+
static void register_class(HSQUIRRELVM v, WrappedClass* wclass)
{
sq_pushstring(v, wclass->name, -1);
sq_newclass(v, false);
- register_functions(v, wclass->functions);
- register_constants(v, wclass->int_consts);
- register_constants(v, wclass->float_consts);
- register_constants(v, wclass->string_consts);
+ _register_functions(v, wclass->functions);
+ _register_constants(v, wclass->int_consts);
+ _register_constants(v, wclass->float_consts);
+ _register_constants(v, wclass->string_consts);
if(sq_createslot(v, -3) < 0) {
std::stringstream msg;
void register_functions(HSQUIRRELVM v, WrappedFunction* functions)
{
sq_pushroottable(v);
- for(WrappedFunction* func = functions; func->name != 0; ++func) {
- register_function(v, func->f, func->name);
- }
+ _register_functions(v, functions);
sq_pop(v, 1);
}
}
template<typename T>
-void register_constants(HSQUIRRELVM v, WrappedConstant<T>* constants)
+void _register_constants(HSQUIRRELVM v, WrappedConstant<T>* constants)
{
- sq_pushroottable(v);
- for(WrappedConstant<T>* c = constants; *constants->name != 0; ++c) {
+ for(WrappedConstant<T>* c = constants; c->name != 0; ++c) {
sq_pushstring(v, c->name, -1);
push_value(v, c->value);
if(sq_createslot(v, -3) < 0) {
throw SquirrelError(v, msg.str());
}
}
+}
+
+template<typename T>
+void register_constants(HSQUIRRELVM v, WrappedConstant<T>* constants)
+{
+ sq_pushroottable(v);
+ _register_constants(v, constants);
sq_pop(v, 1);
}