You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
Interpreter mode is a mode that allows you to easily run mscripts from within game, straight from the chat bar! To enter
interpreter mode, type /interpreter. You must have the interpreter enabled in your preferences file, and the user must
have the commandhelper.interpreter permission. Once you are in interpreter mode, your chat bar turns into a script
window, and you cannot chat anymore (well, you could with the chat function... :D). In order to leave interpreter mode,
type a single dash(-) on a line on its own. Now, when you "chat", you can run arbitrary mscripts. To enter multiline
mode, type >>> on a line of its own. Now when you hit enter, the line is added to an ongoing script, which isn't run
until you end the script with <<<. You can cancel the script by exiting interpreter mode with a single dash.
So, what happens when you actually run a script? Well, the script is run exactly how you typed it in. If there are
errors with the script, you'll be notified with an exception, but otherwise scripts will run normally. So, calling:
Copy Code
will cause the word 'hi!' to appear on your screen. One thing to note about the output of a script: just like typical
scripts, if a command ultimately outputs a command, that command is run. The only difference is that other output will
also be displayed on screen, unlike in regular scripts, where it is just ignored. So, for instance, say you have this
script in your config file:
Copy Code
Running the command /test will actually not do anything in this case. That's because pinfo() returns an array, but
otherwise doesn't have any visible effects. When running pinfo() in interpreter mode though, the array will be printed
out to your screen. This will allow you to play around with scripts much more easily, without having to worry about
echoing everything out. One thing to note about the returned output is that all output returned in this fashion will
display on screen starting with a colon. This is to help you differentiate what the output is compared to what the
script is causing. For example:
Copy Code
would cause the following output:
Copy Code
Outputs:
Hello World!
:This is normally ignored
msg('hi!')

1 {{function|msg}}('hi!')
/test = pinfo()

1 /test = {{function|pinfo}}()
msg('')

1 {{function|msg}}('')
:(note the completely blank line above the colon). This is because msg('') outputs an empty string to the screen, and it itself returns void, which is displayed as an empty string. All output that would normally be ignored by CH is shown in green, and output that CH would act on (running a command) is shown in yellow. All errors are shown in red. Also note that the die function does not return anything, which is different than returning void. Due to the underlying mechanism, if a script runs {{function|die}}, no output will be returned at all, which is in fact the same behavior in normal scripts. Running:
msg('Hello World!') This is normally ignored

1 {{function|msg}}('Hello World!') This is normally ignored
Hello World!
:This is normally ignored
Find a bug in this page? Edit this page yourself, then submit a pull request.