summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-02-21 16:50:05 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-02-21 16:50:05 +0200
commit62e79125775123f1889131b42caaeeb5f1cf015a (patch)
tree804449e2fedc2c3568d2dbac3fd87989af50aa1b
parent69dbc046eb5a82b38c6d5c3302e9b3b0b3c1bcf1 (diff)
downloadminetest-62e79125775123f1889131b42caaeeb5f1cf015a.tar.gz
minetest-62e79125775123f1889131b42caaeeb5f1cf015a.tar.bz2
minetest-62e79125775123f1889131b42caaeeb5f1cf015a.zip
some tidying
-rw-r--r--src/clientobject.cpp17
-rw-r--r--src/mapnode.h17
-rw-r--r--src/serverobject.cpp83
3 files changed, 99 insertions, 18 deletions
diff --git a/src/clientobject.cpp b/src/clientobject.cpp
index e6646eff1..bb4497e94 100644
--- a/src/clientobject.cpp
+++ b/src/clientobject.cpp
@@ -175,6 +175,23 @@ extern "C"{
}
/*
+ Functions for calling from script:
+
+ object_set_position(self, x, y, z)
+ object_set_rotation(self, x, y, z)
+ object_add_to_mesh(self, image, corners, backface_culling)
+ object_clear_mesh(self)
+
+ Callbacks in script:
+
+ step(self, dtime)
+ process_message(self, data)
+ initialize(self, data)
+ TODO:
+ string status_text(self)
+*/
+
+/*
object_set_position(self, x, y, z)
*/
static int lf_object_set_position(lua_State *L)
diff --git a/src/mapnode.h b/src/mapnode.h
index 7819d701d..03a294ad2 100644
--- a/src/mapnode.h
+++ b/src/mapnode.h
@@ -198,23 +198,6 @@ struct ContentFeatures
}
}
- /*void setTexture(u16 i, AtlasPointer p, u8 alpha=255)
- {
- tiles[i].texture = p;
- if(alpha != 255)
- {
- tiles[i].alpha = alpha;
- tiles[i].material_type = MATERIAL_ALPHA_VERTEX;
- }
- }
- void setAllTextures(AtlasPointer p, u8 alpha=255)
- {
- for(u16 i=0; i<6; i++)
- {
- setTexture(i, p, alpha);
- }
- }*/
-
void setTile(u16 i, const TileSpec &tile)
{
tiles[i] = tile;
diff --git a/src/serverobject.cpp b/src/serverobject.cpp
index 2fd3a1bfb..8b41cef16 100644
--- a/src/serverobject.cpp
+++ b/src/serverobject.cpp
@@ -88,10 +88,20 @@ extern "C"{
}
/*
+ Functions for calling from script:
+
object_set_base_position(self, x,y,z)
x,y,z = object_get_base_position(self)
object_add_message(self, data)
+ n = object_get_node(self, x,y,z)
object_remove(self)
+
+ Callbacks in script:
+
+ step(self, dtime)
+ get_client_init_data(self)
+ get_server_init_data(self)
+ initialize(self, data)
*/
/*
@@ -168,7 +178,7 @@ static int lf_object_add_message(lua_State *L)
}
/*
- object_get_node(x,y,z)
+ object_get_node(self, x,y,z)
*/
static int lf_object_get_node(lua_State *L)
{
@@ -201,6 +211,76 @@ static int lf_object_get_node(lua_State *L)
lua_pushstring(L, "content");
lua_pushinteger(L, n.d);
lua_settable(L, -3);
+ lua_pushstring(L, "param1");
+ lua_pushinteger(L, n.param);
+ lua_settable(L, -3);
+ lua_pushstring(L, "param2");
+ lua_pushinteger(L, n.param2);
+ lua_settable(L, -3);
+ lua_pushstring(L, "walkable");
+ lua_pushboolean(L, content_features(n.d).walkable);
+ lua_settable(L, -3);
+
+ // Return the table
+ return 1;
+}
+
+#if 0
+/*
+ object_set_node(self, x,y,z, n)
+*/
+static int lf_object_set_node(lua_State *L)
+{
+ MapNode n;
+
+ // 5: n
+ // Get fields of table
+
+ lua_pushinteger(L, "content");
+ lua_gettable(L, -2);
+ n.d = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushinteger(L, "param1");
+ lua_gettable(L, -2);
+ n.param = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushinteger(L, "param2");
+ lua_gettable(L, -2);
+ n.param2 = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_pop(L, 1);
+ // 4: z
+ lua_Number z = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+ // 3: y
+ lua_Number y = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+ // 2: x
+ lua_Number x = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+ // 1: self
+ LuaSAO *self = (LuaSAO*)lua_touserdata(L, -1);
+ lua_pop(L, 1);
+
+ assert(self);
+
+ v3s16 pos = floatToInt(v3f(x,y,z), 1.0);
+
+ /*dstream<<"Checking node from pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z
+ <<")"<<std::endl;*/
+
+ // Get the node
+ MapNode n(CONTENT_IGNORE);
+ n = self->getEnv()->getMap().getNodeNoEx(pos);
+
+ // Create a table with some data about the node
+ lua_newtable(L);
+ lua_pushstring(L, "content");
+ lua_pushinteger(L, n.d);
+ lua_settable(L, -3);
lua_pushstring(L, "walkable");
lua_pushboolean(L, content_features(n.d).walkable);
lua_settable(L, -3);
@@ -208,6 +288,7 @@ static int lf_object_get_node(lua_State *L)
// Return the table
return 1;
}
+#endif
/*
object_remove(x,y,z)