0

Introduction

I've been attempting to build this project for many weeks now, and trying multiple solutions that I can't get my head around. Let me describe the project a little. It's a text-based server, that players can login to (via telnet or a client), essentially like a MUD. They can then create and interact with 'objects', giving them 'verbs' and 'properties'.

The server is basically just a database of 'objects', each object has an ID, a name, a location (which is another object), a list of its contents (objects) and some other flags. Objects can have 'verbs' and 'properties'. Properties are just stored data (string, int, float, w/e). Verbs are methods/functions. Objects are interacted with using commands such as "put something in container". An old version of the server already exists, it's called LambdaMOO. I'm attempting to re-create it since it hasn't been updated in a very, very long time.

You can read more in-depth about how objects, verbs and properties should work at: http://bit.ly/17XIqjY

An Example

Let me describe what I'd like. Imagine we have an object. Object #256, it's called "Button". It has the property "count" along with all the default properties that are inherited from it's parent (i.e. 'description'). It has one "verb" on it, called "push". This verb contains this code:

this.count += 1;
this.description = "This button has been pushed " + this.count + " times.";
player.tell("You press the button and feel a chill run down your spine.");

When the player types 'push button' on the server, the 'push' verb will run and output

You press the button and feel a chill run down your spine.

If you then look at the button, you'll see it's updated description.

Note that player in the above script refers the object of the player executing the verb. tell is another verb, on the player object. However the tell verb has a flag saying it is executable from other verbs.

What language?

My main question is what languages can I use for the 'verbs'? I've tried using node.js and the 'vm' library. I've tried using C# to parse C#. I've tried using C# to parse JavaScript. The issue I keep getting is that I have no way of controlling the permissions of the verbs and properties. If I translate them to literal functions in JavaScript, I can't determine which object they are running on and what permissions it should have. If a user calls a function on another users object, I have no way of intercepting that call and stopping it if the permissions aren't correct. I'm not entirely fussed as to which language is used for the verb code it just needs to be "sandboxed". Properties need to be only readable/writeable when they are set to be so by the user, same with verbs. I imagine I could use a language with overloading (like PHP's __get, __set, __call).

I need to also be able to inject these variables into the verb: (mostly determined from the command typed, unless the verb is being called from another verb)

player (object)          the player who typed the command
this (object)            the object on which this verb was found
caller (object)          this will be the same as ‘player’, unless another
                           verb calls the command in which case it is the object
                           containing that verb.
verb (string)            the first word of the command
argstr (string)          everything after the first word of the command
args (list of strings)   a list of the words in ‘argstr’
dobjstr (string)         the direct object string found during parsing
dobj (object)            the direct object value found during matching
prepstr (string)         the prepositional phrase found during parsing
iobjstr (string)         the indirect object string
iobj (object)            the indirect object value

I also need to be able to access any object from any other object (so long as the permissions work out).

// Object #128. Verb: multiply   Prep: this none this   Perms: +r +x
return (args[0] * args[1]);

// Object #256. Verb: square     Prep: this none this   Perms: +r +x
return #128:multiply(args[0], args[0]);

// Object #512. Verb: touch      Prep: any any this     Perms: +r
// Has a property (int) 'size' on it.
this.size = #256:square(this.size);
this.description = "It's a large button, it spans " + this.size + " metres.";
player:tell("You touch the button, it gets bigger.");

The user could then push button and the button object's size property would be squared.

Recommended Reading

I highly recommend you to read the document at http://bit.ly/17XIqjY for a more in-depth idea of how the system should work.

It is also recommended you read the following documents, as μMOO is based upon LambdaMOO and it’s methodology:

tobyink
  • 13,478
  • 1
  • 23
  • 35
R4wizard
  • 69
  • 8
  • While I appreciate the detail of this question, I recommend you edit it down a bit to get at the main question more concisely. Also FYI, there is an active MOO dev community: https://groups.google.com/forum/#!forum/moo-talk – georgek Sep 24 '13 at 01:51
  • I am aware of the MOO Talk forums, however that forum is very much orientated around the original MOO server and core. This is a completely new project based upon the old one's principles. I understand how the old one works very well, and I don't think there is much they could help with in regards to this post. I'll try it anyway. I'm also not sure if I can edit the question down more without making it more vague and in doing so, the answers i'll get won't take the whole concept into account. – R4wizard Sep 24 '13 at 14:56
  • Do a search of LambdaMOO on GitHub. There are several modern ports you could check out. – Brendan Jan 19 '18 at 04:33
  • I am interested in this. But the question is old. What is the current status? – Jerry Jeremiah Nov 02 '20 at 04:56

1 Answers1

1

I take this question as asking for a language that could do what you need. That's what I'll try to answer.

First, this task is hopelessly unsuited to any mainstream or imperative language such as C# or Java. I wouldn't even think about it. Javascript is possible, but not what it's good at and nothing specific to recommend it.

Second, if you had the right skills, it would be an excellent opportunity to design an entirely new language and spend the next year or two getting it working. People really do that, but I don't recommend it unless you like that kind of masochistic experience. [I do.]

So my recommendation is that you widen your language experience until you find a match. Of the languages I know moderately well, Ruby is the best to try first. As soon as you said inject these variables into the verb you made me think of Ruby, because lots of Ruby software (including Rails) is built exactly like that. Forget Python, Perl and Javascript: I really don't think they will hack it.

Beyond Ruby you might contemplate Lua. I haven't used it much recently, and it may not suit, but it is widely used as a games scripting language.

Beyond that are the true functional languages. There is the most ancient of them all: Lisp. You can do absolutely anything in Lisp, including implementing the language you were looking for in the first place. Then there are Scala and Haskell, to name just two. They are mind-bending to learn, but well suited to the kind of problem you have.

Not much of an answer because it basically says: learn each of these languages in turn until you find one that works for you. [Happy to help further if I can. I have fond memories of Moo.]

david.pfx
  • 10,520
  • 3
  • 30
  • 63
  • I've been considering designing it's own language, but having difficulty going up to that level. I'm not an amatuer programmer but designing a language is not something i've looked into with great depth. Do you have an email address I can contact you on? Maybe we can get working on something. MOO sparked my interest in computers a great deal, and I haven't stopped since, I'd love to move it into modern times. – R4wizard Mar 16 '14 at 04:10
  • If you email davidb at either of the companies mentioned in my profile, that will reach me. – david.pfx Mar 16 '14 at 14:14