Possible setcommand problem...

Posted by Shadowfyr on Thu 29 May 2003 11:02 PM — 6 posts, 15,143 views.

USA #0
I am using the following:

<aliases>
  <alias
   name="TwiCast"
   script="Flagcast"
   match="tf *"
   enabled="y"
  >
  </alias>
</aliases>

sub Flagcast (AName, Output, Wildcards)
  dim Teststr
  Teststr = Trim(Wildcards(1))
  world.note getcommand '*****
  if Teststr <> "koryo" and Teststr <> "slave" then
    if AName = "Flagcast" then
      world.setcommand "lig"
      world.send "flag " & Teststr
      world.send "lightning " & Teststr
    else
      world.setcommand "twi"
      world.send "flag " & Teststr
      world.send "twister " & Teststr
    end if
  else
    world.note "Oops, you almost attacked your slave!!!"
  end if
end sub


The ***** line was to test to see what was going on. Seems that Mushclient is doing this:

1. You type command and hit enter.
2. Client clears the input window.
3. Client processes the alias and calls the script.
4. Script tries to use setcommand, but fails since it still thinks 'tf somemob' is in there.
5. Client finally gets around to blanking its internal memory of the command.

I am guessing that instead of checking to see if the actually 'input' window is blank it is instead checking a variable that it uses to execute additional aliases/commands? This kind of makes 'setcommand' a bit pointless.
Australia Forum Administrator #1
Actually, without actually looking at the source, I think it is simpler than that:

a) You type the command
b) The client processes the command
c) After it is processed, the command window is cleared (unless 'repeat command' is set)
USA #2
Hmm. I see. Hard to tell since you also don't see the sent commands until after the script exits. In any case it didn't exactly do what I was expecting. :p In theory, once you hit enter the command is no longer pending, but being executed, so the command line should be empty. The only way around this would be to push the command onto the history list, but you would likely get a duplicate entry and makes no particular logical sense. I think it is backwards imho.
Australia Forum Administrator #3
Why would you get a duplicate? The original one would be pushed, and the new one would replace it.
USA #4
Umm. Not real clear what order things work in. I can see two possibilities:

>Command typed.
Processing.
--Push command.
--Place new command.
----Client places command in history.

>Command typed.
Processing.
--Push command.
--Place new command.
----Client sees command already in history and discard the duplicate.

Also, if you push it, then does it still run through additional aliases if more than one matches and you allow it? You see the problem? Besides I set up a temporary one shot timer to do it, which works, assuming I can get used to not retyping the command it feeds me. ;) lol
Australia Forum Administrator #5
I'm not at my development PC right now, but what I think it does is:

a) pull the command from the command window when the <enter> key is pressed

b) process it

c) push the command it processed (not whatever might now be in the command window) into the command history

d) clear the command window (?) But I might be wrong about that.