(svn r9153) [NoAI] -Add: added a bit more code to the script to show how classes work (and that instances stay alive)
-Fix: gameLoop -> GameLoop
--- a/bin/ai/SQNoAI/main.sq Tue Mar 13 21:55:22 2007 +0000
+++ b/bin/ai/SQNoAI/main.sq Tue Mar 13 22:39:41 2007 +0000
@@ -1,6 +1,19 @@
-function gameLoop()
+class SQNoAI {
+ tick = 0;
+ function GameLoop();
+}
+
+function SQNoAI::GameLoop()
{
- print("gameLoop");
+ print("GameLoop " + this.tick);
+ this.tick++;
+}
+
+ai <- SQNoAI();
+
+function GameLoop()
+{
+ ai.GameLoop();
}
print("Called init");
--- a/src/ai/squirrel/squirrel.cpp Tue Mar 13 21:55:22 2007 +0000
+++ b/src/ai/squirrel/squirrel.cpp Tue Mar 13 22:39:41 2007 +0000
@@ -75,9 +75,9 @@
/* Go back to root-table */
sq_pushroottable(this->vm);
/* Find the function-name inside the script */
- sq_pushstring(this->vm,_SC("gameLoop"), -1);
+ sq_pushstring(this->vm,_SC("GameLoop"), -1);
if (!SQ_SUCCEEDED(sq_get(this->vm, -2))) {
- DEBUG(ai, 0, "[squirrel] Failed to run gameLoop");
+ DEBUG(ai, 0, "[squirrel] Failed to run GameLoop");
sq_settop(this->vm, top);
return;
}