• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages

    Usage:

    echo "Message to be echoed"

    Example:

    echo "Hi,this is a test"

    Allows you to print a message into the log window. This script command replaced the older and less powerful Print command, and any new scripts should use this instead. You should also convert your existing scripts to use Echo at your convenience, Print may be deprecated in the future.

    Echo is expression friendly. This means that anything you put in quotes will be treated as a plain text string and echoed exactly. Anything you do not put in quotes will be evaluated as an expression.

    For a simple message to the log window:

    Script:
    echo "This is a line that will show up in the log file"
    
    Results:
    19:29:33 This is a line that will show up in the log file
    19:29:34 Script stopped

    It is also able to display the value of a replacement variable:

    Script:
    set blurb Testing
    echo "%blurb%"
    
    Results:
    19:30:10 Testing
    19:30:11 Script stopped

    Unlike Print, echo is able to display the value of a true variable:

    Script:
    blurb = "Testing"
    echo blurb
    
    Results:
    19:31:28 Testing
    19:31:29 Script stopped

    ... and it is able to evaluate the results of expressions:

    math = 1 + 1
    echo math
    echo 1 + 1
    
    Results:
    19:32:22 2
    19:32:23 2
    19:32:24 Script stopped

    If you wanted it to actually print out the text 1 + 1 instead of the result 2, then you would put it in quotes: echo "1 + 1".

    If you wanted to mix variables, objections, plain text, math, whatever in there you can do that.. it might look a little daunting with all the quotes and plus signs, but it's not too hard when you wrap your head around it. Remember that it will display literally as you write it, so include spaces inside the quotes where you want them:

    Script:
    echo "My city is located at " + city.coords
    
    Results:
    19:35:01 My city is located at 123,456

    Note in the above example, I put quotes around the stuff I want it to display word for word, including a space after the word 'at'.
    Then I closed my quotes because the next part (city.coords) is an object I want it to evaluate.
    The + sign tells it to add the next part to the end of whatever was before. If I didn't add that it would also add the space after the end quote.
    Another way to write that could be echo "My city is located at"city.coords but I recommend you get in the habit of seperating them with the + sign. You won't always be able to jam stuff together like that.

    Here's another example:

    Script:
    cavs = city.troop.lightCavalry
    phracts = city.troop.heavyCavalry
    echo "My city at " + city.coords + " has " + (cavs + phracts) "horses in it."
    
    Results:
    19:43:34 My city at 123,456 has 69858 horses in it.
    19:43:35 Script stopped

    In the above example, I used the object city.coords outside of quotes, and I added the values of the variables cavs and phracts together inside the parentheses to display my total number of horses... this math was also outside of quotes since I didn't want the bot to print the words (cavs + phracts) literally into the log file. I used the + sign to combine all the parts of the echo together.


    ScriptControlStructures

    Echo (last edited 2013-08-31 03:12:13 by Inanna)