Thread: MUSHclient
View Single Post
  #4  
Old 06-19-2008, 04:36 PM
Sivamet Sivamet is offline
Wanderer
 
Join Date: May 2008
Posts: 6
Default

I wrote an auto-rescue for MUSHclient incase anyone was looking for one, or whatever. Also posting it just to show off the capibilities of MUSH. There's a trigger, an alias, and a script file. The script is in LUA. To use you'll need 2 functions that I wrote to split strings apart. If you're intersted in using, just reply here or whatnot and I'll post those functions too.

Code:
<aliases>
  <alias
   match="autorescue *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>aRescue_Command("%1")</send>
  </alias>
</aliases>
Code:
<triggers>
  <trigger
   enabled="y"
   match="*attacks on *:*"
   send_to="12"
   sequence="300"
  >
  <send>Do_Rescue("%2");</send>
  </trigger>
</triggers>
And now the script (it's in Red):

Code:
function aRescue_Command(command)
	local cTable = {"List", "Add", "Commands", "Remove", "Report"};
	local cBuf, cExe = "";
	cBuf = strip_first(command);
	cExe = pull_first(command);
	if( cExe == "" or nil) then cExe = command; end
	if( cBuf == cExe ) then cBuf = nil; end

	if( cExe == "commands" ) then
		Note("Current Commands:");
		Note("-----------------");
		for i = 1, table.getn(cTable), 1 do
			Note(cTable[i]);
		end
		Note("-----------------");
		return;
	end

	if( cExe == "add") then
		if(cBuf == "" or cBuf == nil) then
			ColourNote("red", "", "Add who to Auto-Rescue?");
			return;
		end

		local cRes = GetVariable("AutoRescue");
		if(cRes == nil) then
			SetVariable("AutoRescue", "");			
			cRes = GetVariable("AutoRescue");
			SetVariable("AutoRescue", cRes .. "" .. cBuf);
			Note("Added " .. cBuf .. " to Auto-Rescue");
			return;
		end
		if( string.find(cRes, cBuf) ) then
			ColourNote("red", "", cBuf .. " is already being rescued!");
			return;
		end

		SetVariable("AutoRescue", cRes .. " " .. cBuf);
		Note("Added " .. cBuf .. " to Auto-Rescue");
	end

	if( cExe == "remove") then
		if(cBuf == "" or cBuf == nil) then
			ColourNote("red", "", "Remove who from Auto-Rescue?");
			return;
		end
		
		local cRes = GetVariable("AutoRescue");
		if( cRes == nil) then
			ColourNote("red", "", "You aren't rescuing anyone!");
			return;
		end
		if( string.find(cRes, cBuf)) then
			cRes = string.gsub(cRes, cBuf, "");
			SetVariable("AutoRescue", cRes);
			Note(cBuf .. " removed from Auto-Rescue.");
			return;
		else
			Note(cBuf .. " is not on Auto-Rescue.");
			return;
		end
	end

	if( cExe == "list") then
		local cRes = GetVariable("AutoRescue");
		if( cRes == nil) then
			ColourNote("red", "", "You aren't rescuing anyone!");
			return;
		end
		Note("Currently Rescuing: " .. cRes);
		return;
	end

	if( cExe == "report") then
		local cRes = GetVariable("AutoRescue");
		if( cRes == nil) then
			ColourNote("red", "", "You aren't rescuing anyone!");
			return;
		end

		Send("gt Currently Rescuing: " .. cRes);
		return;

	else
		Note("No such arugment supported. To see a list of supported arguments, use the \"commands\" argument.");
	end
end

function Do_Rescue(player)
	local cRes = GetVariable("AutoRescue");
	if( cRes == nil) then	
		return;
	end
	if(string.find(cRes, player)) then
		Send ("rescue " .. player);
		return;
	end
end

Last edited by Sivamet; 06-20-2008 at 01:36 PM.
Reply With Quote