BlobbieScript - Resolutions

Details  |  World  |  Continents  |  Areas  |  Zones  |  Rooms  |  Mobiles  |  Items  |  Exits  |  Extras  |  Buffs  |  Races

This operator is powerful enough to warrant an entire section describing its use. Unlike other operators the resolution operator "->" is highly contextual and the actual functionality is completely dependent on the leftmost value of the resolution. Since this operator may be strung together in sequence to resolve a multi-level path for a container, it may not always behave as expected when the leftmost operand does not support multi-level resolution. This is true of strings. Currently the resolution operator may be used on both strings, associative arrays, and any of the entity pointer types (rooms, mobiles, objects, and exits). It is especially convenient that this operator can be used on room, mobile, object, and exit pointers.

0001 'fun fun fun'->5
0002 @string->3
0003 @array->index
0004 @n->hitpoints
0005 @room->objects

Application of the resolution operator to a string requires that the right operand be an integer index. Use in this manner will return a string consisting of the single character found at the appropriate valid index. Indexes are 1-based. This means the first character of the string is denoted by an index of value 1. Contrast this to languages such as C which are 0 based. If the index is not valid, or the right operand is not an integer then null will be returned. This behaviour is modified when the resolution is being set via the assignment operator. When the resolution is setting a string then once again the right operand must be an integer, however the value to set the indexed character may either be a string or an integer. If it is a string then the first character of the string will be used to update the resolved string, whereas if the value to set is an integer then it will be used as the ascii value of the character with which to update the resolved string. When the value is set, the right operand of the assignment operator is returned.

0001 Examples:
0003 @text = "Blobbie was here."         // Set up the @text variable
0005 @text->6                            // Returns the string "i"
0007 @text->3 = u                        // Sets the 3rd character to "u"
0008                                     // and returns "u"
0010 @text                               // Returns "Blubbie was here."
0012 @text->10 = 105                     // Sets the 10th character to the
0013                                     // character represented by ascii
0014                                     // value 105 ("i") and returns 105
0016 @text                               // Returns "Blubbie wis here."

If the left operand is an associative array then the resolution operator will return the value indexed by the right operand. The right operand will be converted to a string equivalent and used to resolve a value matching that key. The associative array is also known as a dictionary in other languages. Values may be other associative arrays leading to the possibility for multi-level access to a given data element.

0001 Example:
0003 //
0004 // Set up a multi-level associative array
0005 // of immortals.
0006 //
0008 @immortals->name->1 = Blobule
0009 @immortals->name->2 = Galimatazo
0010 @immortals->name->3 = Pazam
0011 @immortals->name->4 = Sang
0012 @immortals->name->5 = DevilDoll
0013 @immortals->name->6 = Brack
0015 @immortals->race->1 = Slime
0016 @immortals->race->2 = Reptile
0017 @immortals->race->3 = Gnome
0018 @immortals->race->4 = Draconian
0019 @immortals->race->5 = Demon
0020 @immortals->race->6 = Doppleganger
0022 //
0023 // Method 1...
0024 //
0026 @immortals->name->1 " the " @immortals->race->1  // Blobule the Slime
0027 @immortals->name->2 " the " @immortals->race->2  // Galimatazo the Reptile
0028 @immortals->name->3 " the " @immortals->race->3  // Pazam the Gnome
0029 @immortals->name->4 " the " @immortals->race->4  // Sang the Draconian
0030 @immortals->name->5 " the " @immortals->race->5  // DevilDoll the Demon
0031 @immortals->name->6 " the " @immortals->race->6  // Brack the Doppleganger
0033 //
0034 // Method 2...
0035 //
0037 @names = @immortals->name                   // Get list of immortal names
0038 @races = @immortals->race                   // Get list of immortal races
0040 @names->1 " the " @races->1                 // Blobule the Slime
0041 @names->2 " the " @races->2                 // Galimatazo the Reptile
0042 @names->3 " the " @races->3                 // Pazam the Gnome
0043 @names->4 " the " @races->4                 // Sang the Draconian
0044 @names->5 " the " @races->5                 // DevilDoll the Demon
0045 @names->6 " the " @races->6                 // Brack the Doppleganger

As mentioned previously, the resolution operator also works on room, mobile, object, and exit pointers. This provides the ability to easily retrieve and set various values related to the entity being resolved. For instance a regeneration script might want to increase the hitpoints of everyone in the room. This could be done as follows:

0001 foreach( @room->mobiles as @target )
0002 {
0003    if( (@target->hitpoints += 1d5) > @target->maxHitpoints )
0004    {
0005        @target->hitpoints = @target->maxHitpoints
0006    }
0007    endif
0008 }
0009 endforeach

There are a couple of places in the above sample script where the resolution operator is used on an entity. The first is:

0001 @targets = @room->mobiles

which is used to retrieve a list of all the mobiles in the room denoted by the room pointer @room. The next place is when we increment the a mobile's hitpoints:

0001 if( (@target->hitpoints += 1d5) > @target->maxHitpoints )

This increments the target's hitpoints by 1 to 5 points and then checks if they exceed the target's maximum hitpoints. If they do then the next line:

0001 @target->hitpoints = @target->maxHitpoints

ensures that they do not exceed the target's maximum hitpoints. The resolution operator is so powerful that it even serves to provide meta functionality by assigning values to certain fields. For instance to move a player from one room to another is as simple as the following line:

0001 @destination->mobiles->last = @n

This moves the mobile stored in the variable @n to the room denoted by @destination. Removal of the player from their existing location is done for you. There are literally hundreds of fields that can be accessed using this method. For details on each entity type see the links at the top.