Skip to content

Redwall MUCK Site

Sections
Personal tools
You are here: Home » Programming Area » MPI Tutorials » Multipul MPI arugments
« November 2008 »
Su Mo Tu We Th Fr Sa
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
 

Multipul MPI arugments

How to get many arguments out of one {&arg}
The other day I was paged with some one asking me how to get multipul arguments for a MPI program they wanted.

You see, they needed to get 3 arguments in one line of text: Give -player- -ammount- -money-type-

I thought about it for a bit and then it hit me: make it a list!

I'm suprised that I didn't think of it before, but I did now so thats what counts, rite?

There was a small error on my part but it was fixed so all's good now and it works.

So, I'll go through this with you the same way I went through it with them.

First, you need an argument: {&arg}
Okay, but what about making it more arguments? Ah, well we need to make it into a list then! We can use {Subst:x,y,z} for this if we change all spaces into new lines like so:
{subst:{&arg}, ,\r}
(Incase you don't know, \r does the same thing as {nl}.)

Well thats all good and well, but how do we select each line to fit our needs? Easily! We can use the function {sublist:x,y} to select the needed line of the argument.

So we wrap that around the previous statment:
{sublist:{subst:{&arg}, ,\r},XYZ}
--->Replace XYZ with the line number needed.

This allows you to use as many arguments as the user puts in, and opens worlds of possabilities for what you can do with one command (you can actually use one command for eveything without using multipul names... meaning that any player can add commands onto somthing in a "mpi playground" of sorts).

For example, lets you want to have a two-argument line:
give -player- -ammount-

You could set it up so the first line is setup to store ammount under the player's money prop.

This holds many uses of course, such as games, security, chat, playgrounds, banking systems, item systems, single line with many commands to store somthing... etc...

Well, hope that helps.

Untill next time,
-Drakain Zeil

Thanks to Marie on RW MU* for asking me about it.
Created by DZeil
Last modified 2004-08-01 06:37 PM
 
 

Powered by Plone

This site conforms to the following standards: