Page 1 of 1

Execute default command on right mouse button press

Posted: 25 Mar 2015, 21:34
by Godde
This simple widget executes default commands on right mouse button press. Makes it easier to target stuff with default commands.
It has been disabled for move commands to make it easier to draw customFormation move lines.
Guard commands can be disabled easily aswell if you want it to be easier to draw lines of move commands on top of friendly units.

Re: Execute default command on right mouse button press

Posted: 28 Mar 2015, 07:10
by Forboding Angel
Can you explain this better?

Re: Execute default command on right mouse button press

Posted: 29 Mar 2015, 07:55
by Godde
A mouse button click consist of button press and button release. Default behaviour on mouse button click, for most commands, is that you get a single target command if you don't move the mouse between button press and button release and that you get an area command if you move the mouse between button press and button release.
The default commands, or "context-sensitive" commands, is the commands that you get when you have units selected and hover the mouse over a unit or feature. Then you can see the context-sensitive mouse cursor changing between different command cursors. If you have units with weapons selected and hover the mouse over an enemy, you will get an attack command for example.
This widget overrides the default behaviour for right mouse button click and gives the default command to your units directly on right mouse button press. This makes it easier to target a specific unit with a default command because it doesn't matter if you move the mouse between button press and button release. With the default mouse behavior, you will get an area command if you move the mouse and that area command could miss the intended target or target another unit first.
For further discussion, see topic: Targeting, precision and ambiguity when using the mouse.

While move commands could also be executed on mouse button press to target location, I personally find line move commands much more useful even if they are a bit slower to perform.

Re: Execute default command on right mouse button press

Posted: 29 Mar 2015, 17:59
by 8611

Code: Select all

exceptions.CMD_MOVE		= CMD.MOVE
...
function CheckCommand(number, commandList)
	for _, command in pairs(commandList) do
		if command == number then
			return true
		end
	end
	
	return false
end
Why not: (untested)

Code: Select all

function CheckCommand(number, commandList)
 return commandList[number] or false
end
You already know the index where something is, so can just check that instead of looping through whole table.

Re: Execute default command on right mouse button press

Posted: 29 Mar 2015, 19:34
by Godde
8611 wrote:You already know the index where something is, so can just check that instead of looping through whole table.
True that. Yeah. I'm not thinking like its a Lua table.