mirror of
				https://github.com/Uberi/Minetest-WorldEdit.git
				synced 2025-10-31 12:55:23 +01:00 
			
		
		
		
	dual-based cylinder
This commit is contained in:
		| @@ -81,14 +81,18 @@ Add hollow cylinder at WorldEdit position 1 along the x/y/z/? axis with length < | ||||
|     //hollowcylinder z -12 3 mesecons:mesecon | ||||
|     //hollowcylinder ? 2 4 stone | ||||
|  | ||||
| ### //cylinder x/y/z/? <length> <radius> <node> | ||||
| ### //cylinder x/y/z/? <length> <radius1> [<radius2>] <node> | ||||
|  | ||||
| Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>. | ||||
| Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length>, base radius <radius1> [and top radius <radius2>], composed of <node>. | ||||
|  | ||||
|     //cylinder x +5 8 dirt | ||||
|     //cylinder y 28 10 default:glass | ||||
|     //cylinder z -12 3 mesecons:mesecon | ||||
|     //cylinder ? 2 4 stone | ||||
|  | ||||
|     //cylinder y 10 10 0 water_flowing | ||||
|     //cylinder x 6 5 0 dirt | ||||
|     //cylinder z 20 10 20 desert_stone | ||||
|      | ||||
| ### //pyramid <height> <node> | ||||
|  | ||||
| @@ -220,4 +224,4 @@ Save the current WorldEdit region including metadata to "(world folder)/schems/< | ||||
| Load nodes and metadata from "(world folder)/schems/<file>.wem" with position 1 of the current WorldEdit region as the origin. | ||||
|  | ||||
|     //metaload some random filename | ||||
|     //metaload huge_base | ||||
|     //metaload huge_base | ||||
|   | ||||
| @@ -94,7 +94,7 @@ Returns the number of nodes added. | ||||
|  | ||||
| ### worldedit.cylinder(pos, axis, length, radius, nodename) | ||||
|  | ||||
| Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`. | ||||
| Adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length`, base radius `radius` (and top radius `radius`), composed of `nodename`. | ||||
|  | ||||
| Returns the number of nodes added. | ||||
|  | ||||
| @@ -170,4 +170,4 @@ Returns the number of nodes saved. | ||||
|  | ||||
| Loads the nodes and meta from `file` to position `pos1`. | ||||
|  | ||||
| Returns the number of nodes loaded. | ||||
| Returns the number of nodes loaded. | ||||
|   | ||||
| @@ -104,8 +104,8 @@ worldedit.hollow_cylinder = function(pos, axis, length, radius, nodename) | ||||
| 	return count | ||||
| end | ||||
|  | ||||
| --adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length` and radius `radius`, composed of `nodename`, returning the number of nodes added | ||||
| worldedit.cylinder = function(pos, axis, length, radius, nodename) | ||||
| --adds a cylinder at `pos` along the `axis` axis ("x" or "y" or "z") with length `length`, base radius `radius` (and top radius `radius`), composed of `nodename`, returning the number of nodes added | ||||
| worldedit.cylinder = function(pos, axis, length, radius1, radius2, nodename) | ||||
| 	local other1, other2 | ||||
| 	if axis == "x" then | ||||
| 		other1, other2 = "y", "z" | ||||
| @@ -125,6 +125,9 @@ worldedit.cylinder = function(pos, axis, length, radius, nodename) | ||||
| 		step = -1 | ||||
| 	end | ||||
| 	for i = 1, length do | ||||
| 		local radius = radius1 + (radius2 - radius1) * (i - 1) / (length - 1) | ||||
| 		--radius shouldn't need rounding | ||||
| 		radius = math.floor(radius+0.5) | ||||
| 		local offset1, offset2 = 0, radius | ||||
| 		local delta = -radius | ||||
| 		while offset1 <= offset2 do | ||||
| @@ -256,4 +259,4 @@ worldedit.spiral = function(pos, width, height, spacer, nodename) --wip: clean t | ||||
| 		end | ||||
| 	end | ||||
| 	return count | ||||
| end | ||||
| end | ||||
|   | ||||
| @@ -269,8 +269,8 @@ minetest.register_chatcommand("/hollowcylinder", { | ||||
| }) | ||||
|  | ||||
| minetest.register_chatcommand("/cylinder", { | ||||
| 	params = "x/y/z/? <length> <radius> <node>", | ||||
| 	description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length> and radius <radius>, composed of <node>", | ||||
| 	params = "x/y/z/? <length> <radius1> [<radius2>] <node>", | ||||
| 	description = "Add cylinder at WorldEdit position 1 along the x/y/z/? axis with length <length>, base radius <radius1> [and top radius <radius2>], composed of <node>", | ||||
| 	privs = {worldedit=true}, | ||||
| 	func = function(name, param) | ||||
| 		local pos = worldedit.pos1[name] | ||||
| @@ -279,10 +279,17 @@ minetest.register_chatcommand("/cylinder", { | ||||
| 			return | ||||
| 		end | ||||
|  | ||||
| 		local found, _, axis, length, radius, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$") | ||||
| 		--double radius | ||||
| 		local found, _, axis, length, radius1, radius2, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+(%d+)%s+([^%s]+)$") | ||||
| 		if found == nil then | ||||
| 			minetest.chat_send_player(name, "Invalid usage: " .. param) | ||||
| 			return | ||||
| 			--single radius | ||||
| 			found, _, axis, length, radius1, nodename = param:find("^([xyz%?])%s+([+-]?%d+)%s+(%d+)%s+([^%s]+)$") | ||||
| 			if found == nil then | ||||
| 				--no radius | ||||
| 				minetest.chat_send_player(name, "Invalid usage: " .. param) | ||||
| 				return | ||||
| 			end | ||||
| 			radius2 = radius1 | ||||
| 		end | ||||
| 		if axis == "?" then | ||||
| 			axis, sign = worldedit.player_axis(name) | ||||
| @@ -293,7 +300,7 @@ minetest.register_chatcommand("/cylinder", { | ||||
| 			return | ||||
| 		end | ||||
|  | ||||
| 		local count = worldedit.cylinder(pos, axis, tonumber(length), tonumber(radius), nodename) | ||||
| 		local count = worldedit.cylinder(pos, axis, tonumber(length), tonumber(radius1), tonumber(radius2), nodename) | ||||
| 		minetest.chat_send_player(name, count .. " nodes added") | ||||
| 	end, | ||||
| }) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user