Based on examples, all required and optional field for the mod.lua and strings.lua files are explained in this article.
[img]https://ftp.train-fever.net/flaggen/de.png[/img] Die Deutsche Version gibt es hier: [url='https://www.transportfever.net/lexikon/index.php/Entry/213-mod-lua-und-strings-lua-Erkl%C3%A4rung-und-Inhalt/']mod.lua und strings.lua - Erklärung und Inhalt[/url]
1 Official Format by Urban Games (mod.lua)
The basic format of the mod.lua file that is required for each mod in the root directory
[code='mod.lua']function data()
return {
info = {
name = _("Sample mod"), -- name of mod
description = _("modDesc"), -- optional, description
minorVersion = 0, -- minorVersion (integer)
severityAdd = "WARNING", -- NONE, WARNING, CRITICAL
severityRemove = "CRITICAL", --
visible = true, -- optional, default: true
-- if false, mod is hidden
},
-- options = ..
-- runFn = ..
-- checkActiveFn = ..
}
end[/code]
2 Additional Information for TPFMM
[b]Basic Information[/b]
[code]tfnetId = 0, -- optional, transportfever.net entry id
steamId = 0, -- optional, steam workshop file id
url = "https://transportfever.net" -- optional, url to mod homepage[/code][b]Authors[/b]
[code]authors = { -- optional, information about authors
{ -- add one or multiple authors
name = "Author 1", -- author name
role = "CREATOR", -- CREATOR, CO_CREATOR, TESTER, BASED_ON, OTHER
tfnetId = 00000, -- optional, id at transportfever.net
steamId = 0000, -- optional, steam id
}, -- optional, add more authors
},[/code][b]Tags[/b]
[code]tags = { "tag1", "tag2", "tag3" }, --optional, list of tags[/code][b]Dependencies[/b]
Define dependencies to other mods that are required in order for the mod to function as desired, not evaluated by the game but informs mod managers which other mods to download. For the download, at least one online source has to be defined
[code]dependencies = { "other_mod_1", "another_mod_1", "third_mod_1" },[/code]
3 Translations (strings.lua)
All strings put in [tt]_("")[/tt] will be translated based on the strings.lua file:
[code]function data()
return {
de = {
["my mod"] = "Mein Mod", -- call to _("my mod") will be
-- replaced with "mein Mod",
-- if language is german
["the description"] = "Beschreibung",
-- _("the description") ⇒ "Beschreibung"
},
}
end[/code][box]Note:
If a variable is passed to the [tt]_()[/tt] function, the content of the variable, not the variable name itself is passed to the function. This, in combination with global variables in lua lead to the scenario in which description and name of multiple mods where overwritten by each other in a beta patch of Transport Fever. Although this is fixed by now, Urban Games and strongly advises to only use local variables. [b]Pesonally, I advice to not use variables for the translation function.[/b][/box]
4 Example Files
[u][b]Very simple file with single author[/b][/u]
[code='mod.lua']function data()
return {
info = {
name = _("name"),
description = _("desc"),
minorVersion = 2,
severityAdd = "NONE"
severityRemove = "CRITICAL",
authors = {
{
name = "John Doe",
role = "CREATOR",
tfnetId = 1,
},
},
tags = {"train", "multiple_unit"},
},
}
end[/code]
[code='strings.lua']function data()
return {
en = {
["name"] = "My Train Mod",
["desc"] = "This is my first train mod. Have fun.",
},
de = {
["name"] = "Mein Zug Mod",
["desc"] = "Das ist mein erster Zug Mod, viel Spaß.",
},
}
end[/code][u][b]A repaint mod, that requires the mod defined above[/b][/u]
[code='mod.lua']function data()
return {
info = {
name = _("name"),
description = _("desc"),
minorVersion = 1,
severityAdd = "NONE"
severityRemove = "CRITICAL",
authors = {
{
name = "jane",
role = "CREATOR",
tfnetId = 00000,
steamId = 0000,
text = "text",
},
{
name = "John Doe",
role = "BASED_ON",
tfnetID = 1,
},
},
dependencies = { "base_mod_1" },
tags = {"repaint", "train", "multiple_unit"},
},
}
end[/code][code='strings.lua']function data()
return {
en = {
["name"] = "My Repaint Mod",
["desc"] = "My first Repaint",
},
de = {
["name"] = "Mein Repaint Mod",
["desc"] = "Mein erstes Repaint.",
},
}
end[/code]