A pack of binds

Spencer asked me to write a script that allowed binding a few chat commands. Namely, getting the scale of an object, undoing, hovering, getting favorites, and repeating the last scaling command performed by the user.

I figured someone else might get some use out of it too. It may interfere with other chat related scripts. Act accordingly.
// Chat binds for Spencer
// Written by Thyth for use on The-Construct.net servers
// 12/29/2009

package spencerbinds
{
	// add the keybinds to the options dialog so the settings can be bound
	function OptionsDlg::onWake(%this)
	{
		if (!$spencerbound)
		{			
			$RemapName[$RemapCount] = "[Spencer Bind] /getscale";
			$RemapCmd[$RemapCount]  = "spencer_getscale";
			$RemapCount++;

			$RemapName[$RemapCount] = "[Spencer Bind] /undo";
			$RemapCmd[$RemapCount]  = "spencer_undo";
			$RemapCount++;

			$RemapName[$RemapCount] = "[Spencer Bind] /bf";
			$RemapCmd[$RemapCount]  = "spencer_buyfavs";
			$RemapCount++;

			$RemapName[$RemapCount] = "[Spencer Bind] /hover";
			$RemapCmd[$RemapCount]  = "spencer_hover";
			$RemapCount++;

			$RemapName[$RemapCount] = "[Spencer Bind] Last /objectscale";
			$RemapCmd[$RemapCount]  = "spencer_lastobjectscale";
			$RemapCount++;
			
			$spencerbound = 1;
		}
		
		parent::onWake(%this);
	}

	// capture outgoing chat to capture use of /objectscale
	function MessageHud_Edit::eval(%this)
	{
		if(!MessageHud.isTeamMsg)
		{
			%text = trim(%this.getValue());
			%search = "/objectscale ";
			if (getSubStr(%text, 0, strlen(%search)) $= %search)
				$spencer_lastscale = trim(getSubStr(%text, strlen(%search), strlen(%text)));
		}

		if(MessageHud.isTeamMsg)
			commandToServer('TeamMessageSent', %this.getValue());
		else
			commandToServer('MessageSent', %this.getValue());

		MessageHud.close();
		Parent::eval(%this);
	}
};
if (!isActivePackage(spencerbinds))
	activatePackage(spencerbinds);

function say(%s)
{
	commandToServer('MessageSent', %s);
}

function spencer_getscale(%val)
{
	if (%val)
		say("/getscale");
}

function spencer_undo(%val)
{
	if (%val)
		say("/undo");
}

function spencer_buyfavs(%val)
{
	if (%val)
		say("/bf");
}

function spencer_hover(%val)
{
	if (%val)
		say("/hover");
}

function spencer_lastobjectscale(%val)
{
	if (%val)
	{
		if ($spencer_lastscale $= "")
		{
			addMessageHudLine("/objectscale not yet used. Must use it before it can be repeated.");
			return;
		}
		say("/objectscale " @ $spencer_lastscale);
	}
}

Comments

Sign In or Register to comment.