[Metis] The Basics

Discuss all kinds of software here including apps, games and operating systems. You can also share software guides and receive help for your software in this section.
User avatar
Pri
Site Admin
Site Admin
Posts: 5433
Joined: Fri Dec 14, 2007 8:59 am

[Metis] The Basics

Mon Dec 17, 2007 12:41 pm

Ok so you want to make something more entertaining then just a reaction bot that says something semi-witty when a user enters or leaves your room.

Lets get started.

1. Editing your MXC.
To start creating you need to open your mxc.xml
So lets get an editor, some suggestions:
Windows Notepad (Included with Windows)
Programmers Notepad http://www.pnotepad.org/download/ (Free)
Notepad 2 http://www.flos-freeware.ch/notepad2.html which is my Personal Choice (Also Free).

2. Learning the Fundamentals
The first script you will make is one called Hello World. Its the notorious first program anyone ever writes when learning a new computer language so thats what we will be teaching.

Move down in your MXC just before the line that says </config> and write the following:

Code: Select all

<command>
<in>hi</in>
<out>Hello World</out>
</command>
4 lines of code have produced your first script command. It's very simple. It's a single-response command. Whenever the bot sees the word "hi" it will output the words "Hello World" in to the main chat for everyone to see. This is the basic way most people write scripts. But lets mix it up a bit.

Let's create a Text recorder instead.

Code: Select all

<command type="script">
<in>hi %PARAM%</in>
<out>Hello World</out>
<out>%PARAM%</out>
</command>
This piece of code is a bit more difficult. When a user says hi and then says something else like this "hi everyone!" the bot will take that user paramter (everyone!) and store it for outputting. Notice we also changed <command> on the first line to <command type="script"> the reason for this is because we now have 2 responses and as such it needs to become a script instead of a basic response command.

So this is how it will look in your room

USER: hi everyone
BOT: Hello World
BOT: everyone

So lets mix it up a bit!

Code: Select all

<command type="script">
<in>hi %PARAM%</in>
<out>Hello %PARAM%</out>
</command>
Now you can see we moved the User Parameter up a line. so now it will look like this:

USER: hi everyone
BOT: Hello everyone

And that is the Fundamentals of writing basic scripts. But to make things that have many more features you need better information retention. Being able to hold many responses in different areas for later retrival is the foundation of practically every bot script.

There are two terms I should explain at this point. Pushing and Popping. When you push data you are moving it from one area to another area. Pretty simple if a user types a message, you can push that message in to a user varible which is stored and can later be accessed. And Popping is when you forcefully wipe that user varible. You can overwrite a user varible by pushing new data in to it or by popping it.

So lets give an example.

Code: Select all

<command type="script">
<in>hi %PARAM%</in>
<out type="push" extdata="store1">%PARAM%</out>
<out>The user param: "$store1$" has been stored.</out>
</command>
Now this is how it will look when a user types "hi everyone" in the main room:

USER: hi everyone
BOT: The user param: "everyone" has been stored.

Lets experiment with a few ways you can store data (There are many).

Code: Select all

<command type="script">
<in>hi %PARAM%</in>
<out type="push" extdata="store1">%PARAM%</out>
<out type="push" extdata="store2">HELLO</out>
<out type="push" extdata="store3">I'm a bot!</out>
<out>The user param: "$store1$" has been stored.</out>
<out>$store2$</out>
<out>$store3$</out>
<out>All together: $store2$ $store1$ $store3$</out>
</command>
So here the script is a little larger. When a user type "hi everyone" this is what will happen:

USER: hi everyone
BOT: The user param: "everyone" has been stored.
BOT: HELLO
BOT: I'm a bot!
BOT: All together: HELLO everyone I'm a bot!

Now in our example we used store1 store2 etc but you can type anything you want for a uservarible. For instance:

Code: Select all

<command type="script">
<in>hi %PARAM%</in>
<out type="push" extdata="david">%PARAM%</out>
<out type="push" extdata="RED">HELLO</out>
<out type="push" extdata="huh">I'm a bot!</out>
<out>The user param: "$david$" has been stored.</out>
<out>$RED$</out>
<out>$huh$</out>
<out>All together: $RED$ $david$ $huh$</out>
</command>
will work just the same.

And there you have it the Fundamentals of Bot Creation. You can post questions in this topic including help requests.

Return to “Software Centre”

Who is online

Users browsing this forum: No registered users and 6 guests