Main      Site Guide    
Smash

As Smash matures, new functionality is being added to the language. This is a brief summary of recent additions to the language. See the Smash Tutorial for further information about any of the items below.


9/27/07

  • S: has been changed so that each supported value has a text tag that may be used in place of the number to retrieve system values. This should make code easier to read, because the text tag describes what the value is you're looking up, whereas the numerical values do not. For example, S:moves may now be used instead of S:0 to get the number of moves made by the player so far. Although the numerical values are still supported, the text tags are now the preferred means of accessing system values. This change may break existing code, although it is unlikely to. Previously, an expression like S:variable would evaluate the variable and access the correspondingly numbered system value. Now, "variable" is assumed to be a text tag that S: does not support, and an error is thrown. To fix this problem, use S:{variable} instead.
  • S:isnewloc (a.k.a. S:16) returns whether or not the player has just jumped to a new location. It is set to 1 after a location change takes place (after a "g" command takes effect, not when it is issued) and reverts back to 0 at the end of the turn. c S:isnewloc is the functional equivalent of G with the exception that c S:isnewloc lets you have a C block following it. Moreover, S:isnewloc can be used within more complex expressions.
  • A new x: operator evaluates a string of hexadecimal digits. For example, x:ff evaluates to 255. Hexadecimal strings are case-insensitive.

1/19/06

  • The I command was removed. This may break existing code. Instead, use the i command, which has a new (optional) priority parameter that can be used to guard against an area-level image overriding an action-level image. All installed code on the RinkWorks server has been updated with this change.
  • The E command was changed to !. This may break existing code. All installed code on the RinkWorks server has been updated with this change.

1/17/06

  • New inventory bag controls, which allow the programmer to manipulate entire sets of inventory without using a series of variables to keep track of individual items. The basic idea is that the normal a, d, and e work on the current "inventory bag." If you switch inventory bags with the b command, you can toggle between multiple sets of inventory. A commonly desired effect you can achieve with inventory bags is the player losing all items, then getting them back at a later time. New commands and operators to support this functionality are:
    • b command to switch inventory bags
    • B command to merge inventory bags
    • d can take no arguments to drop all items in the current bag
    • D command drops all items in a specified bag, or all of them if none is specified
    • b: operator returns the number of items in a bag
    • B: operator returns whether the specified bag is the current one
    • S:10 is the string-encoded bag name (or last 8 chars)
    • S:11 is the number of regular items in the given bag
    • S:12 is the number of distinct enumerated items in the given bag
    • S:13 is the number of total enumerated items in the given bag
    • S:14 is the number of distinct items in the given bag
    • S:15 is the number of total items in the given bag
  • S:9 returns the current random number seed, and the new x command lets you set the random number seed. This is useful if you want to make random number sequences repeatable.

1/13/06

  • Now @ + (with no option tag as an argument) will show all constant options; similarly, @ - will hide all constant options.
  • Correction to the Smash Tutorial: The E command is supposed to take a [text] as an argument, not a (str-exp). This means your custom error message is optional and, if present, can span multiple lines, just like the text arguments to . and p commands (for example) can. Note, however, that embedded images don't work in error message texts, even though that's also part of the "text" argument type.

1/12/06

  • A new R loop, which works like an L loop, except that the loop always executes at least once -- and, in fact, the first time through the loop, the loop expression isn't even evaluated. R loops are functionally equivalent to "do/while" loops in other languages such as C/C++.

1/6/06

  • A new .: operator, where .:N is shorthand for (1 << N).
  • A new .! operator, which evaluates to the negation of the .? operator, that is, evaluates to true if a given bit is NOT set.

1/5/06

  • A new l: operator converts an encoded string to lower case.
  • A new u: operator converts an encoded string to upper case.
  • A new U: operator capitalizes the words in an encoded string.

1/3/06

  • A new s: operator returns the sign of its argument.
  • S:7 returns 1 if area description text has been set; 0 otherwise.
  • S:8 returns 1 if action description text has been set; 0 otherwise.
  • A new .+ operator returns a value with a given bit set.
  • A new .- operator returns a value with a given bit cleared.
  • A new .~ operator returns a value with a given bit toggled.
  • A new .? operator returns 1 if a given bit has been set in a value.
  • Function blocks may now be defined in the copts.sma file. The intention is to allow functions called by the code in the constant option blocks to reside right there in the copts.sma file, but is still, of course, perfectly permissible to continue to place such functions elsewhere.
  • The z command now takes the optional argument of a location name. If present, only the state variables in the given location will be cleared. Note the command z {'S:5} for clearing the current location's state variables without introducing a dependency on what the current location's name is. This trick, of course, only works on location names that are not longer than eight characters.