Complicate placement boats and carts on the server, Add home button in creative inventory, new cart texture, disable Cleaner caching

This commit is contained in:
MoNTE48 2019-05-28 13:10:21 +02:00
parent 9fba94561b
commit a58d944f8a
15 changed files with 45 additions and 36 deletions

View File

@ -138,9 +138,7 @@ function boat.on_punch(self, puncher)
local inv = puncher:get_inventory()
if not inv then
minetest.add_item(self.object:get_pos(), "boats:boat")
elseif not (creative and creative.is_enabled_for
and creative.is_enabled_for(name))
or not inv:contains_item("main", "boats:boat") then
else
local leftover = inv:add_item("main", "boats:boat")
-- if no room in inventory add a replacement boat to the world
if not leftover:is_empty() then
@ -321,7 +319,8 @@ minetest.register_craftitem("boats:boat", {
end
local player_name = placer and placer:get_player_name() or ""
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(player_name)) then
creative.is_enabled_for(player_name)) or
not minetest.is_singleplayer() then
itemstack:take_item()
end
end

View File

@ -440,12 +440,8 @@ minetest.register_entity(":carts:cart", cart_entity)
if not boost_cart.mtg_compat then
minetest.register_craftitem(":carts:cart", {
description = "Cart (Sneak+Click to pick up)",
inventory_image = minetest.inventorycube(
"cart_top.png",
"cart_side.png",
"cart_side.png"
),
wield_image = "cart_side.png",
inventory_image = "carts_cart_inv.png",
wield_image = "carts_cart_inv.png",
on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then
return
@ -458,7 +454,9 @@ if not boost_cart.mtg_compat then
return
end
if not minetest.settings:get_bool("creative_mode") then
minetest.sound_play({name = "default_place_node_metal", gain = 0.5},
{pos = pointed_thing.above})
if not minetest.settings:get_bool("creative_mode") or not minetest.is_singleplayer() then
itemstack:take_item()
end
return itemstack

View File

@ -223,9 +223,6 @@ function boost_cart:boost_rail(pos, amount)
end
function boost_cart:register_rail(name, def_overwrite)
local sound_func = default.node_sound_metal_defaults
or default.node_sound_defaults
local def = {
drawtype = "raillike",
paramtype = "light",
@ -236,7 +233,7 @@ function boost_cart:register_rail(name, def_overwrite)
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
sounds = sound_func()
sounds = default.node_sound_metal_defaults(),
}
for k, v in pairs(def_overwrite) do
def[k] = v

Binary file not shown.

Before

Width:  |  Height:  |  Size: 989 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

View File

@ -26,16 +26,19 @@ local function clean()
for y = -height, height do
for z = -radius, radius do
local pos_scan = vector.new(pos.x + x, pos.y + y, pos.z + z)
local hash = minetest.hash_node_position(pos_scan)
--local hash = minetest.hash_node_position(pos_scan)
local nodename = minetest.get_node(pos_scan).name
if not kpos[hash] then
--[[if not kpos[hash] then
local nodename = minetest.get_node(pos_scan).name
if not minetest.registered_nodes[nodename] then
minetest.remove_node(pos_scan)
end
kpos[hash] = true
kpos[hash] = true]]
if not minetest.registered_nodes[nodename] then
minetest.remove_node(pos_scan)
end
local objs = minetest.get_objects_inside_radius(pos_scan, 0.5)
@ -43,8 +46,7 @@ local function clean()
for j = 1, #objs do
local obj = objs[j]
if not obj:is_player() then
-- new API is too heavy
local entname = obj:get_entity_name()
local entname = obj:get_luaentity().name
if not minetest.registered_entities[entname] then
obj:remove()
end

View File

@ -33,8 +33,8 @@ ofs_tab["combat"] = "6.96,-0.35"
ofs_tab["matr"] = "8,-0.35"
ofs_tab["brew"] = "9.01,-0.35"
ofs_img["all"] = "10.24,1"
ofs_img["inv"] = "10.24,7.13"
ofs_img["all"] = "10.25,1"
ofs_img["inv"] = "10.25,7.11"
ofs_img["blocks"] = "-0.16,-0.15"
ofs_img["deco"] = "0.87,-0.15"
ofs_img["mese"] = "1.92,-0.15"
@ -202,8 +202,10 @@ local function get_creative_formspec(player_name, start_i, pagenum, page, pagema
"image_button[7.15,-0.15;1,1;"..bg["combat"]..";combat;;;false]".. --combat
"image_button[8.17,-0.15;1,1;"..bg["matr"]..";matr;;;false]".. --materials
"image_button[9.2,-0.15;1,1;"..bg["brew"]..";brew;;;false]".. --brewing
"image_button[10.24,1;1,1;"..bg["all"]..";default;;;false]".. --all items
"image_button[10.24,7.13;1,1;"..bg["inv"]..";inv;;;false]".. --inventory
"image_button[10.25,1;1,1;"..bg["all"]..";default;;;false]".. --all items
"image_button[10.25,7.11;1,1;"..bg["inv"]..";inv;;;false]".. --inventory
"image_button_exit[10.3,2.5;1,1;creative_home_set.png;sethome_set;;true;true;]"..
"image_button_exit[10.3,3.5;1,1;creative_home_go.png;sethome_go;;true;true;]"..
"image[0,0.95;5,0.75;fnt_"..name..".png]"..
"image_button[9.145,1.65;0.81,0.6;creative_up.png;creative_prev;]"..
"image_button[9.145,6.08;0.81,0.6;creative_down.png;creative_next;]"..

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

View File

@ -24,7 +24,8 @@ mobs:register_mob("mobs_animal:kitten", {
walk_chance = 15,
run_velocity = 2,
runaway = true,
jump = false,
jump = true,
jump_height = 5,
drops = {
{name = "farming:string", chance = 1, min = 1, max = 1}
},

View File

@ -67,14 +67,8 @@ sethome.go = function(name)
return false
end
minetest.register_privilege("home", {
description = "Can use /sethome and /home",
give_to_singleplayer = true
})
minetest.register_chatcommand("home", {
description = "Teleport you to your home point",
privs = {home = true},
func = function(name)
if sethome.go(name) then
return true, "Teleported to home!"
@ -85,7 +79,6 @@ minetest.register_chatcommand("home", {
minetest.register_chatcommand("sethome", {
description = "Set your home point",
privs = {home = true},
func = function(name)
name = name or "" -- fallback to blank name if nil
local player = minetest.get_player_by_name(name)
@ -98,7 +91,6 @@ minetest.register_chatcommand("sethome", {
minetest.register_chatcommand("home set", {
description = "Set your home point",
privs = {home = true},
func = function(name)
name = name or "" -- fallback to blank name if nil
local player = minetest.get_player_by_name(name)
@ -107,4 +99,22 @@ minetest.register_chatcommand("home set", {
end
return false, "Player not found!"
end,
})
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
if not player or not player:is_player() then
return
end
local player_name = player:get_player_name()
if fields.sethome_set then
sethome.set(player_name, player:get_pos())
minetest.chat_send_player(player_name, "Home set!")
elseif fields.sethome_go then
if sethome.go(player_name) then
sethome.go(player_name)
minetest.chat_send_player(player_name, "Teleported to home!")
else
minetest.chat_send_player(player_name, "Home is not set!")
end
end
end)

View File

@ -44,7 +44,7 @@ wieldview.get_item_texture = function(self, item)
end
wieldview.update_wielded_item = function(self, player)
if not player or minetest.is_singleplayer() == true then
if not player or minetest.is_singleplayer() then
return
end
local name = player:get_player_name()

View File

@ -1 +1 @@
default_privs = interact, shout, home, fly, settime
default_privs = interact, shout, fly, settime