From 6fc9745be81b20549ec66d9f307958a628115e8e Mon Sep 17 00:00:00 2001
From: jsalmon3 <>
Date: Sat, 13 Mar 2004 15:26:55 +0000
Subject: [PATCH] Added CclSyncRand

---
 src/stratagus/script.cpp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/stratagus/script.cpp b/src/stratagus/script.cpp
index a795e4f23..d60205c7b 100644
--- a/src/stratagus/script.cpp
+++ b/src/stratagus/script.cpp
@@ -937,6 +937,20 @@ local int CclGetStratagusLibraryPath(lua_State* l)
 	return 1;
 }
 
+/**
+**  Get a value from the Stratagus syncronized random number generator.
+*/
+local int CclSyncRand(lua_State* l)
+{
+	if (lua_gettop(l) != 1) {
+		lua_pushstring(l, "incorrect argument");
+		lua_error(l);
+	}
+
+	lua_pushnumber(l, SyncRand() % (int)LuaToNumber(l, -1));
+	return 1;
+}
+
 /*............................................................................
 ..  Tables
 ............................................................................*/
@@ -1175,7 +1189,7 @@ global void ScriptProxyTypeInitBlock(ScriptProxyType* type)
 }
 
 /**
-** 	Get a value from the Stratagus syncronized random number generator.
+**  Get a value from the Stratagus syncronized random number generator.
 */
 local int ScriptSyncRand(lua_State* l)
 {
@@ -1390,6 +1404,8 @@ global void InitCcl(void)
 	lua_register(Lua, "GetStratagusHomePath", CclGetStratagusHomePath);
 	lua_register(Lua, "GetStratagusLibraryPath",
 		CclGetStratagusLibraryPath);
+
+	lua_register(Lua, "SyncRand", CclSyncRand);
 }
 
 /**