# HG changeset patch # User truelight # Date 1173825581 0 # Node ID d30036300fe7266e95dcc0c6e63af529cad6c1be # Parent c3d08e0b1083d743f8fdbc6427ff1d71b47809b8 (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 diff -r c3d08e0b1083 -r d30036300fe7 bin/ai/SQNoAI/main.sq --- 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"); diff -r c3d08e0b1083 -r d30036300fe7 src/ai/squirrel/squirrel.cpp --- 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; }