Minor fix, drops improvement

This commit is contained in:
MoNTE48 2019-07-02 09:27:33 +02:00
parent 26bff3450e
commit e59ae03bf5
9 changed files with 63 additions and 62 deletions

View File

@ -765,6 +765,7 @@ core.register_chatcommand("rollback", {
core.register_chatcommand("status", {
description = "Print server status",
privs = {server=true},
func = function(name, param)
return true, core.get_server_status()
end,

View File

@ -188,23 +188,22 @@ end)
minetest.register_playerstep(function(dtime, playernames)
for _, name in pairs(playernames) do
local player = minetest.get_player_by_name(name)
local player_name = player:get_player_name()
if player and player:is_player() then
local wielded_item = player:get_wielded_item()
local wielded_item_name = wielded_item:get_name()
timer[player_name] = timer[player_name] and timer[player_name] + dtime or 0
wield[player_name] = wield[player_name] or ""
timer[player] = timer[player] and timer[player] + dtime or 0
wield[player] = wield[player] or ""
if timer[player_name] > timeout and player then
if timer[player] > timeout and player then
hud.change_item(player, "itemname", {text = ""})
timer[player_name] = 0
timer[player] = 0
return
end
if player and wielded_item_name ~= wield[player_name] then
wield[player_name] = wielded_item_name
timer[player_name] = 0
if player and wielded_item_name ~= wield[player] then
wield[player] = wielded_item_name
timer[player] = 0
local def = core.registered_items[wielded_item_name]
local meta = wielded_item:get_meta()
@ -217,4 +216,5 @@ minetest.register_playerstep(function(dtime, playernames)
hud.change_item(player, "itemname", {text = description})
end
end
end
end, minetest.is_singleplayer()) -- Force step in singlplayer mode only

View File

@ -144,12 +144,6 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
self.punched = true
end
function carts:on_rail_step(entity, pos, distance)
if minetest.global_exists("mesecon") then
carts:signal_detector_rail(pos)
end
end
-- sound refresh interval = 1.0sec
local function rail_sound(self, dtime)
if not self.sound_ttl then
@ -434,6 +428,12 @@ local function rail_on_step(self, dtime)
end
end
function carts:on_rail_step(entity, pos, distance)
if minetest.global_exists("mesecon") then
carts:signal_detector_rail(pos)
end
end
function cart_entity:on_step(dtime)
rail_on_step(self, dtime)
rail_sound(self, dtime)
@ -444,7 +444,6 @@ minetest.register_entity("carts:cart", cart_entity)
minetest.register_craftitem("carts:cart", {
description = "Cart (Sneak+Click to pick up)",
inventory_image = "carts_cart_inv.png",
wield_image = "carts_cart_inv.png",
stack_max = 1,
sounds = default.node_sound_metal_defaults(),
on_place = function(itemstack, placer, pointed_thing)

View File

@ -569,8 +569,12 @@ local function snowball_impact(thrower, pos, dir, hit_object)
end
end
function default.snow_shoot_snowball(itemstack, player, pointed_thing)
local obj = minetest.item_throw("default:snow", player, 19, -3,
function default.snow_shoot_snowball(itemstack, thrower, pointed_thing)
local playerpos = thrower:get_pos()
if not minetest.is_valid_pos(playerpos) then
return
end
local obj = minetest.item_throw("default:snow", thrower, 19, -3,
snowball_impact)
if obj then
obj:set_properties({
@ -578,18 +582,15 @@ function default.snow_shoot_snowball(itemstack, player, pointed_thing)
visual_size = {x=1, y=1},
textures = {"default_snowball.png"},
})
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(player)) or
not minetest.is_singleplayer() then
itemstack:take_item()
end
local playerpos = player:get_pos()
if minetest.is_valid_pos(playerpos) then
minetest.sound_play("throwing_sound", {
pos = playerpos,
gain = 0.7,
max_hear_distance = 10,
})
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(thrower)) or
not minetest.is_singleplayer() then
itemstack:take_item()
end
end
return itemstack

View File

@ -1,6 +1,5 @@
local age = 0.5 -- How old an item has to be before collecting
local radius_magnet = 2 -- Radius of item magnet
local player_collect_height = 1.3 -- Added to their pos y value
local function collect_items(player)
local pos = player:get_pos()
@ -8,11 +7,12 @@ local function collect_items(player)
return
end
-- Detect
local col_pos = vector.add(pos, {x = 0, y = player_collect_height, z = 0})
local col_pos = vector.add(pos, {x = 0, y = 1.3, z = 0})
local objects = minetest.get_objects_inside_radius(col_pos, radius_magnet)
for _, object in ipairs(objects) do
local entity = object:get_luaentity()
if entity and not object:is_player() and
not entity.collectioner and
entity.name == "__builtin:item" and entity.age > age then
local item = ItemStack(entity.itemstring)
local inv = player:get_inventory()
@ -23,15 +23,15 @@ local function collect_items(player)
entity.collectioner = true
-- Collect
if entity.collectioner == true then
minetest.after(0.01, function()
minetest.after(0.05, function()
minetest.sound_play("item_drop_pickup", {
pos = pos,
pos = col_pos,
max_hear_distance = 10,
gain = 0.25,
gain = 0.2,
})
inv:add_item("main", item)
entity.itemstring = ""
object:remove()
inv:add_item("main", item)
end)
end
end

View File

@ -430,7 +430,7 @@ end)
minetest.register_playerstep(function(dtime, playernames)
-- Update HUDs of all players
for _, name in pairs(playernames) do
playereffects.hud_update(minetest.get_player_by_name(name))
playereffects.hud_update(name)
end
end, minetest.is_singleplayer()) -- Force step in singlplayer mode only
@ -438,8 +438,11 @@ end, minetest.is_singleplayer()) -- Force step in singlplayer mode only
function playereffects.hud_update(player)
if(playereffects.use_hud == true) then
local now = os.time()
local playername = player:get_player_name()
local hudinfos = playereffects.hudinfos[playername]
local player = minetest.get_player_by_name(player)
if not player or not player:is_player() then
return
end
local hudinfos = playereffects.hudinfos[player]
if(hudinfos ~= nil) then
for effect_id, hudinfo in pairs(hudinfos) do
local effect = playereffects.effects[effect_id]

View File

@ -1,10 +1,6 @@
local update_time = 1
local has_armor = minetest.get_modpath("3d_armor")
local time = 0
local update_time = tonumber(minetest.settings:get("wieldview_update_time"))
if not update_time then
update_time = 2
minetest.settings:set("wieldview_update_time", tostring(update_time))
end
local wield_tiles = {}
local wield_cubes = {}

View File

@ -7,7 +7,6 @@ local nodes = {}
for node, def in pairs(minetest.registered_nodes) do
if (def.drawtype == "normal" or def.drawtype:sub(1,5) == "glass" or def.drawtype:sub(1,8) == "allfaces") and
(def.tiles and type(def.tiles[1]) == "string") and
not def.on_construct and
not def.on_rightclick and
not def.on_blast and
not def.allow_metadata_inventory_take and
@ -335,12 +334,12 @@ for _, d in pairs(workbench.defs) do
end
-- Aliases. A lot of aliases...
local stairs_aliases = {
{"corner", "outerstair"},
{"invcorner", "outerstair"},
{"stair_outer", "innerstair"},
{"stair_inner", "innerstair"}
{"stair_inner", "innerstair"},
{"nanoslab", "microslab"}
}
for i=1, #nodes do
@ -353,16 +352,18 @@ for i=1, #nodes do
for _, e in pairs(stairs_aliases) do
minetest.register_alias("stairs:"..e[1].."_"..node:match(":(.*)"), "stairs:"..e[2].."_"..node:gsub(":", "_"))
minetest.register_alias("stairs:"..e[1].."_"..node:gsub(":", "_"), "stairs:"..e[2].."_"..node:gsub(":", "_"))
minetest.register_alias(node.."_"..e[1], "stairs:"..e[2].."_"..node:gsub(":", "_"))
end
end
for _, d in pairs(workbench.defs) do
minetest.register_alias("stairs:"..d[1].."_coal", "stairs:"..d[1].."_default_coalblock")
minetest.register_alias("stairs:"..d[1].."_straw", "stairs:"..d[1].."_farming_straw")
end
for _, e in pairs(stairs_aliases) do
minetest.register_alias("stairs:"..e[1].."_coal", "stairs:"..e[2].."_default_coalblock")
minetest.register_alias("stairs:"..e[1].."_straw", "stairs:"..e[2].."_farming_straw")
end
minetest.register_alias("stairs:stair_steel", "stairs:stair_default_steelblock")

View File

@ -326,7 +326,7 @@ void ScriptApiBase::objectrefGetOrCreate(lua_State *L,
} else {
push_objectRef(L, cobj->getId());
if (cobj->isGone())
warningstream << "ScriptApiBase::objectrefGetOrCreate(): "
actionstream << "ScriptApiBase::objectrefGetOrCreate(): "
<< "Pushing ObjectRef to removed/deactivated object"
<< ", this is probably a bug." << std::endl;
}