summaryrefslogtreecommitdiff
path: root/src/luaconsole.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/luaconsole.c')
-rw-r--r--src/luaconsole.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/luaconsole.c b/src/luaconsole.c
index 42495e7..0f4d567 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -1,6 +1,7 @@
#include <defines.h>
#ifdef LUACONSOLE
#include <powder.h>
+#include "gravity.h"
#include <console.h>
#include <luaconsole.h>
@@ -155,7 +156,6 @@ tpt.partsdata = nil");
tptElements = lua_gettop(l);
for(i = 1; i < PT_NUM; i++)
{
- int currentElementMeta, currentElement;
for(j = 0; j < strlen(ptypes[i].name); j++)
tmpname[j] = tolower(ptypes[i].name[j]);
tmpname[strlen(ptypes[i].name)] = 0;
@@ -167,8 +167,6 @@ tpt.partsdata = nil");
lua_newtable(l);
currentElementMeta = lua_gettop(l);
- lua_pushinteger(l, i);
- lua_setfield(l, currentElement, "value");
lua_pushcfunction(l, luacon_elementwrite);
lua_setfield(l, currentElementMeta, "__newindex");
lua_pushcfunction(l, luacon_elementread);
@@ -576,7 +574,7 @@ int luacon_elementread(lua_State* l){
free(key);
//Get Raw Index value for element
- lua_pushstring(l, "value");
+ lua_pushstring(l, "id");
lua_rawget(l, 1);
i = lua_tointeger (l, lua_gettop(l));
@@ -618,7 +616,7 @@ int luacon_elementwrite(lua_State* l){
offset = luacon_element_getproperty(key, &format);
//Get Raw Index value for element
- lua_pushstring(l, "value");
+ lua_pushstring(l, "id");
lua_rawget(l, 1);
i = lua_tointeger (l, lua_gettop(l));
@@ -1006,21 +1004,22 @@ int luatpt_reset_gravity_field(lua_State* l)
int x1, y1, width, height;
x1 = abs(luaL_optint(l, 1, 0));
y1 = abs(luaL_optint(l, 2, 0));
- width = abs(luaL_optint(l, 3, XRES/CELL));
- height = abs(luaL_optint(l, 4, YRES/CELL));
- if(x1 > (XRES/CELL)-1)
- x1 = (XRES/CELL)-1;
- if(y1 > (YRES/CELL)-1)
- y1 = (YRES/CELL)-1;
- if(x1+width > (XRES/CELL)-1)
- width = (XRES/CELL)-x1;
- if(y1+height > (YRES/CELL)-1)
- height = (YRES/CELL)-y1;
+ width = abs(luaL_optint(l, 3, XRES));
+ height = abs(luaL_optint(l, 4, YRES));
+ if(x1 > XRES-1)
+ x1 = XRES-1;
+ if(y1 > YRES-1)
+ y1 = YRES-1;
+ if(x1+width > XRES-1)
+ width = XRES-x1;
+ if(y1+height > YRES-1)
+ height = YRES-y1;
for (nx = x1; nx<x1+width; nx++)
for (ny = y1; ny<y1+height; ny++)
{
- gravx[ny][nx] = 0;
- gravy[ny][nx] = 0;
+ gravxf[ny*XRES+nx] = 0;
+ gravyf[ny*XRES+nx] = 0;
+ gravpf[ny*XRES+nx] = 0;
}
return 0;
}