|
Programming SciffyMUD: Conditionals |
|
This document attempts to explain the concept of conditionals. Conditionals are a way of saying wether a certain condition is met or not - in a sense they are boolean functions. They cannot be used by themselves in any meaningful way BUT they can be "bound" to an event and an action. In this case, the action will be performed if the conditional is met, when the event happens! |
|
Document under heavy construction! Hard-hats please! The simplest form of conditional is "always". This means, "when the event happens, just do the action." Very often, you just use "always", but you may also want to test wether a flag is set, or the value of something. Here's an example: * For example (converted to plain-text for clarity): ****** * I am a fearsome warrior called Bob. * I'm on a quest for excalibur. A count of my previous good deeds is stored * in my dynamic member variable called excaliburQuestDeeds. If my * excaliburQuestDeeds is more than 10, then I am allowed to pull excalibur * from the stone, or else I die and have to start again... * * Having reached the mighty stone, I issue the command "pull sword from stone" * command. * - the "pull" event belonging to the sword is called. * - the "pull" event has previously been bound to two conditionals, which * say: * if (excaliburQuestDeeds >= 10) do the function to give me the sword * if (excaliburQuestDeeds < 10) kill me * ****** |
|
This is a list of all of the conditionals. They have been grouped into booleans, integers, and strings - but remember that any datum can be converted into any other datum (see action) . * The forms for a conditional are: * * No-data type: ** always (ignore everything and run the function) * * Boolean types: ** if (one bool is true) ** not (one bool is false) ** and (two bools are both true) ** or (either or both of two bools are true) ** xor (either of two bools is true, but not both) ** andnot (first bool is true and the second is false) ** ornot (first bool is true or the second is false) ** nand (either or both of two bools are false) ** equal (a is the same as b) * * Numerical types: ** equalto (one number equals another) ** lessthan (one number < another) ** greaterthan (one number > another) * * String types: ** same (striwcmp on two strings) ** notequal (striwcmp on two strings fails) ** empty (zero length) ** notempty (> 0 length) ** longerstr (length of one string > another string) ** shorterstr (length of one string < another string) ** longer (length of one string > given number) ** shorter (length of one string < given number) * * A conditional therefore comes in one or more parts: * * - the condition to be tested, from the above list * If not always, then... * - the 1st value, should be valueZ |