forked from mtcontrib/minetest-mod-snow
		
	add infomessage to the snow chatcommand, add a bit light to the lit star texture and allow en- and disabling snowfall ingame
This commit is contained in:
		
							
								
								
									
										93
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								init.lua
									
									
									
									
									
								
							@@ -123,55 +123,56 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- Checks if the snow level is even at any given pos.
 | 
					-- Checks if the snow level is even at any given pos.
 | 
				
			||||||
-- Smooth Snow
 | 
					-- Smooth Snow
 | 
				
			||||||
if snow.smooth_snow then
 | 
					local function is_uneven(pos)
 | 
				
			||||||
	snow.is_uneven = function(pos)
 | 
						local num = minetest.get_node_level(pos)
 | 
				
			||||||
		local num = minetest.get_node_level(pos)
 | 
						local get_node = minetest.get_node
 | 
				
			||||||
		local get_node = minetest.get_node
 | 
						local add_node = minetest.add_node
 | 
				
			||||||
		local add_node = minetest.add_node
 | 
						local found
 | 
				
			||||||
		local found
 | 
						local foundx
 | 
				
			||||||
		local foundx
 | 
						local foundy
 | 
				
			||||||
		local foundy
 | 
						local foundz
 | 
				
			||||||
		local foundz
 | 
						for z = -1,1 do
 | 
				
			||||||
		for z = -1,1 do
 | 
							for x = -1,1 do
 | 
				
			||||||
			for x = -1,1 do
 | 
								local p = {x=pos.x+x, y=pos.y, z=pos.z+z}
 | 
				
			||||||
				local p = {x=pos.x+x, y=pos.y, z=pos.z+z}
 | 
								local node = get_node(p)
 | 
				
			||||||
				local node = get_node(p)
 | 
								p.y = p.y-1
 | 
				
			||||||
 | 
								local bnode = get_node(p)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if node
 | 
				
			||||||
 | 
								and minetest.registered_nodes[node.name]
 | 
				
			||||||
 | 
								and minetest.registered_nodes[node.name].drawtype == "plantlike"
 | 
				
			||||||
 | 
								and bnode.name == "default:dirt_with_grass" then
 | 
				
			||||||
 | 
									add_node(p, {name="default:dirt_with_snow"})
 | 
				
			||||||
 | 
									return true
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								p.y = p.y+1
 | 
				
			||||||
 | 
								if not (x == 0 and z == 0)
 | 
				
			||||||
 | 
								and node.name == "default:snow"
 | 
				
			||||||
 | 
								and minetest.get_node_level(p) < num then
 | 
				
			||||||
 | 
									found = true
 | 
				
			||||||
 | 
									foundx = x
 | 
				
			||||||
 | 
									foundz = z
 | 
				
			||||||
 | 
								elseif node.name == "air"
 | 
				
			||||||
 | 
								and bnode.name ~= "air"
 | 
				
			||||||
 | 
								and bnode.name ~= "default:snow" then
 | 
				
			||||||
				p.y = p.y-1
 | 
									p.y = p.y-1
 | 
				
			||||||
				local bnode = get_node(p)
 | 
									snow.place(p)
 | 
				
			||||||
 | 
									return true
 | 
				
			||||||
				if node
 | 
					 | 
				
			||||||
				and minetest.registered_nodes[node.name]
 | 
					 | 
				
			||||||
				and minetest.registered_nodes[node.name].drawtype == "plantlike"
 | 
					 | 
				
			||||||
				and bnode.name == "default:dirt_with_grass" then
 | 
					 | 
				
			||||||
					add_node(p, {name="default:dirt_with_snow"})
 | 
					 | 
				
			||||||
					return true
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				p.y = p.y+1
 | 
					 | 
				
			||||||
				if not (x == 0 and z == 0)
 | 
					 | 
				
			||||||
				and node.name == "default:snow"
 | 
					 | 
				
			||||||
				and minetest.get_node_level(p) < num then
 | 
					 | 
				
			||||||
					found = true
 | 
					 | 
				
			||||||
					foundx = x
 | 
					 | 
				
			||||||
					foundz = z
 | 
					 | 
				
			||||||
				elseif node.name == "air"
 | 
					 | 
				
			||||||
				and bnode.name ~= "air"
 | 
					 | 
				
			||||||
				and bnode.name ~= "default:snow" then
 | 
					 | 
				
			||||||
					p.y = p.y-1
 | 
					 | 
				
			||||||
					snow.place(p)
 | 
					 | 
				
			||||||
					return true
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		if found then
 | 
					 | 
				
			||||||
			local p = {x=pos.x+foundx, y=pos.y, z=pos.z+foundz}
 | 
					 | 
				
			||||||
			if snow.is_uneven(p) ~= true then
 | 
					 | 
				
			||||||
				minetest.add_node_level(p, 7)
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
			return true
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
else
 | 
						if found then
 | 
				
			||||||
	snow.is_uneven = function()
 | 
							local p = {x=pos.x+foundx, y=pos.y, z=pos.z+foundz}
 | 
				
			||||||
 | 
							if snow.is_uneven(p) ~= true then
 | 
				
			||||||
 | 
								minetest.add_node_level(p, 7)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function snow.is_uneven(pos)
 | 
				
			||||||
 | 
						if snow.smooth_snow then
 | 
				
			||||||
 | 
							return is_uneven(pos)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,10 +40,6 @@ near torches and lava.
 | 
				
			|||||||
