]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.cxx
Add an srand() function to nasal (hooked into sg_srandom_time()).
[flightgear.git] / src / Scripting / NasalSys.cxx
index 41de581a649d9772ce13b47bfdbe7c393b887401..4bbe082958842bf1ce309034ffd3f3a9e9b40f91 100644 (file)
@@ -288,6 +288,12 @@ static naRef f_rand(naContext c, naRef me, int argc, naRef* args)
     return naNum(sg_random());
 }
 
+static naRef f_srand(naContext c, naRef me, int argc, naRef* args)
+{
+    sg_srandom_time();
+    return naNum(0);
+}
+
 // Wrapper function for screenPrint
 static naRef f_screenPrint(naContext c, naRef me, int argc, naRef* args)
 {
@@ -327,6 +333,7 @@ static struct { char* name; naCFunction func; } funcs[] = {
     { "_cmdarg",  f_cmdarg },
     { "_interpolate",  f_interpolate },
     { "rand",  f_rand },
+    { "srand",  f_srand },
     { "screenPrint", f_screenPrint },
     { "directory", f_directory },
     { 0, 0 }