Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Road data/strings/doc
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Structure== Each country has its own module. In the United States and Canada, each state/territory/province also has its own module. Each module begins with a comment stating the name of the country or state, followed by the root table declaration, as follows (from [[Module:Road data/strings/USA/AS]]): <syntaxhighlight lang="lua"> -- American Samoa local AS = {} </syntaxhighlight> The root table is named based on the established abbreviation for the country or state, which is the same as the abbreviation used in the module title. This table stores the various types used in that particular place. Most of the remaining code in the module defines these various types. The module ends by returning the root table: <syntaxhighlight lang="lua"> return AS </syntaxhighlight> ===Aliasing=== There are two ways to define a type as an alias. If the type is defined within the module, simply set the new type as equal to the type being aliased, as shown above (from [[Module:Road data/strings/HKG]]): <syntaxhighlight lang="lua"> HKG.Route = { shield = "HK Route%route%.svg", link = "Route %route% (Hong Kong)", abbr = "Route %route%" } HKG.route = HKG.Route </syntaxhighlight> If the type is defined in a separate module, such as a state highway type being used in another state's module, a special syntax may be used to refer to that module (from [[Module:Road data/strings/USA/NJ]]): <syntaxhighlight lang="lua"> NJ.NY = {alias = {module = "USA/NY", type = "NY"}} </syntaxhighlight> This code sets the <code>NY</code> type as a link to the <code>NY</code> type in [[Module:Road data/strings/USA/NY]]. The parser will import that module and process the type as if the original module had declared it itself. The alias declaration may not add or override any data in the type table it points to. ===Inheriting types=== It is possible to predefine several types for a location by inheriting them from another module. In this example, the module for Albania inherits all of the specified types from the Europe module. <syntaxhighlight lang="lua"> -- Albania local ALB = {} local util = require("Module:Road data/util") util.addAll(ALB, require("Module:Road data/strings/EUR")) </syntaxhighlight> {{n.b.}} Only one module may be inherited at this time. <!-- if they don't intersect it might not be true -->
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)