mirror of
				https://github.com/minetest-mods/areas.git
				synced 2025-10-26 10:45:30 +01:00 
			
		
		
		
	Compare commits
	
		
			16 Commits
		
	
	
		
			require_pr
			...
			a8cacee8cc
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a8cacee8cc | |||
| 76f8ccf8ab | |||
| 02b23b0371 | |||
| 4eeb2a9d11 | |||
| 99408df96a | |||
| 42cde6a494 | |||
| e0783cf8bf | |||
| 0b2baacb92 | |||
| 54c504fa0d | |||
| 26d6f56485 | |||
| 57f20bb25f | |||
| feae9967dc | |||
|  | c4d0fe020f | ||
|  | b0c229d80a | ||
|  | d7fba610a1 | ||
|  | 2a56743f65 | 
							
								
								
									
										41
									
								
								api.lua
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								api.lua
									
									
									
									
									
								
							| @@ -1,5 +1,24 @@ | ||||
| local hudHandlers = {} | ||||
|  | ||||
| ---plants to place in openfarming | ||||
| local plants = { | ||||
| 	["farming:beetroot"]="air", ["farming:blueberries"]="air", ["farming:cabbage"]="air", | ||||
| 	["farming:carrot"]="air", ["farming:chili_pepper"]="air", ["farming:coffee_beans"]="air", | ||||
| 	["farming:corn"]="air", ["farming:cucumber"]="air", ["farming:garlic_clove"]="air", | ||||
| 	["farming:melon_slice"]="air", ["farming:onion"]="air", ["default:papyrus"]="air", | ||||
| 	["farming:pea_pod"]="air",	["farming:peppercorn"]="air", ["farming:pineapple_top"]="air", | ||||
| 	["farming:potato"]="air", ["farming:pumpkin_slice"]="air", ["farming:raspberries"]="air", | ||||
| 	["farming:rhubarb"]="air", | ||||
| 	["farming:seed_barley"]="air", ["farming:seed_cotton"]="air", ["farming:seed_hemp"]="air", | ||||
| 	["farming:seed_mint"]="air", ["farming:seed_oat"]="air", ["farming:seed_rice"]="air", | ||||
| 	["farming:seed_rye"]="air", ["farming:seed_wheat"]="air", | ||||
| 	["farming:tomato"]="air", | ||||
| 	["farming:trellis"]="air", ["farming:grapes"]="farming:trellis", | ||||
| 	["farming:beanpole"]="air", ["farming:beans"]="farming:beanpole", | ||||
| 	["morefarming:seed_wildcarrot"]="air", ["morefarming:seed_teosinte"]="air", | ||||
| 	["morefarming:seed_carrot"]="air", ["morefarming:seed_corn"]="air", | ||||
| } | ||||
|  | ||||
| areas.registered_on_adds = {} | ||||
| areas.registered_on_removes = {} | ||||
| areas.registered_on_moves = {} | ||||
| @@ -91,7 +110,27 @@ function areas:canInteract(pos, name) | ||||
| 	for _, area in pairs(self:getAreasAtPos(pos)) do | ||||
| 		if area.owner == name or area.open then | ||||
| 			return true | ||||
| 		elseif areas.factions_available and area.faction_open then | ||||
| 		end | ||||
| 		if area.openfarming then | ||||
| 			-- if area is openfarming | ||||
| 			local player = minetest.get_player_by_name(name) | ||||
| 			local node = minetest.get_node(pos).name | ||||
| 			if player and minetest.registered_nodes[node] then | ||||
| 				local wstack = player:get_wielded_item():get_name() | ||||
| 				if wstack == "" then wstack = "hand" end | ||||
|  | ||||
| 				--on_dig | ||||
| 				if minetest.get_item_group(node, "plant") == 1 and (wstack == "hand" or minetest.registered_tools[wstack]) then | ||||
| 					return true | ||||
| 				end | ||||
|  | ||||
| 				--on_place | ||||
| 				if plants[wstack] ~= nil and plants[wstack] == node then | ||||
| 					return true | ||||
| 				end | ||||
| 			end | ||||
| 		end | ||||
| 		if areas.factions_available and area.faction_open then | ||||
| 			if (factions.version or 0) < 2 then | ||||
| 				local faction_name = factions.get_player_faction(name) | ||||
| 				if faction_name then | ||||
|   | ||||
| @@ -284,6 +284,28 @@ minetest.register_chatcommand("area_open", { | ||||
| }) | ||||
|  | ||||
|  | ||||
| minetest.register_chatcommand( | ||||
| 	"area_openfarming", { | ||||
| 		params = "<ID>", | ||||
| 		description = "Toggle an area as open farming (anyone can harvest and plant) or closed", | ||||
| 		func = function(name, param) | ||||
| 			local id = tonumber(param) | ||||
| 			if not id then | ||||
| 				return false, "Invalid usage, see /help area_openfarming." | ||||
| 			end | ||||
| 			 | ||||
| 			if not areas:isAreaOwner(id, name) then | ||||
| 				return false, "Area "..id.." does not exist" | ||||
| 					.." or is not owned by you." | ||||
| 			end | ||||
| 			local open = not areas.areas[id].openfarming | ||||
| 			-- Save false as nil to avoid inflating the DB. | ||||
| 			areas.areas[id].openfarming = open or nil | ||||
| 			areas:save() | ||||
| 			return true, ("Area %s to farming."):format(open and "opened" or "closed") | ||||
| 		end | ||||
| }) | ||||
|  | ||||
| if areas.factions_available then | ||||
| 	minetest.register_chatcommand("area_faction_open", { | ||||
| 		params = S("<ID> [faction_name]"), | ||||
| @@ -394,6 +416,8 @@ minetest.register_chatcommand("area_info", { | ||||
| 			table.insert(lines, | ||||
| 				S("You have extended area protection".. | ||||
| 					  " limits (\"areas_high_limit\" privilege).")) | ||||
| 		elseif privs.megabuilder then | ||||
| 			table.insert(lines, "You are a megabuilder (\"megabuilder\" privilege).") | ||||
| 		end | ||||
|  | ||||
| 		-- Area count | ||||
| @@ -406,7 +430,7 @@ minetest.register_chatcommand("area_info", { | ||||
| 		table.insert(lines, S("You have @1 areas.", area_num)) | ||||
|  | ||||
| 		-- Area limit | ||||
| 		local area_limit_line = privs.areas and | ||||
| 		local area_limit_line = (privs.areas or privs.megabuilder) and | ||||
| 			S("Limit: no area count limit") or | ||||
| 			S("Limit: @1 areas", max_count) | ||||
| 		table.insert(lines, area_limit_line) | ||||
| @@ -427,6 +451,9 @@ minetest.register_chatcommand("area_info", { | ||||
| 					limit, size_limit) | ||||
| 				priv_limit_info("areas_high_limit", | ||||
| 					limit_high, size_limit_high) | ||||
| 				table.insert(lines, "Players with the \"megabuilder\" privilege can protect unlimited areas in size and number.") | ||||
| 			elseif privs.megabuilder then | ||||
| 				table.insert(lines, "You can protect areas unlimited in size and number.") | ||||
| 			elseif has_prot_priv then | ||||
| 				size_info(S("You can protect areas"), max_size) | ||||
| 			end | ||||
|   | ||||
							
								
								
									
										4
									
								
								hud.lua
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								hud.lua
									
									
									
									
									
								
							| @@ -44,8 +44,8 @@ minetest.register_globalstep(function(dtime) | ||||
|  | ||||
| 			table.insert(areaStrings, ("%s [%u] (%s%s%s)") | ||||
| 					:format(area.name, id, area.owner, | ||||
| 					area.open and S(":open") or "", | ||||
| 					faction_info and ": "..faction_info or "")) | ||||
| 					area.open and S(":open") or area.openfarming and ":openfarming" or "", | ||||
| 					faction_info and ":"..faction_info or "")) | ||||
| 		end | ||||
|  | ||||
| 		for i, area in pairs(areas:getExternalHudEntries(pos)) do | ||||
|   | ||||
							
								
								
									
										4
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								init.lua
									
									
									
									
									
								
							| @@ -31,6 +31,10 @@ minetest.register_privilege("areas_high_limit", { | ||||
| 	description = S("Can protect more, bigger areas."), | ||||
| 	give_to_singleplayer = false | ||||
| }) | ||||
| -- Mega_builder privilege -- MFF | ||||
| minetest.register_privilege("megabuilder", { | ||||
| 	description = "Can protect an infinite amount of areas." | ||||
| }) | ||||
|  | ||||
| if not minetest.registered_privileges[areas.config.self_protection_privilege] then | ||||
| 	minetest.register_privilege(areas.config.self_protection_privilege, { | ||||
|   | ||||
| @@ -225,6 +225,8 @@ function areas:canPlayerAddArea(pos1, pos2, name) | ||||
| 				.." the necessary privilege.") | ||||
| 	end | ||||
|  | ||||
| 	-- MFF: megabuilders skip checks on size and number of areas | ||||
| 	if not privs.megabuilder then | ||||
| 		local max_size = privs.areas_high_limit and | ||||
| 			self.config.self_protection_max_size_high or | ||||
| 			self.config.self_protection_max_size | ||||
| @@ -234,6 +236,7 @@ function areas:canPlayerAddArea(pos1, pos2, name) | ||||
| 			(pos2.z - pos1.z) > max_size.z then | ||||
| 				return false, S("Area is too big.") | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 		-- Check number of areas the user has and make sure it not above the max | ||||
| 		local count = 0 | ||||
| @@ -257,7 +260,6 @@ function areas:canPlayerAddArea(pos1, pos2, name) | ||||
| 		return false, S("The area intersects with @1 [@2] (@3).", | ||||
| 				area.name, id, area.owner) | ||||
| 	end | ||||
|  | ||||
| 	return true | ||||
| end | ||||
|  | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 123 B | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 157 B After Width: | Height: | Size: 134 B | 
		Reference in New Issue
	
	Block a user