[ create a new paste ] login | about

Link: http://codepad.org/a5s8ozTC    [ raw code | output | fork ]

ExcaliburZero - Lua, pasted on May 29:
minetest.register_entity("neoblocks:fireball", {
	visual = "sprite",
	visual_size = {x=1, y=1},
	--textures = {{name="mobs_fireball.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.5}}}, FIXME
	textures = {"mobs_fireball.png"},
	velocity = 5,
	on_step = function(self, dtime)
			local pos = self.object:getpos()
			if minetest.env:get_node(self.object:getpos()).name ~= "air" then
				self.hit_node(self, pos, node)
				self.object:remove()
				return
			end
			pos.y = pos.y-1
			for _,player in pairs(minetest.env:get_objects_inside_radius(pos, 1)) do
				if player:is_player() then
					self.hit_player(self, player)
					self.object:remove()
					return
				end
			end
		end,
	hit_player = function(self, player)
		local s = player:getpos()
		local p = player:get_look_dir()
		local vec = {x=s.x-p.x, y=s.y-p.y, z=s.z-p.z}
		player:punch(self.object, 1.0,  {
			full_punch_interval=1.0,
			damage_groups = {fleshy=4},
		}, vec)
		local pos = player:getpos()
		for dx=-1,1 do
			for dy=-1,1 do
				for dz=-1,1 do
					local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
					local n = minetest.env:get_node(pos).name
					if minetest.registered_nodes[n].groups.flammable or math.random(1, 100) <= 30 then
						minetest.env:set_node(p, {name="fire:basic_flame"})
					else
						minetest.env:remove_node(p)
					end
				end
			end
		end
	end,
	hit_node = function(self, pos, node)
		for dx=-1,1 do
			for dy=-2,1 do
				for dz=-1,1 do
					local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
					local n = minetest.env:get_node(pos).name
					if minetest.registered_nodes[n].groups.flammable or math.random(1, 100) <= 30 then
						minetest.env:set_node(p, {name="fire:basic_flame"})
					else
						minetest.env:remove_node(p)
					end
				end
			end
		end
	end
})

minetest.register_tool("neoblocks:fireball", {
	description = "Fireball",
	inventory_image = "mobs_fireball.png",
	on_use = function(itemstack, placer, pointed_thing)
		if pointed_thing.above then
			local dir = placer:get_look_dir();
			local obj = minetest.env:add_entity(player:getpos() + (0,2,0) + dir, "neoblocks:fireball")
			local vec = {x=dir.x*3,y=dir.y*3,z=dir.z*3}
			obj:setvelocity(vec)
		end
		return itemstack
	end,
})

minetest.register_node("neoblocks:fireballttt", {
tile_images = {"mobs_fireball.png"},
groups={snappy=2,choppy=2,oddly_breakable_by_hand=2},
})

minetest.register_craft({
output = '"neoblocks:fireball" 10',
recipe = {
{'', 'default:torch', ''},
{'', 'default:mese_crystal', ''},
{'', '', ''},
}
})


Output:
1
line 69: ')' expected near ','


Create a new paste based on this one


Comments: