forked from mtcontrib/factions
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			nalc-1.0
			...
			2b0aa5fd95
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2b0aa5fd95 | |||
| a596a1bf35 | |||
| 3287b6793f | |||
| 
						 | 
					e5fdd2bdee | 
							
								
								
									
										45
									
								
								chatcommands.lua
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										45
									
								
								chatcommands.lua
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -43,7 +43,7 @@ function factions_chat.init()
 | 
			
		||||
		{
 | 
			
		||||
			params = "<cmd> <parameter 1> .. <parameter n>",
 | 
			
		||||
			description = "faction administration functions",
 | 
			
		||||
			privs = { interact=true },
 | 
			
		||||
			privs = { faction_user=true },
 | 
			
		||||
			func = factions_chat.cmdhandler,
 | 
			
		||||
		}
 | 
			
		||||
	)
 | 
			
		||||
@@ -79,7 +79,7 @@ end
 | 
			
		||||
-------------------------------------------------------------------------------
 | 
			
		||||
function factions_chat.cmdhandler(playername,parameter)
 | 
			
		||||
 | 
			
		||||
	local player = minetest.env:get_player_by_name(playername)
 | 
			
		||||
	local player = minetest.get_player_by_name(playername)
 | 
			
		||||
	local params = parameter:split(" ")
 | 
			
		||||
	local cmd = params[1]
 | 
			
		||||
 | 
			
		||||
@@ -101,13 +101,6 @@ function factions_chat.cmdhandler(playername,parameter)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if cmd == "claim" then
 | 
			
		||||
		minetest.chat_send_player(playername,"Trust me, we're working on it",false)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	if cmd == "unclaim" then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	--list all known factions
 | 
			
		||||
	if cmd == "list" then
 | 
			
		||||
		local list = factions.get_faction_list()
 | 
			
		||||
@@ -126,7 +119,7 @@ function factions_chat.cmdhandler(playername,parameter)
 | 
			
		||||
 | 
			
		||||
	--show factions mod version
 | 
			
		||||
	if cmd == "version" then
 | 
			
		||||
		minetest.chat_send_player(playername, "Factions: version " .. factions_version , false)
 | 
			
		||||
		minetest.chat_send_player(playername, "Factions: version " .. factions.version , false)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
@@ -143,7 +136,7 @@ function factions_chat.cmdhandler(playername,parameter)
 | 
			
		||||
	if cmd == "leave" then
 | 
			
		||||
		if params[2] ~= nil then
 | 
			
		||||
			if params[3] ~= nil then
 | 
			
		||||
				local toremove = minetest.env:get_player_by_name(params[3])
 | 
			
		||||
				local toremove = minetest.get_player_by_name(params[3])
 | 
			
		||||
				--allowed if faction_admin, admin of faction or player itself
 | 
			
		||||
				if minetest.check_player_privs(playername,{ faction_admin=true }) or
 | 
			
		||||
					factions.is_admin(params[2],playername) and
 | 
			
		||||
@@ -189,7 +182,7 @@ function factions_chat.cmdhandler(playername,parameter)
 | 
			
		||||
			if params[3] ~= nil and
 | 
			
		||||
				minetest.check_player_privs(playername,{ faction_admin=true }) then
 | 
			
		||||
 | 
			
		||||
				local toadd = minetest.env:get_player_by_name(params[3])
 | 
			
		||||
				local toadd = minetest.get_player_by_name(params[3])
 | 
			
		||||
 | 
			
		||||
				if toadd ~= nil then
 | 
			
		||||
					if factions.member_add(params[2],toadd) then
 | 
			
		||||
@@ -361,14 +354,14 @@ end
 | 
			
		||||
-------------------------------------------------------------------------------
 | 
			
		||||
function factions_chat.allfactions_chathandler(playername,parameter)
 | 
			
		||||
 | 
			
		||||
	local player = minetest.env:get_player_by_name(playername)
 | 
			
		||||
	local player = minetest.get_player_by_name(playername)
 | 
			
		||||
 | 
			
		||||
	if player ~= nil then
 | 
			
		||||
	  local recipients = {}
 | 
			
		||||
 | 
			
		||||
	  for faction,value in pairs(factions.get_factions(player)) do
 | 
			
		||||
		  for name,value in pairs(factions.dynamic_data.membertable[faction]) do
 | 
			
		||||
			  local object_to_check = mientest.env:get_player_by_name(name)
 | 
			
		||||
		  for name,val in pairs(factions.dynamic_data.membertable[value]) do
 | 
			
		||||
			  local object_to_check = minetest.get_player_by_name(name)
 | 
			
		||||
 | 
			
		||||
			  if object_to_check ~= nil then
 | 
			
		||||
				  recipients[name] = true
 | 
			
		||||
@@ -398,7 +391,7 @@ end
 | 
			
		||||
-------------------------------------------------------------------------------
 | 
			
		||||
function factions_chat.chathandler(playername,parameter)
 | 
			
		||||
 | 
			
		||||
	local player = minetest.env:get_player_by_name(playername)	
 | 
			
		||||
	local player = minetest.get_player_by_name(playername)
 | 
			
		||||
 | 
			
		||||
	if player ~= nil then
 | 
			
		||||
	  local line = parameter:split(" ")
 | 
			
		||||
@@ -412,16 +405,15 @@ function factions_chat.chathandler(playername,parameter)
 | 
			
		||||
	  local valid_faction = false
 | 
			
		||||
 | 
			
		||||
	  for faction,value in pairs(factions.get_factions(player)) do
 | 
			
		||||
		  if target_faction == faction then
 | 
			
		||||
		  if target_faction == value then
 | 
			
		||||
			  valid_faction = true
 | 
			
		||||
		  end
 | 
			
		||||
	  end
 | 
			
		||||
 | 
			
		||||
	  if faction ~= nil and valid_faction and
 | 
			
		||||
	      factions.dynamic_data.membertable[faction] ~= nil then
 | 
			
		||||
		  for name,value in pairs(factions.dynamic_data.membertable[faction]) do
 | 
			
		||||
			  local object_to_check = mientest.env:get_player_by_name(name)
 | 
			
		||||
			  factions_chat.show_help(playername)
 | 
			
		||||
	  if target_faction ~= nil and valid_faction and
 | 
			
		||||
	      factions.dynamic_data.membertable[target_faction] ~= nil then
 | 
			
		||||
		  for name,value in pairs(factions.dynamic_data.membertable[target_faction]) do
 | 
			
		||||
			  local object_to_check = minetest.get_player_by_name(name)
 | 
			
		||||
			  if object_to_check ~= nil and
 | 
			
		||||
				  name ~= playername then
 | 
			
		||||
				  minetest.chat_send_player(name,playername ..": " .. text,false)
 | 
			
		||||
@@ -429,7 +421,7 @@ function factions_chat.chathandler(playername,parameter)
 | 
			
		||||
		  end
 | 
			
		||||
	  else
 | 
			
		||||
		  minetest.chat_send_player(playername,
 | 
			
		||||
			  "Factions: you're not a member of " .. dump(faction),false)
 | 
			
		||||
			  "Factions: you're not a member of " .. dump(target_faction),false)
 | 
			
		||||
	  end
 | 
			
		||||
	  return
 | 
			
		||||
	end
 | 
			
		||||
@@ -463,10 +455,11 @@ function factions_chat.show_help(playername)
 | 
			
		||||
 | 
			
		||||
	MSG("\tAdmin commands:")
 | 
			
		||||
	MSG("\t\t/factions create <factionname> -> create a new faction")
 | 
			
		||||
	MSG("\t\t/factions delete <factionname> -> delete a faction faction")
 | 
			
		||||
	MSG("\t\t/factions delete <factionname> -> delete a faction")
 | 
			
		||||
	MSG("\t\t/factions join <factionname> <playername>   -> join player to faction")
 | 
			
		||||
	MSG("\t\t/factions leave <factionname> <playername> -> remove player from faction")
 | 
			
		||||
	MSG("\t\t/factions invite <factionname> <playername> -> invite player to faction")
 | 
			
		||||
	MSG("\t\t/factions set_free <factionname> <value> -> set faction free to join")
 | 
			
		||||
	MSG("\t\t/factions admin <factionname> <playername> <value> -> make player admin of faction")
 | 
			
		||||
	MSG("\t\t/factions set_free <factionname> <true|false> -> set faction free to join")
 | 
			
		||||
	MSG("\t\t/factions admin <factionname> <playername> <true|false> -> make player admin of faction")
 | 
			
		||||
	MSG("\t\t/factions description <factionname> <text> -> set description for faction")
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										0
									
								
								description.txt
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								description.txt
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								doc/Doxyfile
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								doc/Doxyfile
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										8
									
								
								factions.lua
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										8
									
								
								factions.lua
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -232,10 +232,6 @@ end
 | 
			
		||||
--!
 | 
			
		||||
--! @return true/false (succesfully added faction or not)
 | 
			
		||||
-------------------------------------------------------------------------------
 | 
			
		||||
function factions.claim()
 | 
			
		||||
end
 | 
			
		||||
function factions.unclaim()
 | 
			
		||||
end
 | 
			
		||||
function factions.member_add(name, object)
 | 
			
		||||
	local new_entry = {}
 | 
			
		||||
	new_entry.factions = {}
 | 
			
		||||
@@ -347,7 +343,7 @@ end
 | 
			
		||||
--! @return true/false (succesfully changed privileges)
 | 
			
		||||
-------------------------------------------------------------------------------
 | 
			
		||||
function factions.set_admin(name,playername,value)
 | 
			
		||||
	mobf_assert_backtrace(type(playername) == "string")
 | 
			
		||||
	--mobf_assert_backtrace(type(playername) == "string")
 | 
			
		||||
	if factions.data.factions[name] ~= nil then
 | 
			
		||||
		if value then
 | 
			
		||||
			factions.data.factions[name].adminlist[playername] = true
 | 
			
		||||
@@ -750,11 +746,13 @@ function factions.load()
 | 
			
		||||
			for id,object in pairs(factions.data.objects) do
 | 
			
		||||
				for name,value in pairs(factions.data.objects[id].factions) do
 | 
			
		||||
					if value then
 | 
			
		||||
						if factions.dynamic_data.membertable[name] then -- One of the indexes above is nil. Which one? No idea. //MFF(Mg|07/29/15)
 | 
			
		||||
							factions.dynamic_data.membertable[name][id] = true
 | 
			
		||||
						end
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	else
 | 
			
		||||
		local file,error = io.open(factions_worldid .. "/" .. "factions.conf","w")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user