Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

LPC Language Library

The LPC language is a C-like programming language that allows defining objects in LPMud. A Mudlib is a collection of objects, defined in LPC language, that builds up the virtual world.

Objects

An object in LPMud consists of two parts:

  • Program
    These are binary codes generated by the LPC compiler when translating LPC program files into low-level instructions (aka. opcodes). These opcodes are not executable machine codes for a real world CPU. It is designed for LPMud's virtual stack machine and requires an interpreter for execution.
  • Variables
    These are global variables declared in LPC program files. They hold values of various types, and can be changed to any value (of any type) at runtime. Local variables and function parameters only exist on the stack, and are freed when the function returns.

Object's program and variables are dynamically allocated by the LPMud driver, but managed differently:

  • Programs are reference counted by objects referencing it.
    When a LPC source file is compiled (aka. loaded), an object is created to reference the program. This initial object is assigned a name without #. For example: the object loaded after compiling "/std/room.c" is named "/std/room". When the object is destructed, the reference count is decremented. The program is freed when its reference count reaches zero.
  • Multiple objects can be created using the same program.
    For example, you can "clone" many rooms from the LPC program "/std/room.c", each room is assigned a name such as "/std/room#2", "/std/room#5" ... etc. All these room objects share the same program image in the memory, while having their own copy of variables.
  • Multiple versions of a LPC program can be loaded at the same time.
    An object's program is assigned when when it was loaded or cloned, as well as its copy of global variables. By convention the initial object of a LPC program is not used to represent an entity in the LPMud, but using cloned ones. For example, when a user connects to the LPMud, the Mudlib always clone an object from "/std/user.c" to serve the connection. The program and variables associated to the connecting user is assigned when the user object was cloned. This allows the wizards to modify the LPC source file online and re-compile it (by destructing the initial object), without affecting the other "old versions" of the program still referenced by connected users. This is one of the major advantages that makes LPMud more flexible than other types of MUD.

Types

The LPC language offers several data types to make LPMud programming easy to get started by novice programmers. There are built-in primitive data types: int, float, string and also composite data types such as array, buffer, mapping, object.

Like most modern scripting languages, LPC does not use pointers and has automatic garbage collection.

Primitive data types are always pass-by-value, while composite data types are always pass-by-reference.