The
LexiScript language is an easy to learn scripting language. While it is easy to feel intimidated by it, because of the potential power it possesses, it scales well, starting with extremely simple scripts that are nothing more than a bunch of MUD commands, and going all the way up to sets of scripts, mobs, room, items, that all work together to create new games within the MUD.
Many features in the MUD are scripted. Almost all mob/object/room specific behaviors are scripted. The entire token system is scripted, as are the
The
BASIC concepts of
LexiScript are simple:
- All behavior is contained in a 'script'. Each script has a vnum, and can be edited by the 'scriptedit' command.
- The Script Engine is what runs (executes) the scripts.
- Scripts are often referred to as 'triggers', because they contain a trigger, and a script to run when the 'trigger' occurs. Examples of triggers are when a player types a command, something enters a room, the wearer of an object receives damage, the mob dies, etc. There are many types of triggers, and new ones can be added if you need them.
- Every character (mob or player), object, or room is considered an Entity. An entity can have scripts (triggers) attached to them. Scripts can be attached manually (for testing purposes), by other scripts, or an object/mob/room can load with scripts attached to them via oedit/medit/zedit.
- Scripts consist of a series of commands? and logical expressions? , one per line. Each command does something, such as send a message, move an object, or perform math. Logical expressions control the 'flow' of the script, allowing the behavior to repeat or change depending on conditions.
- Scripts and entities have variables? which contain data - numbers or text. Variables can refer to other entities (mobs, players, objects, or rooms). We'll cover variables more later.
A simple Greet script on a mob might look something like:
bow %actor%
wait 2s
say Greetings, %actor.name%, how have you been?
In the script above,
%actor% is one of the variables that Greet triggers get whenever they run. When a character (mob or player) enters a room, a
reference? to the character is put into a variable named
actor. This reference References and the types of information a variable can contain will be covered more later. You can retrieve the contents of a variable, by surrounding it's name with %%.
The mob will first 'bow' to the
%actor% (Character being greeted). 'bow' is not a special script command; since this is a script on a mob, that means all normal MUD commands including socials are valid script commands. In other words, the simplest script is nothing more than basic MUD commands!
After bowing, the mob will
wait 2s, or 2 seconds. The
wait? command causes the script to pause, and wait for the time to pass, before it continues. It can take it's time in pulses (1/10th of a second), seconds, minutes, and hours.
Finally, after 2 seconds, the mob will say, "Greetings, %actor.name%, how have you been."
%actor.name% is a type of variable usage. Characters, objects, and rooms have
fields? , values that can be accessed by scripts, if you have a
reference? to them. Sample fields are
name,
alias,
level,
mp,
race, and
weight. In this particular case, the
name field means the name of the character referenced by
actor should be used.
There are more complex fields, called
subfields, which allow you to query the kind of information you want to get back. Fields can be chained, such as:
%actor.name.word(3)%.
Recently Changed LexiScript Topics
Mob Triggers Obj Triggers Room Triggers Random Global Global Command Random Random Speech Command Command Act Sit Speech Death Leave ...
affect See LexiScriptCommandAffect for usage Apply timed or permanent affects and attribute modifications to a character. affectmsg affectmsg ...
General Purpose self A reference to the entity the ...
LexiScript Regular Expressions LexiScript now features a full fledged Regular expression (regex) pattern matcher / parser. A regex parser is extremely useful for ...
This is out of date Live Features Thread Control Returns the current ID of a thread, which is a record with the following fields: ...
Functions in LexiScript The LexiScript Function system is a powerful system for encapsulating portions of scripts for easy reuse. If a script has similiar pieces ...
Basic variables Strings Integers Floats Scope Local Global Shared Promotion and Lack Thereof Fields Subfields Lists Lists are, at their heart, space separated ...
One of the more recent additions to scripting, and the one with the potential to significantly enhance gameplay altering scripts, is the 'affect' command. Affects ...
The LexiScript language is an easy to learn scripting language. While it is easy to feel intimidated by it, because of the potential power it possesses, it scales ...
Number of topics: 9
Scratchpad below here, ignore
(references)
A reference is not readable; if you were to look at it it would be a seemingly random number. However, to the MUD, that number is special, and the variable contains a special, unprintable symbol, that the MUD uses to see that the reference is not just a number, but is actually an ID Number for something in the MUD.
You can read more about references here.?
To ACCESS the contents of a variable, it must be enclosed in %%s. What this means to the script engine, is to find the variable, take it's contents, and put the contents of the variable in place of the variable on the line.
For example, if %victim% contained "Dude", then:
say Hey there, %victim%!
Will become:
say Hey there, Dude!