Lua MUD Object Properties

Accessing Object Properties

Using 'ch' as an example which represents a character object in the MUD, accessing properties is as simple as using 'ch.level', '', '', etc.

Example code may be:

if ch.level > 100 then
   send(ch,"You are a noble!")
if <  --- remember, self is the mob running the prog.
   say("I'm smarter than you!")
   say("You're smarter than me!")

If you are dealing with an object, you may write something like

if obj.level < 100 then
   say ("I don't accept this low level junk!")
   mdo ("give " .. .. " " ..

The line beginning 'mdo' is using Lua concatentation to create a command the character will execute in the MUD itself - in this case returning the object to the character that triggered the script.

Related Pages