Characters Table

If your prog needs to access character data not in this list, contact Lasher.

Property

Description

align

Current alignment

clan

Character's Clan

class

Primary class

clones

Returns number of same type of mob in the room, excluding self. Always 0 for players.

con

Current constitution. NOTE: All stat values include equipment and spells.

damtype

Character's primary damtype - compare to FOCUS_variables below.

desc*

Character description - read only on players.

dex

Current dexterity

explored

Number of global rooms the character has explored.

exploredhere

Number of in-zone rooms the character has explored.

gold*

Gold on hand

heshe

He/She/It name for current char.

himher

Him/Her/It name for current char.

hisher

His/Hers/Its name for current char.

hp

Current hit points

maxhp

Max hit points

hppct

Percentage of HP remaining

ingame

Number of same mob in-game

following

Return name of character the target is following

gid

Unique integer ID on each char - used for comparison.

groupsize

Number of other people in player's group in room.

gtarget

Same as target, but the previously remember char does not still have to be in the same room.

int

Current intelligence

key

Mob key, blank for a player

keywords

Mob only - returns keywords of the mob. Useful with give etc.

lastroom

Room the character was last in.

leader

Return the name of the character's group leader

level

Level of character

longname*

Mob only - description of mob as seen in room.

luck

Current luck

mana

Current mana

maxmana

Max mana

manapct

Percentage of mana remaining

mobkills

Number of mobs the player has killed.

moves

Current moves

maxmoves

Max moves

movepct

Percentage of moves remaining

name*

Character name - read only on players.

order

Returns order of current mob in room among mobs with the same key. Useful for ensuring a prog only fires once.

owner

Return name of character's owner - only applies to pets.

position

Current position of character

practices*

Player only - practices on hand.

questsdone

Player only - number of quests the player has completed.

race

Character race

racename

Character racename

room

Returns room character is in as a ROOM type variable.

roomkey

Returns key of room character is currently in.

saves

Current saves

sex

Male returns 1, sexless returns 0, female returns -1.

str

Current strength

subclass

Character subclass

target

Returns mob's target as 'CH' type. See below.

tier

Current tier of character

totlevel

Total level as it would appear on rank 1.

trains*

Player only - training sessions on hand.

wis

Current wisdom

MUD Table Definitions

When using properties such as race, class, subclass and clan, the values returned are numbers. If you happen to know that Troll is race number 11, you could write something like:

 if ch.race == 11 then
   say("Hi Troll!")
 end

While this works, it is not very convenient. To help with comparing values in tables, several of the game tables have their contents loaded into Lua for easier comparison. The following are all valid:

 if ch.race == RACE_TROLL ...
 if ch.class == CLASS_MAGE ...
 if ch.subclass == SUBCLASS_ARCHER ...
 if ch.clan == CLAN_SHADOKIL ...
 if ch.sex == SEX_FEMALE ...
 if ch.position == POS_SITTING ...

Lua Object Return Types

Some of the properties on objects will return other objects on the stack rather than string or integer values. Once you have a variable of this type, all of the usual properties are available on it. For example, when 'targ = self.target' returns the mob's target, then all the properties of 'targ' are available using targ.level, targ.int, etc.

Comparing Lua Object Return Types

One other important point for builders to remember is that similar objects in Lua do not compare as equal. For example, if Razor triggers a program (ch) and the mob gets it's target (targ) then wants to see if Razor is already it's target, it cannot simply do if ch == targ. This is because the two variables are two different objects in Lua that just happen to point to the same underlying character in the MUD. Every character in the game has a unique 'gid' value and this is what should be used for comparison.

In the sample Lua code below, the mob checks if it has a target already. If it doesn't, it remembers the character triggering the prog. If it does, it wants to either inform the player that they are its target, or inform the player who the target it. The 'gid' character property is used for the comparison:

 targ = self.target
 if targ == nil then
   say ("I don't have a target")
   remember(ch)
 else
   if (targ.gid == ch.gid) then
      say ("Hi! You're my target!")
   else
      say ("My target's name is " .. targ.name)
   end
 end

As we get into more advanced Lua programming and store character information for later re-use (in prog timers for example), it is always the 'gid' that will be stored, never a direct pointer to the character themselves which can be become invalid if the target character quits/is killed in the meantime.

Related Pages