--=============================================================
 | 
					--=============================================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if not snow.enable_snowfall then
 | 
					 | 
				
			||||||
	return
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local weather_legacy
 | 
					local weather_legacy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local read_weather_legacy = function ()
 | 
					local read_weather_legacy = function ()
 | 
				
			||||||
@@ -84,7 +80,7 @@ local PERSISTENCE3 = 0.5 -- 0.5
 | 
				
			|||||||
local SCALE3 = 250 -- 250
 | 
					local SCALE3 = 250 -- 250
 | 
				
			||||||
 | 
					
 | 
				
			||||||
--Get snow at position.
 | 
					--Get snow at position.
 | 
				
			||||||
local get_snow = function(pos)
 | 
					local function get_snow(pos)
 | 
				
			||||||
	--Legacy support.
 | 
						--Legacy support.
 | 
				
			||||||
	if weather_legacy == "snow" then
 | 
						if weather_legacy == "snow" then
 | 
				
			||||||
		local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
 | 
							local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
 | 
				
			||||||
@@ -106,14 +102,19 @@ end
 | 
				
			|||||||
local addvectors = vector and vector.add
 | 
					local addvectors = vector and vector.add
 | 
				
			||||||
 | 
					
 | 
				
			||||||
--Returns a random position between minp and maxp.
 | 
					--Returns a random position between minp and maxp.
 | 
				
			||||||
