Skip to content

Variable Methods

GodDragoner edited this page May 17, 2018 · 14 revisions

Variables

getVar(String variableName)

Gets the value of a variable.

Parameters: variableName - The name of the variable you want to get the current value of

Alias: checkVar, getDate, getVariable

Example:

setVar("test", true);
if(getVar("test")) {
   sendMessage('Test');
}

getVar(String variableName, Object defaultValue)

Gets the value of a variable and if it does not exist it returns the default value.

Parameters: variableName - The name of the variable you want to get the current value of

defaultValue - The default value that is returned if the variable does not exist

Example:

if(getVar("test", false)) {
   sendMessage('Test');
}

setVar(String variableName, Object value)

Sets the value of a given variable.

Parameters: variableName - The name of the variable you want to set the current value of

value - The value you want to assign to the variable

Alias: setVariable, setFlag

Example:

setVar("someBoolean", true);

setVar("someNumber", 2);

setVar("someFloat", 5.5);

setVar("someString", "Hello world!");


setTempVar(String variableName, Object value)

Sets the value of a given variable temporary for this session only.

Parameters: variableName - The name of the variable you want to set the current value of

value - The value you want to assign to the variable

Alias: setTempVariable, setTempFlag

Example:

setTempVar("someBoolean", true);

setTempVar("someNumber", 2);

setTempVar("someFloat", 5.5);

setTempVar("someString", "Hello world!");


deleteVar(String variableName)

Deletes a given variable including its value not matter if the variable is temporary or not.

Parameters: variableName - The name of the variable you want to delete

Alias: delVar, deleteVariable

Example:

deleteVar("someBoolean");

deleteVar("someNumber");


setDate()

Returns a date object of the current time.

Example:

date = setDate();
date.addMinute(5).addDay(5);
sendMessage(date.hasPassed()); // Prints false

date.addDay(-6);

sendMessage(date.hasPassed()); // Prints true

//Other example
setDate("nextWeekCheckDate", setDate().addDay(7).setHour(0).setSecond(0).setMinute(0));

setDate(String variableName)

Sets a given variable to the current date.

Parameters: variableName - The name of the variable you want to set to the current date

Example:

setDate("someDate");

date = getVar("someDate");

date.addMinute(5).addDay(5);

sendMessage(date.hasPassed()); -> Prints false

date.addDay(-6);

sendMessage(date.hasPassed()); -> Prints true


setDate(String variableName, TeaseDate date)

Sets a given variable to the given date.

Parameters: variableName - The name of the variable you want to set to the given date

date - The date you want to set the variable to

Example:

date = setDate();
date.addDay(5);
setDate("testDate", date);

//Alternative
setVar("testDate", date);


setTempDate(String variableName)

Sets a given variable to the current date temporary for this session only.

Parameters: variableName - The name of the variable you want to set to the current date

Example:

date = setTempDate("someDate");

date.addMinute(5).addDay(5);

sendMessage(date.hasPassed()); -> Prints false

date.addDay(-6);

sendMessage(date.hasPassed()); -> Prints true


isVar(String variableName)

Returns true if the variable exists/was set before.

Parameters: variableName - The name of the variable you want to check for

Alias: isVariable

Example:

setVar("test", true);
if(isVariable("test")) {
   sendMessage('Test exists!');
}

registerVar(String variableName, String customName, String description)

Sets the custom name and description of a given variable and will mark it as supported by the personality. Use case? If you want users to modify supported variables without any hassle using the gui.

Parameters:

variableName - The name of the variable you want to register as supported

customName - The custom name you want the variable to have (anything that looks pretty and describes it well)

description - Any description you'd like

Alias: registerVariable, setSupportedVariable

Example:

registerVariable("anallimit", "Anal Limit", "Is anal a hard limit, allowed, needs to be addressed or still a matter of discussion?");

Variables provided by the system

startDate -> The date at that the session started

prefSessionLength -> The amount of minutes that sub prefers as a session length

subName -> The name of the sub

domName -> The name of the dom

domFriend1Name -> The name of the first dom friend

domFriend2Name -> The name of the second dom friend

domFriend3Name -> The name of the third dom friend

personalityVersion -> Version of the personality taken from the personality.properties file