diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-31 16:07:38 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-31 16:07:38 (GMT) |
| commit | 2327d9678d5b75f1fcf6133966de8f4d754b0476 (patch) | |
| tree | d99abc011f4a4833b5fd07c21328066de9dab5aa | |
| parent | 03a048afe548b4fcbf281b5e3cb593f006c1d087 (diff) | |
| download | powder-2327d9678d5b75f1fcf6133966de8f4d754b0476.zip powder-2327d9678d5b75f1fcf6133966de8f4d754b0476.tar.gz | |
implement create and delete functions
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | src/luaconsole.c | 38 |
2 files changed, 35 insertions, 9 deletions
@@ -7,9 +7,9 @@ PY_INCPATH := $(shell $(PY_BIN) -c "import os.path,sys;print os.path.join(sys.ex PY_LDFLAGS := $(shell $(PY_BIN) -c "import distutils.sysconfig;print distutils.sysconfig.get_config_var('LINKFORSHARED')") PYCOMMAND := $(PY_BIN) getheader.py -CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -Iincludes/ +CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -Iincludes/ OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -LFLAGS := -lpthread -lSDL -lm -lbz2 #-lpython$(PY_VERSION) -L$(PY_LIBPATH) -I$(PY_INCPATH) $(PY_LDFLAGS) +LFLAGS := -lpthread -lSDL -lm -lbz2 -llua5.1 #-lpython$(PY_VERSION) -L$(PY_LIBPATH) -I$(PY_INCPATH) $(PY_LDFLAGS) LFLAGS_X := -lm -lbz2 -lSDLmain -I/Library/Frameworks/Python.framework/Versions/$(PY_VERSION)/include/python$(PY_VERSION) MFLAGS_SSE3 := -march=native -DX86 -DX86_SSE3 -msse3 MFLAGS_SSE2 := -march=native -DX86 -DX86_SSE2 -msse2 @@ -117,4 +117,4 @@ render-x: $(SOURCES) $(PYCOMMAND) $(COMPILER) -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) -lSDL $(MFLAGS) $(SOURCES) -framework Cocoa -DMACOSX -DRENDERER -arch x86_64 strip $@ - mv $@ build
\ No newline at end of file + mv $@ build diff --git a/src/luaconsole.c b/src/luaconsole.c index 8b8c222..53f81f0 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -112,9 +112,26 @@ int luatpt_drawtext(lua_State* l) int luatpt_create(lua_State* l) { - lua_pushstring(l, "not implemented"); - lua_error(l); - //TODO: Implement luatpt_create (Create a particle) + int x, y, retid, t = 0; + char * name; + x = abs(luaL_optint(l, 1, 0)); + y = abs(luaL_optint(l, 2, 0)); + if(x < XRES && y < YRES){ + if(lua_isnumber(l, 3)){ + t = luaL_optint(l, 3, 0); + if(t >= PT_NUM) + return -1; + } else { + name = luaL_optstring(l, 3, "dust"); + if (name[0]!=0) + console_parse_type(name, &t, console_error); + } + retid = create_part(-1, x, y, t); + if(retid==-1) + return -1; + lua_pushinteger(l, retid); + return 1; + } return -1; } @@ -372,9 +389,18 @@ int luatpt_set_shortcuts(lua_State* l) int luatpt_delete(lua_State* l) { - lua_pushstring(l, "not implemented"); - lua_error(l); - //TODO: Implement luatpt_delete (Delete particle) + int arg1, arg2; + arg1 = abs(luaL_optint(l, 1, 0)); + arg2 = luaL_optint(l, 2, -1); + if(arg2 == -1 && arg1 < NPART){ + kill_part(arg1); + return 0; + } + arg2 = abs(arg2); + if(arg2 < YRES && arg1 < XRES){ + delete_part(arg1, arg2); + return 0; + } return -1; } |
