Page 1 of 1

Getting last command passed by user

Posted: 11 May 2015 07:44
by Vlek
I was wondering if there was a way to retrieve the last command entered by the user. Does this get saved, kind of like args, in the background? If not, is there any temporary fixes that anyone can think of? I've tried making an empty alias that saved all args to a variable, but that did not work. Making a trigger that looks for an ">" in front of a statement to save it did not work either.

Re: Getting last command passed by user

Posted: 10 Oct 2015 07:33
by britanica
A very late answer on what I found works.

Code: Select all

var keys = Object.keys(mud.InputHistory.history);
var last = keys[keys.length-1];
gwc.output.append('last command: ' + mud.InputHistory.history[last]);
The command triggered from the numpad directions does not get added to the history. Directions where the full word is typed in the command input and enter is pressed do get added to the history.

Re: Getting last command passed by user

Posted: 10 Oct 2015 22:30
by Alisa
That is for an alias right?

For some reason these commands confuse me a bit :-)

Re: Getting last command passed by user

Posted: 11 Oct 2015 01:23
by britanica
The code will work in either an alias or a trigger

The difference between the two is that the code for a trigger is run in response to the client receiving a message from the mud server. An alias runs the code when the client receives a command from the player.

Re: Getting last command passed by user

Posted: 19 Oct 2015 14:11
by Snowrose
there is a quicktyper dhorthand of %% that will autoexecute your lastcommand in a do
and it will say doing: whatever last command was.
so if your trying to redo your last command you can use %%.

however if you use %% in an alias it will have a substitute function
ie
alias hhug hug %% happily
and you "hhug friend" you will "hug friend happily"
thus it would be difficult to use %% in an in game alias fir last command reasons.