Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
on spawn a small description of the spawn type is printed
Browse files Browse the repository at this point in the history
git-svn-id: svn://gakman.com/gravit/trunk@259 60970b36-f649-e149-802f-859a9d0a703e
  • Loading branch information
gak committed May 28, 2005
1 parent addf0ec commit f3865f6
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 19 deletions.
24 changes: 18 additions & 6 deletions command.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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) { void cmdSpawn(char *arg) {


char *scriptName; char *scriptName;
Expand Down Expand Up @@ -400,14 +410,16 @@ void cmdSpawn(char *arg) {
scriptFile = va("spawn/%s.gravitspawn", scriptName); scriptFile = va("spawn/%s.gravitspawn", scriptName);


luaExecute(scriptFile); 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"); lua_getglobal(state.lua, "spawn");
if (lua_pcall(state.lua, 0, 1, 0)) { if (lua_pcall(state.lua, 0, 1, 0)) {
conAdd(LERR, "Could not execute spawn function in %s", scriptFile); conAdd(LERR, "Could not execute spawn function in %s", scriptFile);
conAdd(LERR, "%s", lua_tostring(state.lua, -1)); cmdSpawnCancel();
cleanMemory();
state.currentlySpawning = 0;
state.particleCount = 0;
luaFree();
return; return;
} }


Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int init(int argc, char *argv[]) {
return 0; return 0;


if (!state.dontExecuteDefaultScript) if (!state.dontExecuteDefaultScript)
configRead("gravit.cfg"); configRead("gravit.cfg", 0);


#ifndef NO_GUI #ifndef NO_GUI


Expand Down
6 changes: 5 additions & 1 deletion spawn/binary-galaxy.gravitspawn
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,9 @@


require("scripts/functions.lua") require("spawn/functions.lua")

function describe()
log("Two galaxies rotating around each other")
end


function spawn() function spawn()


Expand Down
4 changes: 2 additions & 2 deletions spawn/default.gravitspawn
Original file line number Original file line Diff line number Diff line change
@@ -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) n = table.getn(scripts)
r = math.random(1,n) r = math.random(1,n)
log("Spawining " .. scripts[r]) log("Spawining " .. scripts[r])
spawn = nil spawn = nil
require ("scripts/" .. scripts[r] .. ".lua") require ("spawn/" .. scripts[r] .. ".gravitspawn")


12 changes: 7 additions & 5 deletions spawn/dust.gravitspawn
Original file line number Original file line Diff line number Diff line change
@@ -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() function spawn()


log("mooo!")

local massiveparticles = randomint(1, 3) local massiveparticles = randomint(1, 3)
local smallrange = randomfloat(100, 10000) local smallrange = randomfloat(100, 10000)
local bigrange = randomfloat(0, 10000) local bigrange = randomfloat(0, 10000)
Expand All @@ -15,8 +19,6 @@ function spawn()


for i=0,spawnparticles-1 do for i=0,spawnparticles-1 do


log(i)

if (i < massiveparticles) then if (i < massiveparticles) then
pos = randomrange(bigrange) pos = randomrange(bigrange)
vel = v(0,0,0) vel = v(0,0,0)
Expand Down
8 changes: 7 additions & 1 deletion spawn/loops.gravitspawn
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,11 @@


require("scripts/functions.lua") require("spawn/functions.lua")

function describe()

log("Random looping patterns of particles")

end


function spawn() function spawn()


Expand Down
6 changes: 5 additions & 1 deletion spawn/many-galaxy.gravitspawn
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,8 @@
require("scripts/functions.lua") require("spawn/functions.lua")

function describe()
log("Many sphere and spiral galaxies")
end


function spawn() function spawn()
-- work out a number of galaxies based on spawnparticles -- work out a number of galaxies based on spawnparticles
Expand Down
6 changes: 5 additions & 1 deletion spawn/one-galaxy.gravitspawn
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,8 @@
require("scripts/functions.lua") require("spawn/functions.lua")

function describe()
log("One spiral galaxy")
end


function spawn() function spawn()
particlemassmin = randomfloat(1,1000) particlemassmin = randomfloat(1,1000)
Expand Down
7 changes: 6 additions & 1 deletion spawn/snake.gravitspawn
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,11 @@


require("scripts/functions.lua") require("spawn/functions.lua")


function describe()
log("Random shaped string of particles")
end


function spawn() function spawn()


curveness = randomfloat(0, 0.5) curveness = randomfloat(0, 0.5)
Expand Down

0 comments on commit f3865f6

Please sign in to comment.