mirror of
				https://github.com/mt-mods/playerfactions.git
				synced 2025-10-27 06:35:17 +01:00 
			
		
		
		
	Change the way to configure : now using minetest.conf
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -3,3 +3,4 @@ | |||||||
| !*.md | !*.md | ||||||
| !mod.conf | !mod.conf | ||||||
| !.gitignore | !.gitignore | ||||||
|  | !settingtypes.txt | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ A simple mod which allows player created factions. Not very useful on its own, i | |||||||
|  |  | ||||||
| ## Usage | ## Usage | ||||||
| We can choose a mode : single or multi factions. | We can choose a mode : single or multi factions. | ||||||
| By default players can only be in one faction at a time. If you want to allow players to join multiple factions at once, add `mode_unique_faction = false` to modpath/settings.txt | By default players can only be in one faction at a time. If you want to allow players to join multiple factions at once, add `player_factions.mode_unique_faction = false` to minetest.conf | ||||||
|  |  | ||||||
| Parameters marked with square brackets ([]) are optional; most of these are only used if mode_unique_faction is false. | Parameters marked with square brackets ([]) are optional; most of these are only used if mode_unique_faction is false. | ||||||
|  |  | ||||||
| @@ -15,7 +15,7 @@ These commands can be used by anyone: | |||||||
|  |  | ||||||
| - `/factions create <faction> <password>`: Create a new faction | - `/factions create <faction> <password>`: Create a new faction | ||||||
| - `/factions list`: List available factions | - `/factions list`: List available factions | ||||||
| - `/factions info <faction>`: See information on a faction. For faction with lot of member we can choose the length of the member's list that's going to be shown by `adding max_members_list = int` to modpath/settings.txt, default is 50. | - `/factions info <faction>`: See information on a faction. For faction with lot of member we can choose the length of the member's list that's going to be shown by adding `player_factions.max_members_list = int` to minetest.conf, default is 50. | ||||||
| - `/factions join <faction> <password>`: Join an existing faction | - `/factions join <faction> <password>`: Join an existing faction | ||||||
| - `/factions leave [faction]`: Leave your faction | - `/factions leave [faction]`: Leave your faction | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								init.lua
									
									
									
									
									
								
							| @@ -20,9 +20,8 @@ for fname, fact in pairs(facts) do | |||||||
| 	end | 	end | ||||||
| end | end | ||||||
|  |  | ||||||
| settings = Settings(MP.."/settings.txt") | factions.mode_unique_faction = minetest.settings:get_bool("player_factions.mode_unique_faction", true) | ||||||
| factions.mode_unique_faction = settings:get_bool("mode_unique_faction", true) | factions.max_members_list = tonumber(minetest.settings:get("player_factions.max_members_list")) or 50 | ||||||
| factions.max_members_list = tonumber(settings:get("max_members_list")) or 50 |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -46,6 +45,7 @@ function factions.get_player_faction(name) | |||||||
| 	if not minetest.player_exists(name) then | 	if not minetest.player_exists(name) then | ||||||
| 		return false | 		return false | ||||||
| 	end | 	end | ||||||
|  | 	minetest.log("warning", "Function factions.get_player_faction() is deprecated in favor of factions.get_player_factions(). Please check updates of mods depending on playerfactions.") | ||||||
| 	for fname, fact in pairs(facts) do | 	for fname, fact in pairs(facts) do | ||||||
| 		if fact.members[name] then | 		if fact.members[name] then | ||||||
| 			return fname | 			return fname | ||||||
| @@ -223,8 +223,13 @@ local function handle_command(name, param) | |||||||
| 	elseif action == "info" then | 	elseif action == "info" then | ||||||
| 		local faction_name = params[2] | 		local faction_name = params[2] | ||||||
| 		if faction_name == nil then | 		if faction_name == nil then | ||||||
| 			faction_name = factions.get_player_faction(name) | 			local player_factions = factions.get_player_factions(name) | ||||||
| 			minetest.chat_send_player(name, S("No faction were given, returning information about your oldest faction (e.g. the oldest created faction you are in)")) | 			if #player_factions == 1 then | ||||||
|  | 				faction_name = player_factions[1] | ||||||
|  | 			else | ||||||
|  | 				minetest.chat_send_player(name, S("You are in many factions, you have to choose one of them : @1", table.concat(player_factions, ", "))) | ||||||
|  | 				return false | ||||||
|  | 			end | ||||||
| 		elseif facts[faction_name] == nil then | 		elseif facts[faction_name] == nil then | ||||||
| 			minetest.chat_send_player(name, S("This faction is not registered")) | 			minetest.chat_send_player(name, S("This faction is not registered")) | ||||||
| 		else | 		else | ||||||
|   | |||||||
| @@ -1,2 +0,0 @@ | |||||||
| mode_unique_faction = false |  | ||||||
| max_members_list = 50 |  | ||||||
							
								
								
									
										2
									
								
								settingtypes.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								settingtypes.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | player_factions.mode_unique_faction (Enable faction mode) bool true | ||||||
|  | player_factions.max_members_list (The max number of members shown with info command) int 50 | ||||||
		Reference in New Issue
	
	Block a user