Improvements

master
zmv7 2022-04-09 18:02:19 +05:00 committed by GitHub
parent 4f7f38a16e
commit cb0cac1572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 10 deletions

View File

@ -4,16 +4,16 @@ minetest.override_item("default:snow", {
on_use = function(itemstack, user, pointed_thing)
if not minetest.check_player_privs(user:get_player_name(), {creative = true}) then itemstack:take_item()
end
local pos = user:getpos()
local pos = user:get_pos()
local dir = user:get_look_dir()
local yaw = user:get_look_horizontal()
if pos and dir then
pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "snowball:ball")
if obj then
obj:setvelocity({x=dir.x * 20, y=dir.y * 20, z=dir.z * 20})
obj:setacceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
obj:setyaw(yaw)
obj:set_velocity({x=dir.x * 20, y=dir.y * 20, z=dir.z * 20})
obj:set_acceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
obj:set_yaw(yaw)
thrower = user
end
end
@ -25,23 +25,27 @@ local SNOWBALL = {
physical = false,
timer = 0,
visual = "sprite",
visual_size = {x=0.5, y=0.5},
visual_size = {x=0.5, y=0.5,},
textures = {'default_snowball.png'},
lastpos= {},
pointable = false,
collisionbox = {-0.25,-0.25,-0.25,0.25,0.25,0.25},
--selectionbox = {-0.25,-0.25,-0.25,0.25,0.25,0.25},
selectionbox = {-0.25,-0.25,-0.25,0.25,0.25,0.25},
collide_with_objects = false,
}
SNOWBALL.on_step = function(self, dtime)
self.timer = self.timer + dtime
local pos = self.object:getpos()
local yaw = self.object:getyaw()
local pos = self.object:get_pos()
local yaw = self.object:get_yaw()
local node = minetest.get_node(pos)
if self.timer > 0.2 then
local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y-1, z = pos.z}, 1)
for k, obj in pairs(objs) do
if obj:is_player() or obj:get_luaentity()._cmi_is_mob then
if not obj then goto nodes end
local prop = obj:get_properties()
if not prop then goto nodes end
if obj:is_player() or prop.collide_with_objects then
obj:punch(thrower, 1.0, {
full_punch_interval = 1.0,
damage_groups= {fleshy = 1},
@ -51,7 +55,7 @@ SNOWBALL.on_step = function(self, dtime)
end
end
end
::nodes::
if self.lastpos.x ~= nil then
if minetest.registered_nodes[node.name].walkable and node.name ~= "default:snow" then
if not minetest.is_protected(self.lastpos,"") then