Scripts should be used with respect for other players. Big fonts or too many bright colors directly in the chat window will not be appreciated and may cause people to put you in their ignore list.
Also make sure to test your scripts in a custom channel before using them in populated chat rooms. If something in your script is broken, the chat window will fill up with broken code. To create your own custom channel type:
Where [ChannelName] should be replaced with the name you want to use for your test channel.
Scripts in TSW is a way to significantly expand the range of things we can do in the chat window. Some common tasks we can accomplish with scripts are:
- Colored text
- Sequences of chat commands
- Pop-up windows
Before we go into making our own scripts we will first have a look at what scripts are and how to use them.
Scripts are text files stored in a specific folder inside your game folder. For a script to be available in game, it has to be stored in the following location:
If the Scripts folder does not exist on your computer, you can create it yourself in the location listed above.
In the game script files are accessed by their full names, including the file extension. It’s therefore common to leave script files without an extension. If you’re using the regular notepad on windows, it will automatically add .txt to the end of your file name. To remove the extension, go into your Scripts folder, make sure the folder is set to show file extensions. Then remove the extension from the name.
Using scripts is simple. Go to your chat window in the game, type a forward slash followed by the name of your script file. For example, a file called helloworld.txt would by called by typing the following in the chat:
If your script outputs text, it will show in the currently active channel.
Scripts can use variables to pass along words from the chat into the script. Each word after the file name will be put into the variables %1, %2, %3… and so on, or %* for all the words that follow.
My name is %1 and I like %2.
/helloworld.txt Chosen-Blood tacos
My name is Chosen-Blood and I like tacos.
I love %*!
/helloworld.txt TSWDB and ice cream
I love TSWDB and ice cream!
%m – Your own name
%t – Your target’s name
%f – Hostile target’s name
%0 – The name of the script
We use the <font> tag along with the color attribute to write in a different color.
For the sake of the rest of us, please don’t use colors directly in the chat more than necessary.
This text is <font color=red>red</font>.
This text is red.
/pink This text is pink.
This text is pink.
List of some available predefined colors: https://pastebin.com/QqAFvXYw
There is a limited amount of sizes you can choose from. Each size (font face) is defined in file inside your game folder. This file can be altered to change how big the text in your own chat window will appear. This also means that people who have altered this file may see your scripts differently than you do.
And even more so here than with the colors, think before you cover the entire chat window with a huge font.
<font face=normal>Smaller text</font>
/bold This text is bold.
This text is bold.
Note: The standard font face in the chat window is LARGE
Full list of font faces: https://pastebin.com/9Wz8uaUC
Basically you could think of your notepad as a chat window. Each new row is another line in the chat. And on any one of those lines you can use any command you would in the game.
/say Hi %t
1 – Emote: wavebig
2 – Hi Vikestart
There is one command in particular that you will have use for in your scripts. The delay command will allow you to set an ammount of time in milliseconds that will pass before the next command is executed.
1 – Emote: dance_runningman
– 5 second delay
2 – Emote: dance_gangnam_style
– 5 second delay
3 – Emote: dance_samba
You can also cause the script to call itself. This will cause an infinite loop. The script will continue to repeat itself until the game thinks you’ve had enough or you reload your ui (ctrl + shift + F1).
1 – Emote: dance_funkychicken
– 4 second delay
2 – Emote: dance_funkychicken
– 4 second delay
3 – …
Before going into popups you should have some knowledge of the different types of links we can use. If you’re familiar with HTML, you’ll recognize the <a href=””> … </a> tag for links.
There are three different types of links we can use in the game.
All linked items in the game uses this. Sometimes when someone links too many items at once (exceeds the character limit of scripts), the code will brake and you will see this between the lines. Will not be going into depth on item references in this guide.
Used to trigger chat commands from within a popup. Using this in a popup will allow you to create buttons which other players can click to trigger chat commands.
This is how we create a popup.
There are 3 important things in particular you’ll want to keep track of when creating links.
Make sure you read the paragraph about links above before continuing. If you have done so, you know the most important things we’ll need to create our first popup.
Example 1 – Simple popup
<a href=”text://<CENTER><BR><FONT FACE=HEADLINE COLOR=ENCHANTED>My first popup!</FONT></CENTER>”>Click me!</a>
Tags that can be used in popups
Applies from start tag to end tag, described in the beginning of the guide.
Additional links can be put inside the popup to trigger chat commands (including opening the browser).
Creates a new line, requires no end tag.
Aligns all text to the left from start to end tag.
Centers all text from start tag to end tag.
Aligns all text to the right from start to end tag.
Example 2 – Emote Link
<a href=”text://<DIV ALIGN=CENTER><A HREF=’chatcmd:///lookup’>Up</A></DIV><DIV ALIGN=LEFT><A HREF=’chatcmd:///lookleft’>Left</A></DIV><DIV ALIGN=RIGHT><A HREF=’chatcmd:///lookright’>Right</A></DIV>”>Look here!</a>
Up – Emote: lookup
Left – Emote: lookleft
Right – Emote: lookright
Example 3 – Browser Link
<a href=”text://<CENTER><FONT COLOR=#AACCFF FACE=COMBAT_FEEDBACK>Browser Link</FONT><BR><BR><FONT FACE=HYBORIANLARGE><A HREF=’chatcmd:///option WebBrowserStartURL "%1" \n /option web_browser 1′>%1</A></FONT>”>%1</a>
Link – Open browser to https://legacy.tswdb.com/
Something you’ll notice in the previous example if you look closely is we’re using two commands in the same link. The first to set the starting URL of the browser, the second to open the browser. Between them you can see the character \n which is the character for a line break. As stated earlier, a new line means a new command. So setting a new line within our link allows us to call more than one command.
Example 4 – Styled Link
<a style=”text-decoration:none” href=”text://<CENTER><A STYLE=’text-decoration:none’ HREF=’chatcmd:///option WebBrowserStartURL "https://bit.ly/1kD1nPk" \n /option web_browser 1′><FONT FACE=LARGE COLOR=#FF99EE>[Pony]</FONT></A>”><font face=LARGE color=#FF99EE>[Pony]</font></a>
Pony – Opens a picture of ponies
There are script names that are reserved for the game. For example we can’t name our scripts magic or tp since these are commands for game masters. But there are two special script names we can use. These are auto_login and auto_teleport.
These files are very useful for joining custom chats such as #noobmares and #sanctuary automatically when you log on. You can read more about these scripts and other useful channels to join in this forum thread by Hatkake: https://forums.thesecretworld.com/showthread.php?74514-Scripts-for-Customchats