=============== LIBRARY RULES =============== From library maintainers: - SharpMUSH uses a DSL also referred to as 'softcode' for in-game programming - Avoid functions with side-effects, favor commands and commandlists instead when manipulating data where possible ### Example of @open Command Usage Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@open.md Demonstrates how to use the @open command with multiple exit aliases and specifying a destination with a return exit. This example shows a practical application of the command's capabilities. ```text > @open Up ;up;u;climb=#255, Down ;down;d;fall ``` -------------------------------- ### Example: Get Flags for an Object - Sharpmush Scripting Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/FLAGS().md Demonstrates how to create an object, set flags on it, and then retrieve those flags using the flags() function. ```sharpmush @create Test @set Test=no_command puppet think flags(Test) ``` -------------------------------- ### @message Command Examples and Implementation Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@message.md Provides practical examples of using the @message command, including setting up message formats for different recipients and a rough implementation of a chat format system. This highlights the flexibility of @message in creating dynamic communication. ```sharpmush > &sayformat *Mike=%n sez, '%0' > &sayformat *Walker=From %n: %0 > &cmd.fsay me=$fsay *: @message/spoof *Mike *Walker *Javelin=%n says\, "%0", SAYFORMAT, %0 > fsay This is a test ``` ```sharpmush > &cmd.chat Globals=$^@chat (.+?)=([\:;]?)(.+?)$: @message/spoof cwho(%1)=setr(0,<%1> [speak(&[squish(ctitle(%1, %#) %n)], %2%3)]), CHATFORMAT, firstof(%2, "), %1, %3, %n, ctitle(%1, %#), %q0 > @set Globals/cmd.chat=regexp ``` -------------------------------- ### List and Unset Q-Registers - SharpMUSH Script Examples Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/UNSETQ().md These examples demonstrate the basic usage of listq() and unsetq(). The first shows listing all registers after setting some. The second shows unsetting specific registers and then listing the remaining ones. These functions are crucial for managing register state. ```sharp-mush think setq(name,Walker,num,#6061,loc,Bahamas)[listq()] LOC NAME NUM ``` ```sharp-mush think setq(name,Walker,num,#6061,loc,Bahamas)[unsetq(name)][listq()] LOC NUM ``` -------------------------------- ### Use Named Arguments with mapsql() Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/SQL_Examples.md This example demonstrates an alternative way to format SQL query results using named arguments within the `mapsql()` function. It utilizes `[r(name, args)]` and `[r(total, args)]` to reference columns by their names, offering a more readable approach compared to positional arguments. ```mush > &each_bb me=(%0) - %1 (%2) > &query me=SELECT `name`, count(*) AS `total` FROM `bbs` GROUP BY `name` ORDER BY `name` > think mapsql(each_bb, v(query), %r) > &each_bb me=(%0) - [r(name, args)] ([r(total, args)]) ``` -------------------------------- ### Language System Implementation with @message Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@message.md Illustrates how the @message command can be integrated into a basic language system. This example shows dynamic message generation based on player skills and a translation mechanism, demonstrating advanced customization. ```sharpmush > &skill`spanish Juan=2 > &skill`spanish Bob=1 > &cmd.spanish Globals=$+spanish *: @nspemit %#=You say (Spanish), "%0"; @message/oemit/spoof %#=setr(0,%n says (Spanish)\, "%0"), %!/TRANSLATE, ##, SPANISH, %q0 ``` ```sharpmush > &translate Globals=switch(default(%0/skill`%1, 2), 2, %2, speak(%#, |%2,, %!/translate`some)) > &translate`some Globals="[iter(%0,if(rand(2),%i0,...))]" ``` ```sharpmush +spanish The rain in Spain falls mainly on the plain ``` -------------------------------- ### Format SQL Results with mapsql() Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/SQL_Examples.md The `mapsql()` function formats the results of a SQL query according to a specified template. It iterates through each row returned by the query and applies the `each_row` or `each_bb` function to format the output. The `describe` command in the first example and a `SELECT` query in the second demonstrate its flexibility. ```mush > @@ Field, Type, Null?, Key?, Default, Extra > &each_row me=align(<15 <15 <5 <5 <10 <14,%1,%2,%3,%4,%5,%6) > &tabledesc me=mapsql(each_row,describe `[sqlescape(%0)]`,%r,1) > think u(tabledesc,quotes) ``` ```mush > &each_bb me=(%0) - %1 (%2) > &query me=SELECT `name`, count(*) AS `total` FROM `bbs` GROUP BY `name` ORDER BY `name` > think mapsql(each_bb, v(query), %r) ``` -------------------------------- ### LETQ() Example 1: Modifying and Restoring a Single Register Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/LETQ().md This example demonstrates how LETQ() saves the current value of register A, sets it to a new value, evaluates an expression, and then restores the original value of A. The saved register value is accessed using %qA. ```sharpmush think setr(A, 1):[letq(A, 2, %qA)]:%qA 1:2:1 ``` -------------------------------- ### LETQ() Example 2: Modifying and Restoring Multiple Registers Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/LETQ().md This example shows LETQ() handling multiple registers (A and B). It saves their current values, sets new values for both, evaluates an expression that uses the saved values (%qA and %qB), and then restores the original values. ```sharpmush think setr(A, 1)[setr(B,1)]:[letq(A, 2, %qA[setr(B,2)])]:%qA%qB 11:22:12 ``` -------------------------------- ### STEP() Function Usage Example - Sharpmush Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/STEP().md Demonstrates the basic usage of the STEP() function to process a list with a specified step size. It shows how elements are assigned to registers and how the output changes based on the step. ```sharpmush &foo me=%0 - %1 - %2 think step(foo, a b c d e, 3,, %r) a - b - c d - e - ``` -------------------------------- ### STRALLOF() Example - SharpMush Script Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/STRFIRSTOF().md Illustrates the STRALLOF() function, which collects all non-empty string expressions and joins them with a specified output separator. This is useful for constructing strings from multiple potentially empty sources. ```sharpmush say strallof(, ,foo,@@(Nothing),%b,bar|baz,#-1,|) ``` -------------------------------- ### INDEX Function Usage in Sharpmush Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/INDEX().md Demonstrates the usage of the INDEX function with different list types and delimiters. It shows how to specify the delimiter, starting position, and the number of elements to return. Trailing spaces are trimmed from the results. ```sharpmush say index(Cup of Tea | Mug of Beer | Glass of Wine, |, 2, 1) # Expected Output: You say, "Mug of Beer" say index(%rtoy boat^%rblue tribble^%rcute doll^%rred ball,^,2,2) # Expected Output: You say, " blue tribble^ cute doll" ``` -------------------------------- ### ALLOF() Example: Combining True Expressions Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/ALLOF().md Demonstrates how ALLOF() evaluates multiple expressions and returns the true results concatenated with a default separator. It shows the function's ability to filter and combine string and number-based expressions. ```sharpmush > say allof(grab(v(s),rats),grab(v(s),mats),grab(v(s),bats),) ``` ```sharpmush > say allof(#-1,#101,#2970,,#-3,0,#319,null(This Doesn't Count),|) ``` ```sharpmush > say allof(foo, 0, #-1, bar, baz,) ``` ```sharpmush > say allof(foo, 0, #-1, bar, baz,%b) ``` -------------------------------- ### Example: Get Flags for an Attribute - Sharpmush Scripting Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/FLAGS().md Shows an example of retrieving flags for a specific attribute ('describe') of the current object ('me'). ```sharpmush think flags(me/describe) ``` -------------------------------- ### LOCKFILTER() Example: Filter players by name and sex Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/LOCKFILTER().md This example demonstrates how to use LOCKFILTER() to retrieve a list of players whose names start with 'W' and who are male. It utilizes the `lwho()` function to get a list of all online players and then filters them using the provided lock key. ```mushcode think iter(lockfilter(NAME^W*&SEX:M*,lwho()),name(%i0)) ``` -------------------------------- ### Sharpmush @force Inline Execution Example Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@force.md Demonstrates the difference between queuing and inline execution with @force. The first example shows a standard queued execution where a message is displayed indicating the action is done before the object performs it. The second example uses @force/inline, resulting in the object performing its action immediately, and the "Done?" message appearing afterward. ```sharpmush > &order me=$order *:say Lackey, %0 ; @force Lackey=%0 ; say Done? > order pose salutes! You say, "Lackey, pose salutes!" You say, "Done?" Lackey salutes! ``` ```sharpmush > &order me=$order *:say Lackey, %0 ; @force/inline Lackey=%0 ; say Done? > order pose salutes! You say, "Lackey, pose salutes!" Lackey salutes! You say, "Done?" ``` -------------------------------- ### Get MUSH Start and Restart Times Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/RESTARTTIME().md The `starttime()` function retrieves the time the MUSH was last started, and `restarttime()` retrieves the time of the last restart, including @shutdown/reboots. The output format is consistent with the `time()` function. These functions are useful for monitoring server activity and uptime. ```sharpmush say starttime()%r[restarttime()] ``` -------------------------------- ### SETUNION() Example - Numeric Sorting Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/SETUNION().md Illustrates SETUNION() with numeric lists. By default, it sorts numerically. This example shows how it handles floating-point numbers. ```sharpmush say setunion(1.1 1.0, 1.000) ``` -------------------------------- ### Sharpmush @force Command Examples Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@force.md Illustrates the practical application of the @force command. It shows how to create an object, force it to perform an action like 'go east', and how to make it page another object. The examples demonstrate both direct object names and database references, as well as the abbreviation for @force. ```sharpmush > @create Lackey Created: Object #103 > @force Lackey=go east Lackey goes east. Lackey has left. > @force #103=page Cyclonus=Hi there! Lackey pages: Hi there! > #103 page Cyclonus=Whee Lackey pages: Whee ``` -------------------------------- ### RLOC() Function Usage Example - Sharpmush Scripting Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/RLOC().md Demonstrates the usage of the RLOC() function to get the nested location of an object. The `` argument specifies the depth of location retrieval. For instance, `rloc(, 2)` is equivalent to `loc(loc())`. Passing `0` returns the object's number, and `1` returns its direct location. ```sharpmush rloc(, ) -- Example: Get the direct location of an object loc_obj = rloc(my_object, 1) -- Example: Get the location two levels up room_above = rloc(my_object, 2) -- Example: Get the numerical identifier of the object obj_num = rloc(my_object, 0) ``` -------------------------------- ### @trigger Examples Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@trigger.md Illustrates various use cases of the @trigger command, including passing arguments and using the /spoof switch. ```APIDOC ## @trigger Examples ### Basic Triggering ``` > &GREET me=POSE waves hi. > @trigger me/GREET Cyclonus waves hi. ``` ### Triggering with Arguments ``` > &GREET me=POSE waves to %0! ; say Hi there, %1. > @trigger me/GREET=Gears, Arcee Cyclonus waves to Gears. You say, "Hi there, Arcee." ``` ### Triggering $-commands with Arguments and @assert ``` > &foo Globals=$foo *: @assert setr(0,locate(%#,%0,*))=@nspemit %#=Who? ; @nspemit %#=You foo [name(%q0)]. ; @trigger %q0/AFOO > &AFOO Bar=:is foo'd by %n! > FOO BAR Bar is foo'd by Globals! ``` ### Triggering with `/spoof` This example demonstrates how `/spoof` preserves the original enactor when triggering an attribute. ``` > &foo Globals=$foo *: @assert setr(0,locate(%#,%0,*))=@nspemit %#=Who? ; @nspemit %#=You foo [name(%q0)]. ; @trigger/spoof %q0/AFOO > FOO BAR Bar is foo'd by Cyclonus! ``` ### Using `/match` This allows passing a command to match a pattern, useful for complex $-commands or listeners. ``` > @trigger/match object/slap=slap himself=trout Walker slaps himself around with a trout ``` ``` -------------------------------- ### MESSAGE() Function Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/MESSAGE().md Details on the MESSAGE() function, its parameters, switches, and usage examples. ```APIDOC ## MESSAGE() ### Description `message()` is the function form of `@message/silent`, and sends a message, formatted through an attribute, to a list of objects. ### Syntax `message(, , [/][, [, ... , ][, ]])` ### Parameters - **recipients** - The recipient(s) of the message. - **message** - The message content to be sent. - **attribute** - The attribute to use for formatting the message. Can be a global attribute or an object-specific attribute (e.g., `#123/formatter`). - **arg0 through arg9** - Up to ten arguments that can be used within the message formatting attribute. All ten must be provided if `` are used. - **switches** - A space-separated list of one or more of "nospoof", "spoof", "oemit", and "remit". These switches control the message sending behavior, similar to `@message/``. ### Switches - `nospoof`: Disables spoofing. - `spoof`: Enables spoofing. - `oemit`: Enables "output emit" behavior. - `remit`: Enables "remote emit" behavior. ### Examples ``` &formatter #123 think message(me, Default> foo bar baz, #123/formatter, foo bar baz) ``` *Output if `#123/formatter` is `Formatted> [iter(%0,capstr(%i0))]`* ``` Formatted> Foo Bar Baz ``` ``` > think message(here, default, #123/formatter, backwards compatability is annoying sometimes,,,,,,,,,,remit) ``` *Output if `#123/formatter` is `Formatted> [iter(%0,capstr(%i0))]`* ``` Formatted> Backwards Compatability Is Annoying Sometimes ``` ### See Also - [@message] - [oemit()] - [remit()] - [speak()] ``` -------------------------------- ### Open Exit Command Syntax Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@open.md This describes the syntax for the @open command, detailing its parameters and their functions. It explains how to specify exit names, destinations, return exits, source rooms, and aliases. Permissions and linking behavior are also outlined. ```text @open [=,,,,] ``` -------------------------------- ### Using STEXT() and SLEV() in Examples Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/%$.md These examples demonstrate the practical application of STEXT() and SLEV() within Sharpmush code, showing how to use them for conditional logic and string manipulation in nested switch statements. ```Sharpmush &cmd.whois me=$whois *: @pemit %#=switch(pmatch(%0),#-*, I don't know '%0', '%0' is %$0) @switch foo=f*, say switch(bar, b*,%$1 %$0!) ``` -------------------------------- ### OBJID() Function Reference Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/OBJID().md Details on the OBJID() function, its syntax, return value, and usage examples. ```APIDOC ## OBJID() ### Description This function returns the object id of ``, a value which uniquely identifies it for the life of the MUSH. The object id is the object's dbref, a colon character, and the object's creation time, in seconds since the epoch, equivalent to [num(``)]:[csecs(``)] The object id can be used nearly anywhere the dbref can, and ensures that if an object's dbref is recycled, the new object won't be mistaken for the old object. The substitution %: returns the object id of the enactor. ### Syntax `objid()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` "" (No direct request body for function calls) ``` ### Response #### Success Response (200) - **objectId** (string) - A unique identifier for the object in the format "dbref:creation_time". #### Response Example ```json { "objectId": "#1234:1678886400" } ``` ## See Also - [num()] - [csecs()] - [ctime()] - [ENACTOR] ``` -------------------------------- ### MONEY() Function Example with Counter - Sharpmush Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/MONEY().md This example demonstrates using the money() function within a counter to display a formatted currency amount. It combines integer input with the function's output for a dynamic display. ```sharpmush &counter CvC=$count *: @say %0 [money(%0)]. Ah.. ah.. ah. > count 2 > Count von Count says, "2 Pennies. Ah.. ah.. ah." ``` -------------------------------- ### @mapsql Command Documentation Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@mapsql.md Details on how to use the @mapsql command, including its syntax, switches, and argument passing. ```APIDOC ## @mapsql Command ### Description Executes an SQL query if the MUSH supports SQL and can connect to an SQL server. Requires WIZARD or Sql_Ok power. ### Method `@mapsql[/notify][/colnames][/spoof] /=` ### Parameters #### Path Parameters - **obj** (object) - The target object where the attribute actions will be queued. - **attr** (attribute) - The attribute on the target object that will be queued for each row. - **query** (string) - The SQL query to execute. #### Switches - **/notify** - Causes the executor to queue "@notify me" after all rows are processed. - **/colnames** - Queues the obj/attr first with row number (%0) set to 0 and arguments %1 to v(29) being the column names. - **/spoof** - Preserves the current enactor if the `` is controlled. #### Argument Passing For each row returned by the query: - Row number is passed as `%0`. - Columns are passed as `%1` to `%9` and `v(10)` to `v(29)`. - Named arguments matching SQL field names are accessible as `r(, arg)`. ### Request Example ``` > &desctable me=think align(30 20 4 10 10,%0,%1,%2,%3,%4) > @mapsql me/desctable=DESCRIBE table_name ``` ``` > &showresult me=@pemit %#=%0. [r(name, arg)] ([r(age, arg)]) > @mapsql me/showresult=SELECT `name`, `age` FROM `people` ``` ### Response Results are processed by queuing actions on the specified object and attribute. Special arguments are set for row number, column data, and column names. ``` -------------------------------- ### LOCKFILTER() Example: Filter players by flags Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/LOCKFILTER().md This example shows how to use LOCKFILTER() to find all online players who have either the 'WIZARD' or 'ROYALTY' flag. It uses `lwho()` to get the list of online players and filters them based on the specified lock key. ```mushcode think iter(lockfilter(FLAG^WIZARD|FLAG^ROYALTY,lwho()),name(%i0)) ``` -------------------------------- ### @search Examples Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@search.md Provides practical examples of how to use the @search command with various filters and options. ```APIDOC ## @search5 ### Description Examples: ### Method `@search` (usage examples) ### Parameters (See @search for general parameters) ### Request Example ``` @search all type=player,flags=W <-- list all Wizard players @search type=room <-- list all rooms owned by me. @search zone=#50 <-- list all objects belong to zone #50. @search Joe eval=1,100,200 <-- list objects from #100-#200 owned by Joe. @search eval=gt(money(##),10) <-- list all objects owned by me worth more than 10 coins. @search all elock=FLAG^WIZARD|FLAG^ROYALTY <-- list all objects with wizard or royalty flags. @search wizard_bc command=+who <-- Forgot what object has your +who? ``` ### Response #### Success Response (200) - **objects** (list of objects) - A list of objects matching the search criteria based on the examples. #### Response Example (Response format depends on the matched objects and server configuration) ``` -------------------------------- ### LOCKFILTER() Example: Filter players by IC age Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/LOCKFILTER().md This example illustrates filtering online players based on their in-character (IC) age being greater than 20. It uses `lwho()` to get the list of online players and applies the age condition via LOCKFILTER(). ```mushcode think lockfilter(age:>20,lwho()) ``` -------------------------------- ### SharpMUSH @switch Example: Basic Matching Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@select.md Demonstrates a basic usage of the @switch command to match a variable against different patterns and execute corresponding actions. It shows how to handle multiple matches and a default case. ```SharpMUSH > &SWITCH_EX thing=$foo *: @switch %0=*a*, :acks, *b*, :bars, :glurps > foo abc thing acks > foo xxx thing glurps ``` -------------------------------- ### WIDTH() and HEIGHT() Functions Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/SCREENWIDTH.md These functions return the screen width and height for a connected player. Defaults are provided and can be overridden. ```APIDOC ## WIDTH() and HEIGHT() ### Description These functions return the screen width and height for a connected player. The player's client reports these values on connection and resize. Defaults are 78 for width and 24 for height. ### Method Function Call ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Function Signature `width([, ])` `height([, ])` ### Request Example ``` { "action": "call_function", "function": "width", "arguments": ["#1"] } { "action": "call_function", "function": "height", "arguments": ["#1", 80] } ``` ### Response #### Success Response (200) - **value** (integer) - The screen width or height. #### Response Example ``` { "result": 80 } ``` ``` -------------------------------- ### Get Attribute Flags - Sharpmush Scripting Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/FLAGS().md Returns the flag letters for each flag set on a specific attribute of a given object. ```sharpmush flags(/) ``` -------------------------------- ### Prevent SQL Injection with sqlescape() Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/SQL_Examples.md The `sqlescape()` function is used to sanitize input values before they are included in SQL queries, preventing SQL injection attacks. It ensures that special characters within the input are properly escaped. This example shows its use in a SELECT statement. ```mush > &SEL_GETID obj=SELECT id FROM mytable WHERE name = '[sqlescape(%0)]' > &DOIT obj=$do *: think setq(0,sql(u(SEL_GETID,%0),~,|)); @@ More cmds ``` -------------------------------- ### Example: Creating and Hooking a Custom Command (/noparse) Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@command.md This example demonstrates creating a custom command 'eat' using @command/add with the /noparse switch. It then hooks this command to a specific context ('dining machine') and defines its softcode behavior. The example shows how the command executes with normal argument parsing and when arguments are passed as a raw string. ```sharpMUSH > @create Dining Machine > &eat dining=$eat *:@remit %L=%n takes a bite of %0. > @command/add/noparse eat > @hook/override eat=dining machine,eat > eat meat loaf Walker takes a bite of meat loaf. > eat randword(apple tomato pear) Walker takes a bite of randword(apple tomato pear) ``` -------------------------------- ### SharpMUSH @search Examples Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@search.md Provides practical examples of using the @search command with different filters and options, demonstrating common search scenarios. ```plaintext @search all type=player,flags=W <-- list all Wizard players @search type=room <-- list all rooms owned by me. @search zone=#50 <-- list all objects belong to zone #50. @search Joe eval=1,100,200 <-- list objects from #100-#200 owned by Joe. @search eval=gt(money(##),10) <-- list all objects owned by me worth more than 10 coins. @search all elock=FLAG^WIZARD|FLAG^ROYALTY <-- list all objects with wizard or royalty flags. @search wizard_bc command=+who <-- Forgot what object has your +who? ``` -------------------------------- ### @trigger with /match Switch Example Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@trigger.md Shows how to use the /match switch with @trigger to specify a command that matches a pattern, allowing for more complex triggering scenarios, especially with regular expressions. ```Mush > @trigger/match object/slap=slap himself=trout ``` -------------------------------- ### Example: Using @notify/setq to modify a queue entry Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@notify.md This example demonstrates how @notify/setq can be used to modify the contents of a queued command. First, a command is queued with @wait, referencing a Q-register (%q0). Then, @notify/setq is used to set the value of %q0, which is then included in the output when the queued command executes. ```sharpmush > @wait me=think Hello, %q0! > @notify/setq me=0,Walker Hello, Walker! ``` -------------------------------- ### ENTRANCES() Function API Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/ENTRANCES().md Details on how to use the ENTRANCES() function, including its parameters and behavior. ```APIDOC ## ENTRANCES() ### Description The `entrances()` function returns a list of all exits, things, players, and rooms linked to a specified location. It can be filtered by object type and a range of database references. ### Method Function Call ### Parameters #### Path Parameters - **object** (object) - Optional - The object to retrieve entrances from. Defaults to the current location. - **type** (string) - Optional - A string specifying the types of objects to return. Possible values: 'a' (all, default), 'e' (exits), 't' (things), 'p' (players), 'r' (rooms). - **begin** (number) - Optional - The starting database reference number for the range search. - **end** (number) - Optional - The ending database reference number for the range search. ### Request Example ``` entrances() entrances(#123) entrances(me, "tr") entrances(me, "t", 1000, 2000) ``` ### Response #### Success Response (200) - **list** (array) - A list of objects (exits, things, players, rooms) linked to the specified location. #### Response Example ```json { "entrances": [ "#100 ExitName", "#101 ThingName", "#102 PlayerName", "#103 RoomName" ] } ``` ``` -------------------------------- ### Sharpmush @dolist example: Basic iteration Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/@dolist.md This example demonstrates the basic usage of the @dolist command to iterate over a list of items ('a', 'b', 'c') and print each item along with its sequential number using the %i0 and inum(0) substitutions. ```sharpmush > @dolist a b c=say %i0 is number [inum(0)] You say, "a is number 1" You say, "b is number 2" You say, "c is number 3" ``` -------------------------------- ### Calculate String Digest (MD5 Example) Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/CHECKSUM.md Calculates the MD5 hash of a given string. The result is a base-16 encoded hexadecimal string representing the digest. ```SharpMush digest("md5", "foo") ``` -------------------------------- ### Update Fields using sql() Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/SQL_Examples.md The `sql()` function is used to execute SQL commands, including UPDATE statements. This example shows how to update the `time` field in a `foo` table based on `loc` values, again using `sqlescape()` for security. The `%q0` placeholder captures the number of rows affected by the update. ```mush > &update me=UPDATE `foo` SET `time` = '[sqlescape(%0)]' WHERE `loc` = '[sqlescape(%1)]' > &foo me=$foo *: think sql(u(update, %0, %L),,0)%q0 rows updated. > foo bar ``` -------------------------------- ### Example: textfile() usage - Sharpmush Script Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/TEXTSEARCH().md This example demonstrates retrieving help text for the ln() function using the textfile() command. The output includes the function signature and its description, showcasing how textfile() returns formatted text content. ```Sharpmush Script say textfile(help, ln(\( )) ``` -------------------------------- ### SOCKSET - Command Line Interface Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Command Documentation/SOCKSET.md The SOCKSET command allows players to set or query individual socket options directly from the command line. Without arguments, it displays current settings. With an option-value pair, it attempts to modify the specified option. ```APIDOC ## SOCKSET ### Description Allows users to set or query individual socket-specific options for their connection. Displays current settings when run without arguments. Attempts to set the given option when an `option=value` pair is provided. ### Method Command Line ### Endpoint N/A (Command Line Utility) ### Parameters #### Command Line Arguments - **option** (string) - Optional - The name of the socket option to set. - **value** (string) - Optional - The desired value for the socket option. ### Request Example ``` SOCKSET width=80 SOCKSET telnet=yes SOCKSET ``` ### Response #### Success Response - **output** (string) - Displays the current value of the queried option or confirmation of the setting. #### Response Example ``` Width is now 80. ``` ### Options: - `colorstyle`: See [colorstyle] - `outputprefix`: Same as OUTPUTPREFIX - `outputsuffix`: Same as OUTPUTSUFFIX - `pueblo`: Sets Pueblo-related options. If value has `md5=...`, it sets the pueblo checksum. If empty, Pueblo mode is turned off. - `telnet`: `yes` or `no`, to enable/disable telnet negotiation - `width`: Set your width(), same as SCREENWIDTH - `height`: Set your height(), same as SCREENHEIGHT - `terminaltype`: Your terminal type, used by terminfo() - `prompt_newlines`: Set whether a newline is shown after prompts from @prompt, same as PROMPT_NEWLINES - `stripaccents`: Strip accents for this connection. Like the NOACCENTS flag, but connection-specific. Set by default on connections which negotiate charset as [US-]ASCII - `noquota`: Input command quota is set to max every refresh. Can only be set by a logged-in Wizard. ``` -------------------------------- ### Get All MUSH Flags - Sharpmush Scripting Source: https://github.com/sharpmush/sharpmush.guide/blob/main/Function Documentation/FLAGS().md Returns a string of flag letters for all flags on the MUSH. Some flags may not have letters, and multiple flags can share the same letter. ```sharpmush flags() ```