Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

on spawn a small description of the spawn type is printed

git-svn-id: svn://gakman.com/gravit/trunk@259 60970b36-f649-e149-802f-859a9d0a703e
  • Loading branch information...
commit f3865f6504dd2bccef6fb90c318c5a8eab1deb48 1 parent addf0ec
gak authored
View
24 command.c
@@ -361,6 +361,16 @@ void cmdStop(char *arg) {
}
+void cmdSpawnCancel(void) {
+
+ conAdd(LERR, "%s", lua_tostring(state.lua, -1));
+ cleanMemory();
+ state.currentlySpawning = 0;
+ state.particleCount = 0;
+ luaFree();
+
+}
+
void cmdSpawn(char *arg) {
char *scriptName;
@@ -400,14 +410,16 @@ void cmdSpawn(char *arg) {
scriptFile = va("spawn/%s.gravitspawn", scriptName);
luaExecute(scriptFile);
+ lua_getglobal(state.lua, "describe");
+ if (lua_pcall(state.lua, 0, 1, 0)) {
+ conAdd(LERR, "Could not execute spawn function in %s", scriptFile);
+ cmdSpawnCancel();
+ return;
+ }
lua_getglobal(state.lua, "spawn");
if (lua_pcall(state.lua, 0, 1, 0)) {
- conAdd(LERR, "Could not execute spawn function in %s", scriptFile);
- conAdd(LERR, "%s", lua_tostring(state.lua, -1));
- cleanMemory();
- state.currentlySpawning = 0;
- state.particleCount = 0;
- luaFree();
+ conAdd(LERR, "Could not execute spawn function in %s", scriptFile);
+ cmdSpawnCancel();
return;
}
View
2  main.c
@@ -197,7 +197,7 @@ int init(int argc, char *argv[]) {
return 0;
if (!state.dontExecuteDefaultScript)
- configRead("gravit.cfg");
+ configRead("gravit.cfg", 0);
#ifndef NO_GUI
View
6 spawn/binary-galaxy.gravitspawn
@@ -1,5 +1,9 @@
-require("scripts/functions.lua")
+require("spawn/functions.lua")
+
+function describe()
+ log("Two galaxies rotating around each other")
+end
function spawn()
View
4 spawn/default.gravitspawn
@@ -1,8 +1,8 @@
-scripts = { "one-galaxy", "binary-galaxy", "many-galaxy", "snake", "loops" }
+scripts = { "one-galaxy", "binary-galaxy", "many-galaxy", "snake", "loops", "dust" }
n = table.getn(scripts)
r = math.random(1,n)
log("Spawining " .. scripts[r])
spawn = nil
-require ("scripts/" .. scripts[r] .. ".lua")
+require ("spawn/" .. scripts[r] .. ".gravitspawn")
View
12 spawn/dust.gravitspawn
@@ -1,10 +1,14 @@
-require("scripts/functions.lua")
+require("spawn/functions.lua")
+
+function describe()
+
+ log("A few massive particles and a ball of relatevely ligher particles with random veclocities")
+
+end
function spawn()
- log("mooo!")
-
local massiveparticles = randomint(1, 3)
local smallrange = randomfloat(100, 10000)
local bigrange = randomfloat(0, 10000)
@@ -15,8 +19,6 @@ function spawn()
for i=0,spawnparticles-1 do
- log(i)
-
if (i < massiveparticles) then
pos = randomrange(bigrange)
vel = v(0,0,0)
View
8 spawn/loops.gravitspawn
@@ -1,5 +1,11 @@
-require("scripts/functions.lua")
+require("spawn/functions.lua")
+
+function describe()
+
+ log("Random looping patterns of particles")
+
+end
function spawn()
View
6 spawn/many-galaxy.gravitspawn
@@ -1,4 +1,8 @@
-require("scripts/functions.lua")
+require("spawn/functions.lua")
+
+function describe()
+ log("Many sphere and spiral galaxies")
+end
function spawn()
-- work out a number of galaxies based on spawnparticles
View
6 spawn/one-galaxy.gravitspawn
@@ -1,4 +1,8 @@
-require("scripts/functions.lua")
+require("spawn/functions.lua")
+
+function describe()
+ log("One spiral galaxy")
+end
function spawn()
particlemassmin = randomfloat(1,1000)
View
7 spawn/snake.gravitspawn
@@ -1,6 +1,11 @@
-require("scripts/functions.lua")
+require("spawn/functions.lua")
+function describe()
+ log("Random shaped string of particles")
+end
+
+
function spawn()
curveness = randomfloat(0, 0.5)
Please sign in to comment.
Something went wrong with that request. Please try again.