From 9886c4f5b6d3f62e93a9ed6ea8c1aff70113badd Mon Sep 17 00:00:00 2001 From: melzua Date: Fri, 16 Oct 2015 21:31:30 +0200 Subject: [PATCH 1/2] Field "height_min": Deprecated: new name is "y_min". --- mods/default/mapgen.lua | 38 +++++++++++++++++++------------------- mods/gold/init.lua | 6 +++--- mods/jewels/init.lua | 6 +++--- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/mods/default/mapgen.lua b/mods/default/mapgen.lua index f65204b..aaca2c5 100644 --- a/mods/default/mapgen.lua +++ b/mods/default/mapgen.lua @@ -539,8 +539,8 @@ minetest.register_ore( clust_scarcity = 10*10*10, clust_num_ores = 6, clust_size = 4, - height_min = -31000, - height_max = 32, + y_min = -31000, + y_max = 32, }) minetest.register_ore( @@ -551,8 +551,8 @@ minetest.register_ore( clust_scarcity = 8*8*8, clust_num_ores = 8, clust_size = 6, - height_min = -31000, - height_max = -32, + y_min = -31000, + y_max = -32, }) minetest.register_ore( @@ -563,8 +563,8 @@ minetest.register_ore( clust_scarcity = 9*9*9, clust_num_ores = 20, clust_size = 10, - height_min = -31000, - height_max = -64, + y_min = -31000, + y_max = -64, }) -- Iron @@ -577,8 +577,8 @@ minetest.register_ore( clust_scarcity = 8*8*8, clust_num_ores = 6, clust_size = 4, - height_min = -31000, - height_max = 0, + y_min = -31000, + y_max = 0, }) minetest.register_ore( @@ -589,8 +589,8 @@ minetest.register_ore( clust_scarcity = 8*8*8, clust_num_ores = 20, clust_size = 10, - height_min = -31000, - height_max = -32, + y_min = -31000, + y_max = -32, }) -- Steel blocks @@ -603,8 +603,8 @@ minetest.register_ore( clust_scarcity = 12*12*12, clust_num_ores = 10, clust_size = 10, - height_min = -31000, - height_max = -128, + y_min = -31000, + y_max = -128, }) -- Water @@ -617,8 +617,8 @@ minetest.register_ore( -- Springs clust_scarcity = 18*18*18, clust_num_ores = 1, clust_size = 1, - height_min = 20, - height_max = 31000, + y_min = 20, + y_max = 31000, }) minetest.register_ore( -- Swamp @@ -630,8 +630,8 @@ minetest.register_ore( -- Swamp clust_scarcity = 10*10*10, clust_num_ores = 10, clust_size = 4, - height_min = -31000, - height_max = 31000, + y_min = -31000, + y_max = 31000, }) minetest.register_ore( -- Marsh @@ -643,8 +643,8 @@ minetest.register_ore( -- Marsh clust_scarcity = 6*6*6, clust_num_ores = 10, clust_size = 6, - height_min = -31000, - height_max = 31000, + y_min = -31000, + y_max = 31000, }) -default.log("mapgen", "loaded") \ No newline at end of file +default.log("mapgen", "loaded") diff --git a/mods/gold/init.lua b/mods/gold/init.lua index 6a16bf5..7466181 100644 --- a/mods/gold/init.lua +++ b/mods/gold/init.lua @@ -285,6 +285,6 @@ minetest.register_ore( clust_scarcity = 12*12*12, clust_num_ores = 10, clust_size = 10, - height_min = -256, - height_max = -32, - }) \ No newline at end of file + y_min = -256, + y_max = -32, + }) diff --git a/mods/jewels/init.lua b/mods/jewels/init.lua index 7cbd7c6..dbdda3a 100644 --- a/mods/jewels/init.lua +++ b/mods/jewels/init.lua @@ -212,10 +212,10 @@ minetest.register_ore( clust_scarcity = 11*11*11, clust_num_ores = 3, clust_size = 6, - height_min = 0, - height_max = 31000, + y_min = 0, + y_max = 31000, }) dofile(minetest.get_modpath("jewels").."/jewels.lua") -default.log("mod:jewels", "loaded") \ No newline at end of file +default.log("mod:jewels", "loaded") From 3bb3d59dbb971e2aca202f8f71fde6977525e36b Mon Sep 17 00:00:00 2001 From: melzua Date: Fri, 16 Oct 2015 21:44:43 +0200 Subject: [PATCH 2/2] Optimize a bit. --- mods/item_drop/init.lua | 58 ++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/mods/item_drop/init.lua b/mods/item_drop/init.lua index ee0fe61..cffe256 100644 --- a/mods/item_drop/init.lua +++ b/mods/item_drop/init.lua @@ -15,60 +15,46 @@ minetest.register_globalstep( local pos = player:getpos() local inv = player:get_inventory() - for _,object in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do - if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and valid(object) then - if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then - inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) - if object:get_luaentity().itemstring ~= "" then - minetest.sound_play("item_drop_pickup", {pos = pos, gain = 0.1, max_hear_distance = 8}) - end - object:get_luaentity().itemstring = "" - object:remove() - end - end - end - for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1.25)) do if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and valid(object) then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then local pos1 = pos pos1.y = pos1.y+0.2 local pos2 = object:getpos() - local vec = vector.normalize({x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}) - vec.x = vec.x*3 - vec.y = vec.y*3 - vec.z = vec.z*3 - object:setvelocity(vec) - object:get_luaentity().physical_state = false - object:get_luaentity().object:set_properties( - { - physical = false - }) - - minetest.after( - 1, - function(args) + local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z} + local len = vector.length(vec) + if len > 0.5 then + vec = vector.divide(vec, len) -- it's a normalize but we have len yet (vector.normalize(vec)) + vec.x = vec.x*3 + vec.y = vec.y*3 + vec.z = vec.z*3 + object:setvelocity(vec) + object:get_luaentity().physical_state = false + object:get_luaentity().object:set_properties( + { + physical = false + }) + else local lua = object:get_luaentity() if object == nil or lua == nil or lua.itemstring == nil then return end - if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then - inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) - if object:get_luaentity().itemstring ~= "" then + if inv:room_for_item("main", ItemStack(lua.itemstring)) then + inv:add_item("main", ItemStack(lua.itemstring)) + if lua.itemstring ~= "" then minetest.sound_play("item_drop_pickup", {pos = pos, gain = 0.3, max_hear_distance = 16}) end - object:get_luaentity().itemstring = "" + lua.itemstring = "" object:remove() else object:setvelocity({x = 0, y = 0, z = 0}) - object:get_luaentity().physical_state = true - object:get_luaentity().object:set_properties( + lua.physical_state = true + lua.object:set_properties( { physical = true }) end - end, {player, object}) - + end end end end @@ -110,4 +96,4 @@ function minetest.handle_node_drops(pos, drops, digger) end end -default.log("mod:item_drop", "loaded") \ No newline at end of file +default.log("mod:item_drop", "loaded")