[Feature Request] SysDataUserCommandRequestEvent

Post Reply
Avaloniac
Posts: 13
Joined: Wed Nov 18, 2009 8:40 pm
Location: avalon.mud.de
Contact:

[Feature Request] SysDataUserCommandRequestEvent

Post by Avaloniac »

hey, for a command queue i need do differ send requests from user command and send(), so a user command event would be nice, or a way to bypass SysDataSendRequest.

regards, Avaloniac.

Widjet
Posts: 30
Joined: Thu Apr 22, 2010 1:43 am

Re: [Feature Request] SysDataUserCommandRequestEvent

Post by Widjet »

Could you not override the send function so that it toggled a flag for use with SysDataSendRequest?
eg:
Code: [show] | [select all] lua
function newSend(cmd)
  this_is_send_command = true
  send(cmd)
end

function onSysDataSendRequest()
  if this_is_send_command then
    --Send command.
  else
    --User command.
  end
  this_is_send_command = false
end
Putting in another event is of course possible, but you can work around the lack, can't you? You could also work around it by having an alias (.+) that captures anything that the user tries to send.

Or am I misinterpreting your request?

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: [Feature Request] SysDataUserCommandRequestEvent

Post by Oneymus »

I believe the new function suggestion is the best way to go. If you want to overwrite the current send, I would recommend this method:
Code: [show] | [select all] lua
do
  oldSend = send
  function send (what)
    send_flag = true
    oldSend( what )
  end
end

Widjet
Posts: 30
Joined: Thu Apr 22, 2010 1:43 am

Re: [Feature Request] SysDataUserCommandRequestEvent

Post by Widjet »

One addendum to Oneymus' code though - make sure you don't run that code twice! Every time you run that code, you're wrapping send in an additional function, which will slow things down.

Also, send() can take a second parameter, so you might want to pass that through as well (if you ever want to do hidden sends).

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: [Feature Request] SysDataUserCommandRequestEvent

Post by Vadi »

... and all in all, be careful when tinkering with send(), a lot of scripts use that so if you mess it up, things can break (until you restart Mudlet anyway). This is one feature in Lua that's extremely powerful but you want to have some knowledge when fiddling with it ;)

Post Reply