Random Lua tweaks/fixes
authorPerttu Ahola <celeron55@gmail.com>
Mon, 21 Nov 2011 12:56:03 +0000 (14:56 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 17:13:50 +0000 (19:13 +0200)
data/mods/default/init.lua
src/scriptapi.cpp

index 4f825626d83f0a7e4877bfeaf2eff41bfa7150a0..b15315e24ccedb477d5cbecc102eabdcf15c05ab 100644 (file)
@@ -715,12 +715,12 @@ function register_falling_node(nodename, texture)
                        -- Set gravity
                        self.object:setacceleration({x=0, y=-10, z=0})
                        -- Turn to actual sand when collides to ground or just move
-                       pos = self.object:getpos()
-                       bcp = {x=pos.x, y=pos.y-0.6, z=pos.z} -- Position of bottom center point
-                       bcn = minetest.env:get_node(bcp)
+                       local pos = self.object:getpos()
+                       local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
+                       local bcn = minetest.env:get_node(bcp)
                        if bcn.name ~= "air" then
                                -- Turn to a sand node
-                               np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
+                               local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
                                minetest.env:add_node(np, {name=nodename})
                                self.object:remove()
                        else
index 02db2ce024b8180aa715e35eff25742ddf00c046..45971963248904a1b4fca7aa69db65402b63ff82 100644 (file)
@@ -154,14 +154,17 @@ static void pushpos(lua_State *L, v3s16 p)
 
 static v3s16 readpos(lua_State *L, int index)
 {
-       v3s16 p;
+       // Correct rounding at <0
+       v3f pf = readFloatPos(L, index);
+       return floatToInt(pf, BS);
+       /*v3s16 p;
        lua_getfield(L, index, "x");
        p.X = lua_tonumber(L, -1);
        lua_getfield(L, index, "y");
        p.Y = lua_tonumber(L, -1);
        lua_getfield(L, index, "z");
        p.Z = lua_tonumber(L, -1);
-       return p;
+       return p;*/
 }
 
 static void pushnode(lua_State *L, const MapNode &n, INodeDefManager *ndef)