shooting snowballs will follow later again
This commit is contained in:
parent
4d7b5a6daf
commit
c5e4dbd89a
91
init.lua
91
init.lua
@ -597,67 +597,66 @@ minetest.register_node(":default:stick", {
|
||||
})
|
||||
-- complex node --
|
||||
|
||||
snowball_DAMAGE=0.5
|
||||
snowball_GRAVITY=9
|
||||
snowball_VELOCITY=19
|
||||
--snowball_DAMAGE=0.5
|
||||
--snowball_GRAVITY=9
|
||||
--snowball_VELOCITY=19
|
||||
|
||||
--Shoot snowball.
|
||||
local snow_shoot_snowball=function (item, player, pointed_thing)
|
||||
local playerpos=player:getpos()
|
||||
local obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "default:snow_entity")
|
||||
local dir=player:get_look_dir()
|
||||
obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY})
|
||||
obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3})
|
||||
item:take_item()
|
||||
return item
|
||||
end
|
||||
--local snow_shoot_snowball=function (item, player, pointed_thing)
|
||||
-- local playerpos=player:getpos()
|
||||
-- local obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "default:snow_entity")
|
||||
-- local dir=player:get_look_dir()
|
||||
-- obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY})
|
||||
-- obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3})
|
||||
-- item:take_item()
|
||||
-- return item
|
||||
--end
|
||||
|
||||
|
||||
--The snowball Entity
|
||||
snow_snowball_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
damage=1,
|
||||
gravity=10,
|
||||
velocity=19,
|
||||
range=1,
|
||||
textures = {"default_snowball.png"},
|
||||
lastpos={},
|
||||
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
|
||||
|
||||
}
|
||||
--snow_snowball_ENTITY={
|
||||
-- physical = false,
|
||||
-- timer=0,
|
||||
-- damage=1,
|
||||
-- gravity=10,
|
||||
-- velocity=19,
|
||||
-- range=1,
|
||||
-- textures = {"default_snowball.png"},
|
||||
-- lastpos={},
|
||||
-- collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
|
||||
--}
|
||||
|
||||
|
||||
--Snowball_entity.on_step()--> called when snowball is moving.
|
||||
snow_snowball_ENTITY.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.env:get_node(pos)
|
||||
--snow_snowball_ENTITY.on_step = function(self, dtime)
|
||||
-- self.timer=self.timer+dtime
|
||||
-- local pos = self.object:getpos()
|
||||
-- local node = minetest.env:get_node(pos)
|
||||
|
||||
--Become item when hitting a node.
|
||||
if self.lastpos.x~=nil then --If there is no lastpos for some reason.
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
end
|
||||
if node.name == "default:water_source" then
|
||||
minetest.sound_play("snowball_splash",
|
||||
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
||||
self.object:remove()
|
||||
end
|
||||
-- if self.lastpos.x~=nil then --If there is no lastpos for some reason.
|
||||
-- if node.name ~= "air" then
|
||||
-- self.object:remove()
|
||||
-- end
|
||||
-- if node.name == "default:water_source" then
|
||||
-- minetest.sound_play("snowball_splash",
|
||||
-- {pos = pos, gain = 1.0, max_hear_distance = 32,})
|
||||
-- self.object:remove()
|
||||
-- end
|
||||
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node
|
||||
-- end
|
||||
-- self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node
|
||||
|
||||
end
|
||||
--end
|
||||
|
||||
minetest.register_entity("default:snow_entity", snow_snowball_ENTITY)
|
||||
--minetest.register_entity("default:snow", snow_snowball_ENTITY)
|
||||
|
||||
--Snowball.
|
||||
minetest.register_craftitem("default:snow", {
|
||||
Description = "Snowball",
|
||||
inventory_image = "default_snow.png",
|
||||
on_use = snow_shoot_snowball,
|
||||
})
|
||||
--minetest.register_craftitem("default:snow", {
|
||||
-- Description = "Snowball",
|
||||
-- inventory_image = "default_snow.png",
|
||||
-- on_use = snow_shoot_snowball,
|
||||
--})
|
||||
|
||||
--Snow.
|
||||
--minetest.register_node("christmas_craft:snow", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user