Improve throwing and improve formspecs

This commit is contained in:
stujones11 2019-06-26 22:09:54 +01:00 committed by MoNTE48
parent 17fe5acd85
commit 375971b3bd
8 changed files with 65 additions and 46 deletions

View File

@ -45,7 +45,7 @@ minetest.register_node("default:chest", {
"background[-0.2,-0.35;9.42,12.46;formspec_chest_large.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0.01,0.4;9,3;]"..
"list[current_name;main;0.01,3.39;9,3;]"..
"list[current_player;main;0.01,7.4;9,3;9]"..
@ -58,7 +58,7 @@ minetest.register_node("default:chest", {
"background[-0.2,-0.35;9.42,12.46;formspec_chest_large.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0.01,3.39;9,3;]"..
"list[current_name;main;0.01,0.4;9,3;]"..
"list[current_player;main;0.01,7.4;9,3;9]"..
@ -72,7 +72,7 @@ minetest.register_node("default:chest", {
"background[-0.2,-0.35;9.42,12.46;formspec_chest_large.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0.01,3.39;9,3;]"..
"list[current_name;main;0.01,0.4;9,3;]"..
"list[current_player;main;0.01,7.4;9,3;9]"..
@ -85,7 +85,7 @@ minetest.register_node("default:chest", {
"background[-0.2,-0.35;9.42,12.46;formspec_chest_large.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.35,-0.28;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0.01,0.4;9,3;]"..
"list[current_name;main;0.01,3.39;9,3;]"..
"list[current_player;main;0.01,7.4;9,3;9]"..
@ -97,7 +97,7 @@ minetest.register_node("default:chest", {
"background[-0.2,-0.26;9.41,9.49;formspec_chest.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.35,-0.19;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.35,-0.19;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[current_name;main;0,0.5;9,3;]"..
"list[current_player;main;0,4.5;9,3;9]" ..
"list[current_player;main;0,7.74;9,1;]")
@ -163,7 +163,7 @@ minetest.register_node("default:chest_left", {
"background[-0.2,-0.26;9.41,9.49;formspec_chest.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.35,-0.19;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.35,-0.19;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[current_name;main;0,0.5;9,3;]"..
"list[current_player;main;0,4.5;9,3;9]" ..
"list[current_player;main;0,7.74;9,1;]")
@ -221,7 +221,7 @@ minetest.register_node("default:chest_right", {
"background[-0.2,-0.26;9.41,9.49;formspec_chest.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.35,-0.19;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.35,-0.19;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[current_name;main;0,0.5;9,3;]"..
"list[current_player;main;0,4.5;9,3;9]" ..
"list[current_player;main;0,7.74;9,1;]")

View File

@ -536,7 +536,15 @@ end
-- Shoot snowball
local function snowball_impact(thrower, pos)
local function snowball_impact(thrower, pos, dir, hit_object)
if hit_object then
local punch_damage = {
full_punch_interval = 1.0,
damage_groups = {fleshy=1},
}
hit_object:punch(thrower, 1.0, punch_damage, dir)
end
local node_pos = nil
local node = minetest.get_node(pos)
if node.name == "air" then
local pos_under = vector.subtract(pos, {x=0, y=1, z=0})
@ -544,50 +552,45 @@ local function snowball_impact(thrower, pos)
if node.name then
local def = minetest.registered_items[node.name] or {}
if def.buildable_to == true then
minetest.add_node(pos_under, {name="default:snow"})
node_pos = pos_under
elseif def.walkable == true then
minetest.add_node(pos, {name="default:snow"})
node_pos = pos
end
elseif node.name then
local def = minetest.registered_items[node.name]
if def and def.buildable_to == true then
minetest.add_node(pos, {name="default:snow"})
node_pos = pos
end
end
if node_pos then
minetest.add_node(pos, {name="default:snow"})
minetest.spawn_falling_node(pos)
end
end
end
function default.snow_shoot_snowball(itemstack, player, pointed_thing)
if not (creative and creative.is_enabled_for and
creative.is_enabled_for(player)) or
not minetest.is_singleplayer() then
itemstack:take_item()
end
minetest.item_throw("default:snowball_entity", player, 19, -3,
local obj = minetest.item_throw("default:snow", player, 19, -3,
snowball_impact)
local playerpos = player:get_pos()
if not minetest.is_valid_pos(playerpos) then
return
if obj then
obj:set_properties({
visual = "sprite",
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,
})
end
end
minetest.sound_play("throwing_sound", {
pos = playerpos,
gain = 1.0,
max_hear_distance = 5,
})
return itemstack
end
minetest.register_entity("default:snowball_entity", {
physical = true,
textures = {"default_snowball.png",},
visual = "sprite",
collisionbox = {0,0,0, 0,0,0},
on_activate = function(self, staticdata)
if staticdata == "expired" then
self.object:remove()
end
end,
get_staticdata = function()
return "expired"
end,
})

View File

@ -9,7 +9,7 @@ function default.get_furnace_active_formspec(fuel_percent, item_percent)
"background[-0.2,-0.26;9.41,9.49;formspec_furnace.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
"list[current_name;src;3,0.5;1,1;]"..
@ -26,7 +26,7 @@ function default.get_furnace_inactive_formspec()
"background[-0.2,-0.26;9.41,9.49;formspec_furnace.png]"..
default.gui_bg..
default.listcolors..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;false;close_pressed.png]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
"list[current_name;src;3,0.5;1,1;]"..

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

View File

@ -153,10 +153,10 @@ local mobs_shoot_egg = function (item, player, pointed_thing)
local playerpos = player:get_pos()
minetest.sound_play("default_place_node_hard", {
minetest.sound_play("throwing_sound", {
pos = playerpos,
gain = 1.0,
max_hear_distance = 5,
gain = 0.7,
max_hear_distance = 10,
})
local obj = minetest.add_entity({

View File

@ -3766,9 +3766,20 @@ end
local function throw_spawn_egg(itemstack, user, pointed_thing)
local mob = itemstack:get_name():gsub("_set$", "")
local egg_impact = function(thrower, pos)
local egg_impact = function(thrower, pos, dir, hit_object)
if hit_object then
local punch_damage = {
full_punch_interval = 1.0,
damage_groups = {fleshy=1},
}
hit_object:punch(thrower, 1.0, punch_damage, dir)
end
spawn_mob(pos, mob, itemstack:get_metadata(), user)
end
local playerpos = user:get_pos()
if not minetest.is_valid_pos(playerpos) then
return
end
local obj = minetest.item_throw(mob.."_set", user, 19, -3, egg_impact)
if obj then
local def = minetest.registered_items[mob.."_set"]
@ -3779,6 +3790,11 @@ local function throw_spawn_egg(itemstack, user, pointed_thing)
textures = {def.inventory_image},
})
end
minetest.sound_play("throwing_sound", {
pos = playerpos,
gain = 0.7,
max_hear_distance = 10,
})
if not mobs.is_creative(user) or
not minetest.is_singleplayer() then
itemstack:take_item()