FAQ: Building a pop-up chat window

Post Reply
User avatar
Hyde
Hyde!
Posts: 3477
Joined: Thu Apr 20, 2006 5:26 am

FAQ: Building a pop-up chat window

Post by Hyde »

Scripts in TSW


Scripts in TSW work much like scripts in AO, so making a script for spam wouldn't be hard.

  1. ... The Basics ...
    1. Find your TSW install folder, typically "c:\program files (x86)\The Secret World"
    2. Make a sub-directory there called "scripts"
    3. Create a new text document in the "scripts" sub-directory called "test.txt" (note, ".txt" is optional, some people prefer to leave it off, TSW won't care as long as you use the full filename of whatever you do create)
    4. Paste the following into "test.txt"


      NOTE: This all has to be on a SINGLE line. The line can be very long. But it can't have any line breaks, as each new line is considered a new action. There is almost certainly some upper limit to line length ... if your script appears broken and is very long, this is a possible reason.

      Code: Select all

      /text <a href='text://displayed when the user clicks on the link'>DISPLAYED IN CHAT AS CLICKABLE LINK</a>
      
      The way it works is ...
      • put text that you want people to see first (on the chat channel) where you see "DISPLAYED IN CHAT AS CLICKABLE LINK".
      • put your popup window content where you see "displayed when the user clicks on the link"
      (note: there is a more complete example at the end of this page)
    5. Do the following in the chat input (without the backticks `):
      `/test.txt`

      Important: you have to be VERY careful about quote marks in the text. That's why, even though both double quote (") and single quote (') will work, I use DOUBLE quotes for the main block. That way I can use single quotes for formatting tags and text inside the block. If you reverse it ... that means you can't use single quotes for things like conjunctions ... which I tend to use more frequently than quotations.
  2. ... More Advanced ...
    • You are able to explicitly desginate which channel to send to by using the channel name with a "/" at the beginning. I did this by putting "/text" in front of the script line. If I had not put this in, then the script would dump to whichever channel I had selected. This can be useful ... but it can also be a problem.

      For instance:
      • /Say - rest of the line is directed to "General"
      • /General - rest of the line is directed to "General"
      • /Help - rest of the line is directed to "Help"
      • /LookingForGroup - goes to the Looking For Group channel
      • /Templar OR /Illuminati OR /Dragon - [SPECIAL] goes to your faction channel. You can only use the channel of your own faction, other commands don't exist for your toon.
      • /Cabalsay - SPECIAL ... sends to your Cabal (don't use "/Cabal", that is a different command)
      • /#ScriptTest - SPECIAL ... rest of this line goes to a custom channel called "ScriptTest". The "#" is required for custom channels. If the channel does not exist you will get an error message. To create the channel, use the "/chat join" command (ie, "/chat join ScriptTest").
      • /text - SPECIAL ... rest of the line is displayed ONLY to you, not a real chat, which is GREAT for testing your output. I will be using this in all of my examples. Once you have your script fine tuned, change "/text" to whatever channel you want it to be posted in, or remove it to have it go to the currently selected channel.
    • You can use <font> tags (older HTML text formatting tag, no CSS or style attributes allowed) to change colors and font size.

      NOTE: Only font face seems to work inside links that are displayed on the chat channel ... ie ... <a href=""><font face=HUGE color=red>test</font></a> will not change the color of the link in the chat window. To make it work, the <font> tag needs to be inside the <a> tag. I could explain the reason for all of this NOTE with archaic HTML rules, but I'm not going to bother.

      I HIGHLY recommend you don't abuse size much, as it will get you ignored at best.

      Example:

      Code: Select all

      /text <a href="text://<font face=SMALL>SMALL</font><br><font face=NORMAL>NORMAL</font> (not needed most times)<br><font face=NORMAL_BOLD>NORMAL_BOLD</font><br><font face=LARGE>LARGE</font><br><font face=LARGE_BOLD>LARGE_BOLD</font><br><font face=HUGE>HUGE</font><br><font face=TSWLARGE>TSWLARGE</font><br><font face=HEADLINE>HEADLINE</font>"><font face=HUGE>TSW font faces</font></a>
      Font faces:
      • NORMAL
      • LARGE
      • LARGE_BOLD
      • HUGE
      • TSWLARGE
      • HEADLINE
      NOTE: There are other font faces, but I've not included them. They are either too large or duplicate another font size.
    • Centering Text ... while you can't use CSS or styles, you can use the <div> element. So to center text, use <div align=center>. <center> works, too. Remember ... this isn't the real WWW ... so don't panic about using old out-of-favor tags.
    • Linking ... Using the in-game web browser you can pull up external links. For instance, to link to the TSW Universe site, you can do this:

      NOTE: There's a chance FC will remove this functionality, as it is a bit hacky and not sure they intended for this.

      Code: Select all

      /text Link to <a href="text://Click the link below to open it in the browser<br><a href='chatcmd:///option WebBrowserStartURL "http://tswuniverse.com/index.html" \n /option web_browser 1'>TSWUniverse.com</a>">Link to TSWUniverse.com</a>
    • Variables ... there are 2 types of variables you can use, (my TSW terminology) game variables and user variables.
      • Game variables ... these will send back something based on what you are doing in-game. For instance, target name, player name, etc. These are more useful for things like targeting scripts than for announcement scripts.
        Examples (may not be complete):
        • %m - YOUR name
        • %t - name of your MAIN target
        • %f - name of your FIGHTING target (may be the same as %m, may not)
        • %0 - name the script file you are executing (ie, if you run "/test.txt" then %0 = "test.txt")
      • User variables ... these are variables you pass to your script on the text entry line.
        • %* - ALL words you put on the input after the script name (easier than typing "%1 %2 %3 %4" ... and the limit should be very high).
        • %1 - The FIRST word you put after the script name (example: "/test.txt BLAH" ... BLAH = %1).
        NOTE: You can have many of these user variables. I've personally tested 50 of them (%1 ... %9 ... %50 ... etc). If you just want to echo the entire string, use %*.
    • Delays ... you can insert a 1-second pause into your script. The command uses milliseconds, so 2000 = 2 seconds, etc.
      /delay 1000
    • Chat links ... you can whisper (tell) someone with a chat link. The following link will send YOURSELF a message. This is done with the "%m" variable. You can change "%m" to any valid character name. It will give an error if they are offline or do not exist.

      Code: Select all

      /text <a href="text://<a href='chatcmd:///w %m Have a message!'>Send yourself a message</a>">Send yourself a message</a>
    • Images ... It should be possible to embed images from the RDB (Resource DataBase) like in AO and AoC, but so far the RDB has not been parsed publicly. If you get examples of images (like the Templar/Illuminati/Dragon logos) please post them and I'll update this.

      They would look like this: <img src=rdb://86483>

      Code: Select all

      /text NOT WORKING: <a href="text://<img src=rdb://86483>">Non-working Image link</a>
  3. ... Putting it all together ...

    You can build fairly detailed scripts.
    • Here is an example of a Templar Cabal announcement script that will broadcast to the Templar channel:

      Code: Select all

      /Templar <font color=#9999FF face=LARGE>Your Cabal Name</font> : <a href="text://<div align=center><font face=HEADLINE color=#9999FF>Your Cabal Name</font><br><font face=LARGE_BOLD color=red>Templar since 2012</font><br><p><font face=HUGE>Click for our forums</font><br><a href='chatcmd:///option WebBrowserStartURL "http://YourCabal.example/forums/" \n /option web_browser 1'>YourCabal.example/forums/</a></p><br><p><font face=LARGE_BOLD>If you have any questions, <a href='chatcmd:///w %m Please contact me about your Cabal!'>just ask</a></font></div>"><font face=LARGE_BOLD>Now Recruiting</font></a>
    • This will take everything you say and make it bigger and brighter

      Important: Umm, so if you really do this, you'll just end up ignored ... but you'd have figured this out without me ... save it for raids or PVP ... you can figure out how to make it actually send to other people.

      Code: Select all

      /text <font face=LARGE_BOLD color=yellow>%*</font>



PS. Standard disclaimer: I'm not accepting tech support requests in-game ... if you didn't figure it out from above, it should at least have been enough to get you started. Thank yous are fine :) Support requests will eventually get you ignored.
User avatar
Sillanto
Leetissimo!
Posts: 1314
Joined: Tue Apr 25, 2006 11:35 am
Location: Bristol, UK

Re: FAQ: Building a pop-up chat window

Post by Sillanto »

Nice FAQ :) Thanks Hyde
You want it made ..... See me
You want it broken ... See me
You want it fixed....... Send your hampster to FC
User avatar
Chrisax
President
Posts: 23107
Joined: Wed Apr 19, 2006 1:08 pm

Re: FAQ: Building a pop-up chat window

Post by Chrisax »

=D> :D :happytrooper:
Post Reply