Skip to content

Commit 6a6707c

Browse files
authored
Merge branch 'TotalControlAdmin:master' into master
2 parents 82c2553 + d8ba749 commit 6a6707c

3 files changed

Lines changed: 80 additions & 10 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "IronPython",
3+
"position": 1,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "IronPython in Custom Scripts"
7+
}
8+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
sidebar_label: Import Python Modules
3+
sidebar_position: 1
4+
---
5+
IronPython is regular Python but with the option of using .NET classes or DLL files (e.g. the TCAdmin SDK).
6+
7+
## Use .NET in IronPython
8+
If you want to use any of the .NET classes, you will need to import them into the IronPython script like you would in Python. Before using any .NET classes, you will need to import the clr module, however.
9+
This is an example of how to use the .NET WebClient class, so we can use the `DownloadFile()` method:
10+
```py
11+
from System.Net import WebClient
12+
from System.IO import Path
13+
14+
#Download the TCAdmin logo to the service's root directory
15+
try:
16+
wc = WebClient()
17+
wc.DownloadFile('https://clients.tcadmin.com/billing/images/logo.png', Path.Combine(ThisService.RootDirectory, 'tcadmin-logo.png'))
18+
except Exception as e:
19+
Script.WriteToConsole('Could not download the file. Error: {}'.format(e))
20+
```
21+
22+
## Use the TCAdmin SDK
23+
Before you can use the TCAdmin SDK (or any DLL files for that matter), you need to reference them first. This is done by using the `clr.AddReference()` method.
24+
```py
25+
import clr
26+
clr.AddReference('TCAdmin.SDK')
27+
from TCAdmin.SDK import Mail
28+
29+
#Print the control panel URL to the script window
30+
company_info = Mail.CompanyInfo()
31+
Script.WriteToConsole(company_info.ControlPanelUrl)
32+
```
33+
34+
## Use custom Python modules
35+
In some cases, you might need to use a module that is not included in the default Python library.
36+
```py
37+
import sys
38+
sys.path.append('C:\\CustomPythonModules\\Lib')
39+
from bs4 import BeautifulSoup
40+
# do stuff with bs4
41+
```

docs/using-tcadmin/game-voice-configuration/variables.mdx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,44 @@ sidebar_position: 16
55

66
# Variables
77

8-
Variables allow you to have addtional values that the user can input when creating or configuring a service. These can be used in the game's configuration files (via the config editor) or in commandlines.
8+
Variables are an important part of TCAdmin. They allow you to set predefined values for specific elements (e.g. settings in a configuration file) or the command line. You can also use variables in custom scripts.
9+
If you want to use a variable in a configuration file or the commandline, you should use `$[DefaultVariableName]` or `![CustomVariable]`.
10+
If you want to use a variable in a custom script, please see the documentation for [ThisService](/customizations/scripts/script-objects/this-service#custom-variables).
911

10-
To use custom variables in the command line or in configuration use this format:
12+
## Default Variables
13+
All services have a few default variables configured. Some of these could be for the hostname, rcon password and private password.
1114

12-
```
13-
![VariableName]
14-
```
15-
16-
## Custom Variable
15+
## Custom Variables
16+
You can create your own variables for each of your game templates. This is done under the "Variables" tab in the game settings.
1717

1818
- `Variable Name` - The unformatted name of the variable. You should not change the name if this variable is already in use.
1919
- `Default Value` - The default value for this variable. `For example 'changeme'.`
2020

21-
## Commandline Parameter Options
21+
### Commandline Parameter Options
2222

23-
- `User access` - Specify if the user is able to set the value of this variable when using the commandline builder.
23+
- `Admin/Sub admin/Reseller/User/Server owner access` - Specify if the given role is able to set the value of this variable when using the commandline builder or executing a custom script.
2424
- `Value is required` - Specify if the value is required.
2525
- `Item Type` - Select the type of item that will be used to capture the user's input.
2626
- `Parent Variable` - Select the item's parent value.
27-
- `Parent Value` - The item will only be displayed if the parent variable has this value.
27+
- `Parent Value` - The item will only be displayed if the parent variable has this value.
28+
29+
### Display formatting for File System ComboBox
30+
Starting from TCAdmin 2.0.187.5, you have the ability to manipulate how a specific variable is shown to the user.
31+
This is done using the 'Display Regex' and 'Display Format' fields.
32+
33+
The following is an example on how you could manipulate the value of a ComboBox that is generated based on folders in `backups/worlds/` on the game service.
34+
The folders inside `backups/worlds/` are named based on the date and time they were created (%Y-%m-%d_%H%M%S):
35+
- 2023-08-27_220030
36+
- 2023-08-27_100030
37+
- 2023-08-26_220030
38+
39+
If you want to manipulate how this is shown in the ComboBox, you can use regex to change how the values are shown:
40+
**Display Regex**: (\d{4}-\d{2}-\d{2})_(\d{2})(\d{2})(\d{2})
41+
**Display Format**: $1 $2:$3:$4
42+
43+
The above will result in the following formatting:
44+
- 2023-08-27 22:00:30
45+
- 2023-08-27 10:00:30
46+
- 2023-08-26 22:00:30
47+
48+
The actual value of the variable is not affected by the formatting.

0 commit comments

Comments
 (0)