Versions
Overview
Diversity is a simple tool to control languages. You want to use multiple languages in your script? Use Diversity!
Example
1
2
2
Welcome, $1! Enjoy your stay!
1
2
2
Selamat datang, $1! Bersenang-senanglah!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local language = require("sys/lua/diversity") local currentlanguage = {} for id = 1, 32 do 	currentlanguage[id] = "English" end function serveractionhook(id, action) 	if (action == 1) then 		currentlanguage[id] = currentlanguage[id] == "English" and "Indonesian" or "English" 	end end function joinhook(id) 	msg2(id, language(currentlanguage[id], 1, player(id, "name")) .. "@C") 	msg2(id, language(currentlanguage[id], 2) .. "@C") end addhook("serveraction", "serveractionhook") addhook("join", "joinhook")
Documentation
This is the section where you can learn how to add your own languages and how to use them.
First, let's take a look of the configurations.cfg file. There're several configurations you can set on your liking. First is loaddirectory configuration, is to set the load directory of your languages. Second is officiallanguages configuration, is to set the official languages of your script, so if these official languages aren't available, there will be an error.
Second, is to understand how to add your own languages. You need to insert your languages inside the loaddirectory configuration directory. Your language files must be in text (*.txt) form. A new line is to end a line of your languages' lines, just like the usual. There's a symbol that used to manipulate the strings of the languages, that is '$'. '$' is used for subtitution. Example of a complete language:
1
2
2
You've been attacked by $1! Are you sure to replace $1 with $2?
Third, is to understand how to use the languages. You need to understand how to use functions, that's it. First load Diversity to your script by requiring it, and save it to a variable:
1
local language = require("sys/lua/diversity")
1
<variable>(<language-name>, <language-line>,[ <line-subtitution-1>, <line-subtitution-2>, ...])
1
2
3
2
3
language("English", 1) -- You've been attacked by $1 language("English", 1, "Ortimh") -- You've been attacked by Ortimh language("English", 2, "null", "nil") -- Are you sure to replace null with nil?
Rules
• You are allowed to use this script in your server.
• You are allowed to edit this script for your server.
• You are not allowed to copy any part of this script without permission.
• You are not allowed to say this script is yours.
Installation
1. Download the file and then extract it anywhere in your CS2D directory.
2. Connect your script with this script using require.
3. Use Diversity to control your languages!
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
edited 9×, last 16.06.16 08:39:25 am
Approved by GeoB99
Download
3 kb, 506 Downloads