Guest
May 20, 2012, 3:21 pm UTCHome arrow Commands arrow Additional Conditions arrow The If Command arrow Additional Conditions arrow Additional Conditions
header image
Additional Conditions
Written by Dream Dancer   
Nov 26, 2007 at 05:01 AM

Additional conditions are a fast means of checking things within the bot to determine whether or not to do something. Whether it's someone or something which exists in a $LOG as the Record name, or a specific field in a database is a particular value, many times you find the need to have several related commands, but each one will only do something under the right conditions: 

Name: Add Ban
Stop Action Search if TRUE
If {*} Whispers me {ban *}
AND:
$DATABASE: if there is a record in table {members} in database {1}
where ID is {[player]}
$DATABASE: if field {controller} in database {1} in table {members}
is EXACTLY {TRUE}(text) from ID {[player]}
if variable {[word2]} is not the same as {list} (text comparison)
THEN:

Conditions are processed in the order which they appear, something to keep in mind is that the command processor bails when the FIRST condition is not met, and proceeds to the next command in the list. So in the above example, the processor will bail if the PLAYER is not in the database, or if is in the database, will bail if they're not set up to be a controller of the bot.

You can check quite a few things with additional conditions, even parts of the message sent by the server to the bot as can be seen on the base page of Triggers. You will note that there's a different set of additional conditions on checking some things based on whether you're looking for a numeric value or a text value, and that's because the loose typing of the bot calls everything internally as text, unless it is to be used as number. Hence 0 <> 00 if checked as text but is the same value if checked numerically. Some of the checks are done with the LIKE operator, which is not the same as EQUALS. The engine, unlike the sections which handle the $LOG & $DATABASE functions, is in "Option Compare Binary", which differs from "Option Compare Text"


Option Compare Binary
results in string comparisons based on a sort
order derived from the internal binary representations of the
characters. In microsoft Windows, sort order is determined by the
code page.

A typical binary sort order is shown in the following example:

A < B < E < Z < a < b < e < z < À < Ê < Ø < à < ê < ø

Option Compare Text results in string comparisons based on a
case-insensitive text sort order determined by your system's locale.
When the same characters are sorted using Option Compare Text,
the following text sort order is produced:
(A=a) < ( À=à) < (B=b) < (E=e) < (Ê=ê) < (Z=z) < (Ø=ø)

However, that's only on a couple of checks, and the testing is done CASELESS, so should not be too much of a problem.

Last Updated ( Nov 26, 2007 at 05:19 AM )
Next>
header image