local randpos = function (minp, maxp)
 | 
					local function randpos(minp, maxp)
 | 
				
			||||||
	local x,y,z
 | 
						local x,z
 | 
				
			||||||
	if minp.x > maxp.x then
 | 
						if minp.x > maxp.x then
 | 
				
			||||||
		x = math.random(maxp.x,minp.x) else x = math.random(minp.x,maxp.x) end
 | 
							x = math.random(maxp.x,minp.x)
 | 
				
			||||||
		y = minp.y
 | 
						else
 | 
				
			||||||
 | 
							x = math.random(minp.x,maxp.x)
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
	if minp.z > maxp.z then
 | 
						if minp.z > maxp.z then
 | 
				
			||||||
		z = math.random(maxp.z,minp.z) else z = math.random(minp.z,maxp.z) end
 | 
							z = math.random(maxp.z,minp.z)
 | 
				
			||||||
	return {x=x,y=y,z=z}
 | 
						else
 | 
				
			||||||
 | 
							z = math.random(minp.z,maxp.z)
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						return {x=x,y=minp.y,z=z}
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local default_snow_particle = {
 | 
					local default_snow_particle = {
 | 
				
			||||||
@@ -152,22 +153,20 @@ local function snow_fall(pos, player, animate)
 | 
				
			|||||||
			break
 | 
								break
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	if not ground_y then return end
 | 
						if not ground_y then
 | 
				
			||||||
	pos = {x=pos.x, y=ground_y, z=pos.z}
 | 
							return
 | 
				
			||||||
	local spos = {x=pos.x, y=ground_y+10, z=pos.z}
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pos = {x=pos.x, y=ground_y, z=pos.z}
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  	if get_snow(pos) then
 | 
					  	if get_snow(pos) then
 | 
				
			||||||
  		if animate then
 | 
					  		if animate then
 | 
				
			||||||
	  		local minp = addvectors(spos, {x=-9, y=3, z=-9})
 | 
								local spos = {x=pos.x, y=ground_y+10, z=pos.z}
 | 
				
			||||||
			local maxp = addvectors(spos, {x= 9, y=5, z= 9})
 | 
					 | 
				
			||||||
	  		local vel = {x=0, y=   -1, z=-1}
 | 
					 | 
				
			||||||
			local acc = {x=0, y=   0, z=0}
 | 
					 | 
				
			||||||
			minetest.add_particlespawner(get_snow_particledef({
 | 
								minetest.add_particlespawner(get_snow_particledef({
 | 
				
			||||||
				minpos = minp,
 | 
									minpos = addvectors(spos, {x=-9, y=3, z=-9}),
 | 
				
			||||||
				maxpos = maxp,
 | 
									maxpos = addvectors(spos, {x= 9, y=5, z= 9}),
 | 
				
			||||||
				vel = vel,
 | 
									vel = {x=0, y=-1, z=-1},
 | 
				
			||||||
				acc = acc,
 | 
									acc = {x=0, y=0, z=0},
 | 
				
			||||||
				playername = player:get_player_name()
 | 
									playername = player:get_player_name()
 | 
				
			||||||
			}))
 | 
								}))
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
@@ -177,30 +176,21 @@ local function snow_fall(pos, player, animate)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Snow
 | 
					-- Snow
 | 
				
			||||||
minetest.register_globalstep(function(dtime)
 | 
					local function calc_snowfall()
 | 
				
			||||||
	for _, player in pairs(minetest.get_connected_players()) do
 | 
						for _, player in pairs(minetest.get_connected_players()) do
 | 
				
			||||||
		local ppos = player:getpos()
 | 
							local ppos = player:getpos()
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		local sminp = addvectors(ppos, {x=-20, y=0, z=-20})
 | 
					 | 
				
			||||||
		local smaxp = addvectors(ppos, {x= 20, y=0, z= 20})
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		-- Make sure player is not in a cave/house...
 | 
							-- Make sure player is not in a cave/house...
 | 
				
			||||||
		if get_snow(ppos) and minetest.get_node_light(ppos, 0.5) == 15 then
 | 
							if get_snow(ppos)
 | 
				
			||||||
 | 
							and minetest.get_node_light(ppos, 0.5) == 15 then
 | 
				
			||||||
			local minp = addvectors(ppos, {x=-9, y=3, z=-9})
 | 
								local animate
 | 
				
			||||||
			local maxp = addvectors(ppos, {x= 9, y=5, z= 9})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			local minp_deep = addvectors(ppos, {x=-5, y=3.2, z=-5})
 | 
					 | 
				
			||||||
			local maxp_deep = addvectors(ppos, {x= 5, y=1.6, z= 5})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			local vel = {x=0, y=   -1, z=-1}
 | 
					 | 
				
			||||||
			local acc = {x=0, y=   0, z=0}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if not snow.lighter_snowfall then
 | 
								if not snow.lighter_snowfall then
 | 
				
			||||||
 | 
									local vel = {x=0, y=-1, z=-1}
 | 
				
			||||||
 | 
									local acc = {x=0, y=0, z=0}
 | 
				
			||||||
				minetest.add_particlespawner(get_snow_particledef({
 | 
									minetest.add_particlespawner(get_snow_particledef({
 | 
				
			||||||
					amount = 5,
 | 
										amount = 5,
 | 
				
			||||||
					minpos = minp,
 | 
										minpos = addvectors(ppos, {x=-9, y=3, z=-9}),
 | 
				
			||||||
					maxpos = maxp,
 | 
										maxpos = addvectors(ppos, {x= 9, y=5, z= 9}),
 | 
				
			||||||
					vel = vel,
 | 
										vel = vel,
 | 
				
			||||||
					acc = acc,
 | 
										acc = acc,
 | 
				
			||||||
					size = 25,
 | 
										size = 25,
 | 
				
			||||||
@@ -209,8 +199,8 @@ minetest.register_globalstep(function(dtime)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				minetest.add_particlespawner(get_snow_particledef({
 | 
									minetest.add_particlespawner(get_snow_particledef({
 | 
				
			||||||
					amount = 4,
 | 
										amount = 4,
 | 
				
			||||||
					minpos = minp_deep,
 | 
										minpos = addvectors(ppos, {x=-5, y=3.2, z=-5}),
 | 
				
			||||||
					maxpos = maxp_deep,
 | 
										maxpos = addvectors(ppos, {x= 5, y=1.6, z= 5}),
 | 
				
			||||||
					vel = vel,
 | 
										vel = vel,
 | 
				
			||||||
					acc = acc,
 | 
										acc = acc,
 | 
				
			||||||
					exptime = 4,
 | 
										exptime = 4,
 | 
				
			||||||
@@ -218,14 +208,27 @@ minetest.register_globalstep(function(dtime)
 | 
				
			|||||||
					playername = player:get_player_name()
 | 
										playername = player:get_player_name()
 | 
				
			||||||
				}))
 | 
									}))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if math.random(1,5) == 4 then	
 | 
									animate = false
 | 
				
			||||||
					snow_fall(randpos(sminp, smaxp), player)
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				if math.random(1,5) == 4 then	
 | 
									animate = true
 | 
				
			||||||
					snow_fall(randpos(sminp, smaxp), player, true)
 | 
								end
 | 
				
			||||||
				end
 | 
					
 | 
				
			||||||
 | 
								if math.random(1,5) == 4 then	
 | 
				
			||||||
 | 
									snow_fall(
 | 
				
			||||||
 | 
										randpos(
 | 
				
			||||||
 | 
											addvectors(ppos, {x=-20, y=0, z=-20}),
 | 
				
			||||||
 | 
											addvectors(ppos, {x= 20, y=0, z= 20})
 | 
				
			||||||
 | 
										),
 | 
				
			||||||
 | 
										player,
 | 
				
			||||||
 | 
										animate
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_globalstep(function(dtime)
 | 
				
			||||||
 | 
						if snow.enable_snowfall then
 | 
				
			||||||
 | 
							calc_snowfall()
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										80
									
								
								src/sled.lua
									
									
									
									
									
								
							
							
						
						
									
										80
									
								
								src/sled.lua
									
									
									
									
									
								
							@@ -53,8 +53,7 @@ than I originally planned. :p  ~ LazyJ
 | 
				
			|||||||
--
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function is_water(pos)
 | 
					local function is_water(pos)
 | 
				
			||||||
	local nn = minetest.get_node(pos).name
 | 
						return minetest.get_item_group(minetest.get_node(pos).name, "water") ~= 0
 | 
				
			||||||
	return minetest.get_item_group(nn, "water") ~= 0
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -77,7 +76,8 @@ local sled = {
 | 
				
			|||||||
local players_sled = {}
 | 
					local players_sled = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function sled:on_rightclick(clicker)
 | 
					function sled:on_rightclick(clicker)
 | 
				
			||||||
	if (not self.driver) and snow.sleds then
 | 
						if not self.driver
 | 
				
			||||||
 | 
						and snow.sleds then
 | 
				
			||||||
		players_sled[clicker:get_player_name()] = true
 | 
							players_sled[clicker:get_player_name()] = true
 | 
				
			||||||
		self.driver = clicker
 | 
							self.driver = clicker
 | 
				
			||||||
		self.object:set_attach(clicker, "", {x=0,y=-9,z=0}, {x=0,y=90,z=0})
 | 
							self.object:set_attach(clicker, "", {x=0,y=-9,z=0}, {x=0,y=90,z=0})
 | 
				
			||||||
@@ -110,7 +110,7 @@ function sled:on_rightclick(clicker)
 | 
				
			|||||||
				direction = 0,
 | 
									direction = 0,
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
-- End part 1	
 | 
					-- End part 1	
 | 
				
			||||||
 	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function sled:on_activate(staticdata, dtime_s)
 | 
					function sled:on_activate(staticdata, dtime_s)
 | 
				
			||||||
@@ -126,13 +126,20 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function sled:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
 | 
					function sled:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
 | 
				
			||||||
	self.object:remove()
 | 
						self.object:remove()
 | 
				
			||||||
	if puncher and puncher:is_player() then
 | 
						if puncher
 | 
				
			||||||
 | 
						and puncher:is_player() then
 | 
				
			||||||
		puncher:get_inventory():add_item("main", "snow:sled")
 | 
							puncher:get_inventory():add_item("main", "snow:sled")
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local timer = 0
 | 
				
			||||||
minetest.register_globalstep(function(dtime)
 | 
					minetest.register_globalstep(function(dtime)
 | 
				
			||||||
 | 
						timer = timer+dtime
 | 
				
			||||||
 | 
						if timer < 1 then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						timer = 0
 | 
				
			||||||
	for _, player in pairs(minetest.get_connected_players()) do
 | 
						for _, player in pairs(minetest.get_connected_players()) do
 | 
				
			||||||
		if players_sled[player:get_player_name()] then
 | 
							if players_sled[player:get_player_name()] then
 | 
				
			||||||
			default.player_set_animation(player, "sit", 0)
 | 
								default.player_set_animation(player, "sit", 0)
 | 
				
			||||||
@@ -140,28 +147,37 @@ minetest.register_globalstep(function(dtime)
 | 
				
			|||||||
	end
 | 
						end
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local timer = 0
 | 
				
			||||||
function sled:on_step(dtime)
 | 
					function sled:on_step(dtime)
 | 
				
			||||||
	if self.driver then
 | 
						if not self.driver then
 | 
				
			||||||
		local p = self.object:getpos()
 | 
							return
 | 
				
			||||||
		p.y = p.y+0.4
 | 
						end
 | 
				
			||||||
		local s = self.object:getpos()
 | 
						timer = timer+dtime
 | 
				
			||||||
		s.y = s.y -0.5
 | 
						if timer < 1 then
 | 
				
			||||||
		local keys = self.driver:get_player_control()
 | 
							return
 | 
				
			||||||
		if keys["sneak"] or is_water(p) or (not minetest.find_node_near(s, 1, {"default:snow","default:snowblock","default:ice","default:dirt_with_snow", "group:icemaker"})) then  -- LazyJ
 | 
						end
 | 
				
			||||||
			self.driver:set_physics_override({
 | 
						timer = 0
 | 
				
			||||||
				speed = 1, -- multiplier to default value
 | 
						local p = self.object:getpos()
 | 
				
			||||||
				jump = 1, -- multiplier to default value
 | 
						p.y = p.y+0.4
 | 
				
			||||||
				gravity = 1
 | 
						local s = self.object:getpos()
 | 
				
			||||||
		  	})
 | 
						s.y = s.y -0.5
 | 
				
			||||||
 | 
						local keys = self.driver:get_player_control()
 | 
				
			||||||
 | 
						if keys["sneak"]
 | 
				
			||||||
 | 
						or is_water(p)
 | 
				
			||||||
 | 
						or not minetest.find_node_near(s, 1, {"default:snow","default:snowblock","default:ice","default:dirt_with_snow", "group:icemaker"}) then  -- LazyJ
 | 
				
			||||||
 | 
							self.driver:set_physics_override({
 | 
				
			||||||
 | 
								speed = 1, -- multiplier to default value
 | 
				
			||||||
 | 
								jump = 1, -- multiplier to default value
 | 
				
			||||||
 | 
								gravity = 1
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			players_sled[self.driver:get_player_name()] = false
 | 
							players_sled[self.driver:get_player_name()] = false
 | 
				
			||||||
			self.object:set_detach()
 | 
							self.object:set_detach()
 | 
				
			||||||
			--self.driver:hud_remove("sled")
 | 
							--self.driver:hud_remove("sled")
 | 
				
			||||||
			self.driver:hud_remove(self.HUD) -- And here is part 2. ~ LazyJ
 | 
							self.driver:hud_remove(self.HUD) -- And here is part 2. ~ LazyJ
 | 
				
			||||||
			self.driver = nil
 | 
							self.driver = nil
 | 
				
			||||||
			self.object:remove()
 | 
							self.object:remove()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -176,15 +192,13 @@ minetest.register_craftitem("snow:sled", {
 | 
				
			|||||||
	liquids_pointable = true,
 | 
						liquids_pointable = true,
 | 
				
			||||||
	stack_max = 1,
 | 
						stack_max = 1,
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 	on_use = function(itemstack, placer)
 | 
						on_use = function(itemstack, placer)
 | 
				
			||||||
 		local pos = {x=0,y=-1000, z=0}
 | 
							if players_sled[placer:get_player_name()] then
 | 
				
			||||||
 		local name = placer:get_player_name()
 | 
								return
 | 
				
			||||||
 		local player_pos = placer:getpos()
 | 
							end
 | 
				
			||||||
 		if not players_sled[name] then
 | 
							if minetest.get_node(placer:getpos()).name == "default:snow" then
 | 
				
			||||||
 			if minetest.get_node(player_pos).name == "default:snow" then
 | 
								local sled = minetest.add_entity({x=0,y=-1000, z=0}, "snow:sled")
 | 
				
			||||||
				local sled = minetest.add_entity(pos, "snow:sled")
 | 
								sled:get_luaentity():on_rightclick(placer)
 | 
				
			||||||
				sled:get_luaentity():on_rightclick(placer)
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -159,6 +159,7 @@ minetest.register_chatcommand("snow", {
 | 
				
			|||||||
	description = "Show a menu for various actions",
 | 
						description = "Show a menu for various actions",
 | 
				
			||||||
	privs = {server=true},
 | 
						privs = {server=true},
 | 
				
			||||||
	func = function(name)
 | 
						func = function(name)
 | 
				
			||||||
 | 
							minetest.chat_send_player(name, "Showing snow menu…")
 | 
				
			||||||
		minetest.show_formspec(name, "snow:menu", get_formspec())
 | 
							minetest.show_formspec(name, "snow:menu", get_formspec())
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 302 B After Width: | Height: | Size: 319 B  | 
		Reference in New Issue
	
	Block a user