User Tools

Site Tools


python_getstarted

This is an old revision of the document!


Getting Started

This section will cover the very basics for creating your first Mystic Python script. A full function reference for all of the Mystic BBS module will be covered in a different section.

This section assumes you've already performed the installation of Mystic Python as covered in the Installation section.

Creating a Script

A Mystic Python script is simply a text file with Python code in it which can be executed by a number of ways within Mystic BBS. These can be edited with a source code editor or any text editor.

A script typically ends with the file extension of .mpy which stands for “Mystic Python.” This is the current recommended naming convention but in reality a script can have any name or extension that the developer desires to use.

Import Mystic Module

For each script, you first must import the Mystic BBS module at the top of your script by adding this line:

import mystic_bbs as bbs

This will give you all of the BBS related functions addressable with a bbs prefix. For example, you would write a line of text to the user with full MCI code support by using the prefix and function name:

bbs.writeln(“This is a test!”)

Alternatively you could import the Mystic BBS module without a prefix so that you can access the function names directly. Keep in mind that if you do this it is possible that a function name in the Mystic BBS library could conflict with another function name in a different module.

from mystic_bbs import *

This will give you access to all of the Mystic BBS functions without the need of a prefix, for example:

writeln("This is a test!")

Executing a Python Script

python_getstarted.1514675361.txt.gz · Last modified: 2017/12/30 17:09 by g00r00

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki