[Home] [Downloads] [Search] [Help/forum]


Script function


Read about scripting




Executes a command as if you had typed it into the command window


long Execute(BSTR Command);

View list of data type meanings


The Execute function lets you execute arbitrary commands as if they were typed into the command window.

The command will be parsed exactly the same as the command window parser, depending on currently-set options (eg. speedwalking, command stacking, scripting etc.).

The only difference is that the command will:

* Not be placed in the command history (as you didn't actually type it in)
* Not unpause the output window if it is paused

There is a possibility that you might accidentally nest calls to execute, for example if an alias called itself, so MUSHclient limits nested calls to the Execute function to 20 levels of nesting.

Note that the Execute function ignores the auto-say setting. Thus you can still use Execute to do things, even if the player has turned on auto-say for a quick chat. However if you are planning to do script commands you will need to be sure that the scripting prefix has not changed.

If you are planning to execute a script using Execute you should probably find the current script prefix (using world.GetOption) rather than relying it on being the same all the time.

Available in MUSHclient version 3.35 onwards.

VBscript example

world.Execute "north"  ' normal command
world.Execute "#4s 3e"  ' speed walk
world.Execute "/world.Debug ""colours "" "  ' execute a script

Jscript example

world.Execute ("north");  // normal command
world.Execute ("4s 3e");  // speed walk
world.Execute ("/world.Debug ("colours ") ");  // execute a script

PerlScript example

$world->Execute ("north");  # normal command
$world->Execute ("4s 3e");  # speed walk

Python example

world.Execute ("north")  # normal command
world.Execute ("4s 3e")  # speed walk
world.Execute ("world.Debug ("colours ") ")  # execute a script

Lua example

Execute ("north")  -- normal command
Execute ("4s 3e")  -- speed walk
Execute ("/Debug ('colours') ")  -- execute a script

Return value

eOK: Executed OK
eWorldClosed: World is closed
eCommandsNestedTooDeeply: Commands nested too deeply

View list of return code meanings

See Also ...


(Send) Sends a message to the MUD

(Help topic: function=Execute)

Documentation contents page

Search ...

Enter a search string to find matching documentation.

Search for:   

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]