|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ScriptingEngine
The interface for the main CoffeeMud scripting engine, which implements a scripting engine descended from the old mud codebases of the 90's usually called MOBPROG. Its main features include easy to understand event-oriented triggers, making all mud commands implicit scripting commands. It also includes methods for embedding javascript.
Scriptable
Nested Class Summary | |
---|---|
static class |
ScriptingEngine.ScriptableResponse
An object that holds the information about an event until it is time to execute its associated script. |
Field Summary | |
---|---|
static int |
CONNECTOR_AND
index and equate for logical connector AND |
static int |
CONNECTOR_ANDNOT
index and equate for logical connector ANDNOT |
static int[][] |
CONNECTOR_MAP
A table to describe what happens when connectors are found sequentially (and and not or not and and, etc) |
static int |
CONNECTOR_NOT
index and equate for logical connector NOT |
static int |
CONNECTOR_OR
index and equate for logical connector OR |
static int |
CONNECTOR_ORNOT
index and equate for logical connector ORNOT |
static java.lang.String[] |
CONNECTORS
a list of logical connectors (and, or, etc) |
static java.lang.String[] |
DATETIME_ARGS
a list of the different parts of a time clock |
static java.lang.String[] |
funcs
String list of all valid mobprog functions for logical expressions or string functions |
static int |
GSTATADD_CLAN
index and equate for stat code for mob: clan |
static int |
GSTATADD_CLANROLE
index and equate for stat code for mob: clan role |
static int |
GSTATADD_DEITY
index and equate for stat code for mob: deity |
static int |
GSTATADD_STINK
index and equate for stat code for mob: hygeine |
static java.lang.String[] |
GSTATCODES_ADDITIONAL
a list of some some extra stat codes for mobs |
static java.lang.String[] |
methods
String list of all valid mobprog commands |
static java.lang.String[] |
progs
String list of all valid trigger keywords |
static int |
SIGN_EQGT
Index and equate for => |
static int |
SIGN_EQLT
Index and equate for =< |
static int |
SIGN_EQUL
Index and equate for == |
static int |
SIGN_GRAT
Index and equate for > |
static int |
SIGN_GTEQ
Index and equate for >= |
static int |
SIGN_LEST
Index and equate for < |
static int |
SIGN_LTEQ
Index and equate for <= |
static int |
SIGN_NTEQ
Index and equate for != |
static java.lang.String[] |
SIGNS
List of evaluation signs ==, !=, >, etc. |
static int |
SPECIAL_9SHOPHASPRICE
The index into the local variables array for a random items shop price from shophas |
static int |
SPECIAL_NUM_OBJECTS
The number of local variables associated with an execution of a script |
static int |
SPECIAL_RANDANYONE
The index into the local variables array for a random pc or mob |
static int |
SPECIAL_RANDPC
The index into the local variables array for a random pc |
Method Summary | |
---|---|
java.lang.String |
defaultQuestName()
If this script is associated with a particular quest, this method is called to return that quest name. |
void |
dequeResponses()
Forces any queued event responses to be immediately executed. |
boolean |
endQuest(PhysicalAgent hostObj,
MOB mob,
java.lang.String quest)
Calling this method forces this script to look for a trigger dealing with the end of a quest (QUEST_TIME_PROG -1). |
boolean |
eval(PhysicalAgent scripted,
MOB source,
Environmental target,
MOB monster,
Item primaryItem,
Item secondaryItem,
java.lang.String msg,
java.lang.Object[] tmp,
java.lang.String[][] eval,
int startEval)
Evaluates a scripting function. |
java.lang.String |
execute(PhysicalAgent scripted,
MOB source,
Environmental target,
MOB monster,
Item primaryItem,
Item secondaryItem,
DVector script,
java.lang.String msg,
java.lang.Object[] tmp)
Executes a script in response to an event The scripts are formatted as a 2 dimensional DVector with the first row being the trigger information. |
java.util.List<java.lang.String> |
externalFiles()
If the script is a load command, this will return the list of loaded script files referenced by the load command |
java.lang.String |
functify(PhysicalAgent scripted,
MOB source,
Environmental target,
MOB monster,
Item primaryItem,
Item secondaryItem,
java.lang.String msg,
java.lang.Object[] tmp,
java.lang.String evaluable)
Evaluates one of the boolean functions as a string variable expression, which gives different and informative results. |
java.lang.String |
getLocalVarXML()
If the variable scope of this script is local, this will return all the variables and values defined as an xml document for easy storage. |
MOB |
getMakeMOB(Tickable ticking)
Creates a mob from the Tickable object sent, possibly saving it locally to this object for use later. |
java.lang.String |
getScript()
Returns the script or load command(s). |
java.lang.String |
getScriptResourceKey()
Returns the hey used to cache the script or load commands in here. |
java.lang.String |
getVar(java.lang.String context,
java.lang.String variable)
Returns the value of one of the internal variables, determined by the scope of the script, the context of the variable, and the name of the variable. |
java.lang.String |
getVarScope()
Returns the scope of any variables defined within the script. |
boolean |
isSavable()
Returns whether this script is a temporary attributed of the scripted object, or a permanent on that should be saved with the object. |
boolean |
isVar(java.lang.String context,
java.lang.String variable)
Returns whether an internal variables, determined by the scope of the script, the context of the variable, and the name of the variable, is defined. |
java.lang.String[] |
parseEval(java.lang.String evaluable)
Receives a string for evaluation by the eval function, and stores it as the first element in the given 2 dimensional string array. |
void |
registerDefaultQuest(java.lang.String questName)
If this script is associated with a particular quest, this method is called to register that quest name. |
void |
setLocalVarXML(java.lang.String xml)
If the variable scope of this script is local, this will set all the variables and values defined from a passed in xml document. |
void |
setSavable(boolean truefalse)
Sets whether this script is a temporary attributed of the scripted object, or a permanent on that should be saved with the object. |
void |
setScript(java.lang.String newParms)
Sets the script or load command(s). |
void |
setVar(java.lang.String context,
java.lang.String variable,
java.lang.String value)
Sets the value of one of the internal variables, determined by the scope of the script, the context of the variable, and the name of the variable. |
void |
setVarScope(java.lang.String scope)
Sets the scope of any variables defined within the script. |
java.lang.String |
varify(MOB source,
Environmental target,
PhysicalAgent scripted,
MOB monster,
Item primaryItem,
Item secondaryItem,
java.lang.String msg,
java.lang.Object[] tmp,
java.lang.String varifyable)
Uses this scripting engines variable parsing system to replace any script variables $XXXX with their script determined values. |
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.Tickable |
---|
getTickStatus, name, tick |
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject |
---|
copyOf, ID, initializeClass, newInstance |
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.MsgListener |
---|
executeMsg, okMessage |
Field Detail |
---|
static final int SPECIAL_NUM_OBJECTS
static final int SPECIAL_RANDPC
static final int SPECIAL_RANDANYONE
static final int SPECIAL_9SHOPHASPRICE
static final java.lang.String[] progs
static final java.lang.String[] funcs
static final java.lang.String[] methods
static final java.lang.String[] GSTATCODES_ADDITIONAL
static final int GSTATADD_DEITY
static final int GSTATADD_CLAN
static final int GSTATADD_CLANROLE
static final int GSTATADD_STINK
static final java.lang.String[] DATETIME_ARGS
static final java.lang.String[] SIGNS
static final int SIGN_EQUL
static final int SIGN_GTEQ
static final int SIGN_GRAT
static final int SIGN_LEST
static final int SIGN_LTEQ
static final int SIGN_EQGT
static final int SIGN_EQLT
static final int SIGN_NTEQ
static final java.lang.String[] CONNECTORS
static final int CONNECTOR_AND
static final int CONNECTOR_OR
static final int CONNECTOR_NOT
static final int CONNECTOR_ANDNOT
static final int CONNECTOR_ORNOT
static final int[][] CONNECTOR_MAP
Method Detail |
---|
java.lang.String execute(PhysicalAgent scripted, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, DVector script, java.lang.String msg, java.lang.Object[] tmp)
scripted
- the object that is scriptedsource
- the source of the eventtarget
- the target of the eventmonster
- a mob representation of the scripted objectprimaryItem
- an item involved in the eventsecondaryItem
- a second item involved in the eventscript
- 2 dimensional DVector, the script to executemsg
- a string message associated with the eventtmp
- miscellaneous local variables
ScriptingEngine.ScriptableResponse
java.lang.String varify(MOB source, Environmental target, PhysicalAgent scripted, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp, java.lang.String varifyable)
source
- the source of the eventtarget
- the target of the eventscripted
- the object that is scriptedmonster
- a mob representation of the scripted objectprimaryItem
- an item involved in the eventsecondaryItem
- a second item involved in the eventmsg
- a string message associated with the eventtmp
- miscellaneous local variablesvarifyable
- the string to parse
void dequeResponses()
MOB getMakeMOB(Tickable ticking)
ticking
- the scripted object to make a fake mob out of
java.lang.String[] parseEval(java.lang.String evaluable) throws ScriptParseException
evaluable
- the eval expression
ScriptParseException
- a parse errorboolean eval(PhysicalAgent scripted, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp, java.lang.String[][] eval, int startEval)
scripted
- the object that is scriptedsource
- the source of the eventtarget
- the target of the eventmonster
- a mob representation of the scripted objectprimaryItem
- an item involved in the eventsecondaryItem
- a second item involved in the eventmsg
- a string message associated with the eventtmp
- miscellaneous local variableseval
- the pre-parsed expressionstartEval
- while line to start evaluating on.
java.lang.String functify(PhysicalAgent scripted, MOB source, Environmental target, MOB monster, Item primaryItem, Item secondaryItem, java.lang.String msg, java.lang.Object[] tmp, java.lang.String evaluable)
scripted
- the object that is scriptedsource
- the source of the eventtarget
- the target of the eventmonster
- a mob representation of the scripted objectprimaryItem
- an item involved in the eventsecondaryItem
- a second item involved in the eventmsg
- a string message associated with the eventtmp
- miscellaneous local variablesevaluable
- the function expression
boolean endQuest(PhysicalAgent hostObj, MOB mob, java.lang.String quest)
hostObj
- the scripted objectmob
- a mob representation of the host objectquest
- the name of the quest being ended
java.lang.String getScript()
setScript(String)
,
externalFiles()
java.lang.String getScriptResourceKey()
getScript()
void setScript(java.lang.String newParms)
newParms
- the script or load command(s)getScript()
,
externalFiles()
java.util.List<java.lang.String> externalFiles()
getScript()
,
setScript(String)
void registerDefaultQuest(java.lang.String questName)
questName
- the quest associated with this scriptdefaultQuestName()
java.lang.String defaultQuestName()
registerDefaultQuest(String)
void setVarScope(java.lang.String scope)
scope
- the scope of variablesgetVarScope()
,
getVar(String, String)
,
getLocalVarXML()
java.lang.String getVarScope()
setVarScope(String)
,
setVar(String, String, String)
,
setLocalVarXML(String)
java.lang.String getLocalVarXML()
setVarScope(String)
,
setVar(String, String, String)
,
setLocalVarXML(String)
void setLocalVarXML(java.lang.String xml)
xml
- the local variable values as xmlgetVarScope()
,
getVar(String, String)
,
getLocalVarXML()
boolean isSavable()
setSavable(boolean)
void setSavable(boolean truefalse)
truefalse
- true if this script is a saveable attribute of the scripted objectisSavable()
java.lang.String getVar(java.lang.String context, java.lang.String variable)
context
- the context of the variable, usually a mob or object namevariable
- the name of the variable
setVarScope(String)
,
getVarScope()
,
setVar(String, String, String)
,
isVar(String, String)
,
getLocalVarXML()
,
setLocalVarXML(String)
boolean isVar(java.lang.String context, java.lang.String variable)
context
- the context of the variable, usually a mob or object namevariable
- the name of the variable
setVarScope(String)
,
getVarScope()
,
getVar(String, String)
,
setVar(String, String, String)
,
getLocalVarXML()
,
setLocalVarXML(String)
void setVar(java.lang.String context, java.lang.String variable, java.lang.String value)
context
- the context of the variable, usually a mob or object namevariable
- the name of the variablevalue
- the value of the variablesetVarScope(String)
,
getVarScope()
,
getVar(String, String)
,
isVar(String, String)
,
getLocalVarXML()
,
setLocalVarXML(String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |