Author
Topic: metis script (Read 5435 times)

hi any chance of getting some help with a script for Metis 2.6\RoboMX. i would like to be able to add movies to a movie list , saved in .xml which currently follows this address :- D:\777\Metis 2.6\Add-Ons\New.xml

Is there any particular reason why you want the file to save as xml? Saving it as .txt or .ini would be much easier and would accomplish what your looking to do (unless you have an idea for which xml is absolutely required).

You could check out this thread, the script sounds like what your looking for..

This will setup the script and accept the movie you want to add. I've also added a single output that merely tells you the name of the movie you added so you know it is working.Then directly underneath that you would have this code:

the above piece of code tells the bot to load in our previously saved movie listings. We want to load them in before we try to save anything so that your old list doesn't get over-written on your hard drive. In the above example I'm using C:\Movie.List.txt but you can modify this to anywhere on your hard drive.

Now here is the code to actually control the movie entries as they are being added to your listings

This code will move your movie entries up by one in the list and add your new entry to the variable called movie01. When we read this list back the newest entry will be at the top.Directly after this you want a way to save these entries to your hard drive so when your bot shuts off the list isn't lost. So after that piece of code add this piece of code

This piece of code will save all the entries to the text file C:\Movie.List.txt - You can change this to a file anywhere on your computer. The \n between each entry is what is called a newline and on windows and other operating systems this is interperated as a line break. Basically each entry will be on its own line inside the text file. This means we can easily read it back.

You'll also notice at the bottom I added </command> that is simply because that part of the script (adding files) is done now. So this tells Metis that script is finished.

We use the same command structure but this time we don't need the %PARAM% because the user isn't supplying any parameters, they are just giving a command. I've also changed the output to merely say "List of our Movies!" again so that you know the bot is doing something even if your list of movies is blank.

The above piece of code simply outputs the list of movies in to the room. If you wanted to make this private and you were using WCS or RSWCS you would add /hidecmd /privnotice %NAME% to the front of each line like this:

And then only the user who used the !movies command would see the list of movies. You will also note I included another </command> as that is the final part of that code. Now some notes about this code, it is quite inefficient as each time one of the commands is being used it is loading in 10 lines of text from your hard disk instead of serving the entries from memory. To make it work more efficiently would have made the script more complicated and I wanted this to be as simple as possible so you could understand how it works and hopefully make stuff for yourself and others in the future and also to help anyone else that stumbles across this code example.

I will now supply the complete script in a code tag for easy copying and pasting:

worked like a dream m8 i do appreciate your time and effort on this, i even sussed how to change where files are stored at increased total from 10 to 40, quite pleased with myself. .one last thing what can i do so that only @ can add? seems to me at mo anyone can access it. thx in advance

Basically what this code is doing is checking the users mode in the room, it can either be blank, a + or an @ just like you see in the chat rooms. The condition value here is != which means if the usermode does not match @ then the script will "break" meaning stop. So by placing this piece of code at the top of the script where you add files you're making the script check that the user performing the command has an @ in the userlist and if they don't it won't allow the script to run.

Something to note about this is, if you're using Metis 2.80, 2.81 or 2.82 this won't work. You need to use Metis 2.83 or better. If you need such a Metis you can use my distribution of Metis that you can get here: http://www.mxpulse.com/board/viewtopic.php?f=9&t=405 You will only need to download the metis.r2x and replace the one found in your plugins folder then restart your bot. I recommend you backup your old metis.r2x (don't leave it in the same folder or rename it, physically move it to another folder) just in-case you need it