stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/ui interface.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src/ui interface.c
Date: 15 Dec 2003 08:37:22 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       03/12/15 08:37:22

Modified files:
        src/ui         : interface.c 

Log message:
        Added 'ai me' cheat for Lua

Patches:
Index: stratagus/src/ui/interface.c
diff -u stratagus/src/ui/interface.c:1.146 stratagus/src/ui/interface.c:1.147
--- stratagus/src/ui/interface.c:1.146  Sun Dec 14 15:31:11 2003
+++ stratagus/src/ui/interface.c        Mon Dec 15 08:37:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: interface.c,v 1.146 2003/12/14 04:31:11 jsalmon3 Exp $
+//     $Id: interface.c,v 1.147 2003/12/14 21:37:21 jsalmon3 Exp $
 
 //@{
 
@@ -1113,18 +1113,34 @@
 #elif defined(USE_LUA)
     int ret;
 
-    lua_pushstring(Lua, "HandleCheats");
-    lua_gettable(Lua, LUA_GLOBALSINDEX);
-    lua_pushstring(Lua, input);
-    LuaCall(1, 0);
-    ret = lua_gettop(Lua);
-    if (lua_gettop(Lua) == 1) {
-       ret = LuaToBoolean(Lua, 1);
-       lua_pop(Lua, 1);
+    if (!strcmp(input, "ai me")) {
+       if (ThisPlayer->AiEnabled) {
+           ThisPlayer->AiEnabled = 0;
+           ThisPlayer->Type = PlayerPerson;
+           SetMessage("AI is off, Normal Player");
+       } else {
+           ThisPlayer->AiEnabled = 1;
+           ThisPlayer->Type = PlayerComputer;
+           if (!ThisPlayer->Ai) {
+               AiInit(ThisPlayer);
+           }
+           SetMessage("I'm the BORG, resistance is futile!");
+       }
+       ret = 1;
     } else {
-       lua_pushstring(Lua, "HandleCheats must return a boolean");
-       lua_error(Lua);
-       ret = 0;
+       lua_pushstring(Lua, "HandleCheats");
+       lua_gettable(Lua, LUA_GLOBALSINDEX);
+       lua_pushstring(Lua, input);
+       LuaCall(1, 0);
+       ret = lua_gettop(Lua);
+       if (lua_gettop(Lua) == 1) {
+           ret = LuaToBoolean(Lua, 1);
+           lua_pop(Lua, 1);
+       } else {
+           lua_pushstring(Lua, "HandleCheats must return a boolean");
+           lua_error(Lua);
+           ret = 0;
+       }
     }
     return ret;
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]