mirror of
				https://bitbucket.org/Infinatum/scaffolding.git
				synced 2025-10-31 14:25:21 +01:00 
			
		
		
		
	> Fixed Height Bug
scaffolding will always go up to 32 nodes, no matter where you place the node > Height Set to 32 nodes Scaffolding cannot go over 32 nodes.
This commit is contained in:
		
							
								
								
									
										41
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								init.lua
									
									
									
									
									
								
							| @@ -33,13 +33,29 @@ minetest.register_node("scaffolding:scaffolding", { | |||||||
|  |  | ||||||
| 				-- many thanks to addi for improveing (rewriteing) my crappy code -- | 				-- many thanks to addi for improveing (rewriteing) my crappy code -- | ||||||
| 				local name = minetest.get_node(pos).name 									-- get loacation of node | 				local name = minetest.get_node(pos).name 									-- get loacation of node | ||||||
| 				height = 0; 																							-- set hite of scaffolding (not set) | 				height = 0; | ||||||
|  | 				depth = 0;		-- !!Note!! depth is not needed at the moment | ||||||
|  |  | ||||||
| 				--[[ debug stuff ]] | 				--[[ debug stuff ]] | ||||||
| 				minetest.chat_send_all(string.format("node: %s",name)) | 				minetest.chat_send_all(string.format("node: %s",name)) | ||||||
|  |  | ||||||
| 				minetest.chat_send_all(string.format("node: %s %s %s ",pos.x, pos.y, pos.z )) | 				minetest.chat_send_all(string.format("node: %s %s %s ",pos.x, pos.y, pos.z )) | ||||||
|  |  | ||||||
|  | 				-- set pos at bottom of scafolding tower. | ||||||
|  | 				repeat | ||||||
|  | 					pos.y = pos.y - 1; --every run get one node up | ||||||
|  | 					depth = depth - 1 | ||||||
|  | 					local current_node = minetest.get_node(pos); --get the node of the new position | ||||||
|  | 						minetest.chat_send_all(string.format("found %q at location: %s", | ||||||
|  | 							current_node.name, | ||||||
|  | 							minetest.pos_to_string(pos) | ||||||
|  | 						)) | ||||||
|  |  | ||||||
|  | 					until current_node.name ~= "scaffolding:scaffolding" -- will repeat untill it dose not find a scaffolding node | ||||||
|  | 						minetest.chat_send_all(string.format("exit loop")) | ||||||
|  |  | ||||||
|  | 				-- check height of scaffolding tower -- | ||||||
|  |  | ||||||
| 				repeat | 				repeat | ||||||
| 					pos.y = pos.y + 1; --every run get one node up | 					pos.y = pos.y + 1; --every run get one node up | ||||||
| 					height = height + 1 | 					height = height + 1 | ||||||
| @@ -54,7 +70,7 @@ minetest.register_node("scaffolding:scaffolding", { | |||||||
| 						itemstack:take_item(1); --//and remove one if its the correct one | 						itemstack:take_item(1); --//and remove one if its the correct one | ||||||
| 						player:set_wielded_item(itemstack);--//update inventory of the player | 						player:set_wielded_item(itemstack);--//update inventory of the player | ||||||
| 					end | 					end | ||||||
| 				until current_node.name ~= "scaffolding:scaffolding" or height >= 64 --we repeat until we find something else then "scaffolding:scaffolding" | 				until current_node.name ~= "scaffolding:scaffolding" or height >= 32 --we repeat until we find something else then "scaffolding:scaffolding" | ||||||
| 						--maybe there should be also another limit, because its currently possible to build infinite towers | 						--maybe there should be also another limit, because its currently possible to build infinite towers | ||||||
| 						minetest.chat_send_all(string.format("exit loop")) | 						minetest.chat_send_all(string.format("exit loop")) | ||||||
|  |  | ||||||
| @@ -237,13 +253,30 @@ minetest.register_node("scaffolding:reinforced_scaffolding", { | |||||||
|  |  | ||||||
| 				-- many thanks to addi for improveing (rewriteing) my crappy code -- | 				-- many thanks to addi for improveing (rewriteing) my crappy code -- | ||||||
| 				local name = minetest.get_node(pos).name 									-- get loacation of node | 				local name = minetest.get_node(pos).name 									-- get loacation of node | ||||||
| 				height = 0; 																							-- set hite of scaffolding (not set) | 				height = 0; | ||||||
|  | 				depth = 0; -- !!Note!! depth is not deeded at the moment | ||||||
|  |  | ||||||
| 				--[[ debug stuff ]] | 				--[[ debug stuff ]] | ||||||
| 				minetest.chat_send_all(string.format("node: %s",name)) | 				minetest.chat_send_all(string.format("node: %s",name)) | ||||||
|  |  | ||||||
| 				minetest.chat_send_all(string.format("node: %s %s %s ",pos.x, pos.y, pos.z )) | 				minetest.chat_send_all(string.format("node: %s %s %s ",pos.x, pos.y, pos.z )) | ||||||
|  |  | ||||||
|  | 				-- set pos at bottom of scafolding tower. | ||||||
|  | 				repeat | ||||||
|  | 					pos.y = pos.y - 1; --every run get one node up | ||||||
|  | 					depth = depth - 1 -- !!Note!! depth is not needed at the moment | ||||||
|  |  | ||||||
|  | 					local current_node = minetest.get_node(pos); --get the node of the new position | ||||||
|  | 						minetest.chat_send_all(string.format("found %q at location: %s", | ||||||
|  | 							current_node.name, | ||||||
|  | 							minetest.pos_to_string(pos) | ||||||
|  | 						)) | ||||||
|  |  | ||||||
|  | 					until current_node.name ~= "scaffolding:iron_scaffolding" -- will repeat untill it dose not find a scaffolding node | ||||||
|  | 						minetest.chat_send_all(string.format("exit loop")) | ||||||
|  |  | ||||||
|  | 				-- check height of scaffolding tower -- | ||||||
|  |  | ||||||
| 				repeat | 				repeat | ||||||
| 					pos.y = pos.y + 1; --every run get one node up | 					pos.y = pos.y + 1; --every run get one node up | ||||||
| 					height = height + 1 | 					height = height + 1 | ||||||
| @@ -258,7 +291,7 @@ minetest.register_node("scaffolding:reinforced_scaffolding", { | |||||||
| 						itemstack:take_item(1); --//and remove one if its the correct one | 						itemstack:take_item(1); --//and remove one if its the correct one | ||||||
| 						player:set_wielded_item(itemstack);--//update inventory of the player | 						player:set_wielded_item(itemstack);--//update inventory of the player | ||||||
| 					end | 					end | ||||||
| 				until current_node.name ~= "scaffolding:iron_scaffolding" or height >= 64 --we repeat until we find something else then "scaffolding:scaffolding" | 				until current_node.name ~= "scaffolding:iron_scaffolding" or height >= 32 --we repeat until we find something else then "scaffolding:scaffolding" | ||||||
| 				--maybe there should be also another limit, because its currently possible to build infinite towers | 				--maybe there should be also another limit, because its currently possible to build infinite towers | ||||||
| 				minetest.chat_send_all(string.format("exit loop")) | 				minetest.chat_send_all(string.format("exit loop")) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user