stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src/clone selection.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/clone selection.c
Date: Wed, 19 Nov 2003 22:31:19 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/11/19 22:31:19

Modified files:
        src/clone      : selection.c 

Log message:
        Added SetGroupId and Selection

Patches:
Index: stratagus/src/clone/selection.c
diff -u stratagus/src/clone/selection.c:1.60 
stratagus/src/clone/selection.c:1.61
--- stratagus/src/clone/selection.c:1.60        Thu Nov 13 15:15:56 2003
+++ stratagus/src/clone/selection.c     Wed Nov 19 22:31:19 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: selection.c,v 1.60 2003/11/13 20:15:56 mr-russ Exp $
+//     $Id: selection.c,v 1.61 2003/11/20 03:31:19 jsalmon3 Exp $
 
 //@{
 
@@ -978,7 +978,7 @@
     char* ref;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: selection $Id: selection.c,v 1.60 2003/11/13 
20:15:56 mr-russ Exp $\n\n");
+    CLprintf(file, ";;; MODULE: selection $Id: selection.c,v 1.61 2003/11/20 
03:31:19 jsalmon3 Exp $\n\n");
 
     CLprintf(file, "(set-group-id! %d)\n", GroupId);
     CLprintf(file, "(selection %d '(", NumSelected);
@@ -1021,6 +1021,20 @@
     return old;
 }
 #elif defined(USE_LUA)
+local int CclSetGroupId(lua_State* l)
+{
+    int old;
+
+    if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+       lua_pushstring(l, "incorrect argument");
+       lua_error(l);
+    }
+    old = GroupId;
+    GroupId = lua_tonumber(l, 1);
+
+    lua_pushnumber(l, old);
+    return 1;
+}
 #endif
 
 /**
@@ -1049,6 +1063,35 @@
     return SCM_UNSPECIFIED;
 }
 #elif defined(USE_LUA)
+local int CclSelection(lua_State* l)
+{
+    int i;
+    int args;
+    int j;
+
+    if (lua_gettop(l) != 2 || !lua_isnumber(l, 1) || !lua_istable(l, 2)) {
+       lua_pushstring(l, "incorrect argument");
+       lua_error(l);
+    }
+    InitSelections();
+    NumSelected = lua_tonumber(l, 1);
+    i = 0;
+    args = luaL_getn(l, 2);
+    for (j = 0; j < args; ++j) {
+       const char* str;
+
+       lua_rawgeti(l, 2, j + 1);
+       if (!lua_isstring(l, -1)) {
+           lua_pushstring(l, "incorrect argument");
+           lua_error(l);
+       }
+       str = lua_tostring(l, -1);
+       lua_pop(l, 1);
+       Selected[i++] = UnitSlots[strtol(str + 1, NULL, 16)];
+    }
+
+    return 0;
+}
 #endif
 
 /**
@@ -1059,6 +1102,9 @@
 #if defined(USE_GUILE) || defined(USE_SIOD)
     gh_new_procedure1_0("set-group-id!", CclSetGroupId);
     gh_new_procedure2_0("selection", CclSelection);
+#elif defined(USE_LUA)
+    lua_register(Lua, "SetGroupId", CclSetGroupId);
+    lua_register(Lua, "Selection", CclSelection);
 #endif
 }
 




reply via email to

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