aboutsummaryrefslogtreecommitdiff
path: root/advtrains/api_doc.txt
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains/api_doc.txt')
-rw-r--r--advtrains/api_doc.txt62
1 files changed, 14 insertions, 48 deletions
diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt
index d3e7ca9..5668ba3 100644
--- a/advtrains/api_doc.txt
+++ b/advtrains/api_doc.txt
@@ -75,9 +75,23 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
^- Getting on by walking in then takes effect.
^- Positive values mean front, negative ones back. Resulting position is automatically shifted to the right side.
+ coupler_types_front = {scharfenberg=true},
+ coupler_types_back = {chain=true},
+ ^- Defines the available coupler types on this wagon on the front and back side. Wagon will only couple to wagons that have a matching coupler. (this property does not have any visual impact)
+ ^- Default: not given (nil) - causes the wagon to couple to any other wagon regardless of coupler type.
+ ^- Empty table ({}): This wagon does not couple to any other wagon (e.g. for Linetrack vehicles)
+ ^- Register coupler types using ''advtrains.register_coupler_type(type, name)''. advtrains defines the default types "chain" (Buffer and Chain) and "scharfenberg" (Scharfenberg coupler).
+
wagon_span=2,
^- How far this wagon extends from its base position. Is the half of the wagon length.
^- Used to determine in which distance the other wagons have to be positioned. Will require tweaking.
+ wheel_positions = {1.5, -1.5},
+ ^- Optional: if defined, the wagon will be placed so that these 2 wheel positions are on the track
+ ^- This parameter is recommended for long wagons (wagon_span >= 2).
+ ^- The position is a distance relative to the center of the wagon.
+ ^- Must have exactly 2 entries, corresponding to the front (1) and rear (2) wheel of the wagon object. 1st must be greater than 2nd.
+ ^- If not provided, the simple 1-position positioning logic will be used (wagon is positioned with the center on the track)
+
extent_h = 1,
^- Determines the collision box extent in x/z direction. Defaults to 1 (=3x3)
^- The actual bounding box size is (extent_h*2)+1, so 0 means 1x1, 1 means 3x3 and 2 means 5x5
@@ -106,12 +120,6 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
^- both the inventory grid and a 'Wagon properties' button.
^- Use "list["..inventory_name..";<list_name>;<X>,<Y>;<W>,<H>;<Start>]" to display a wagon's inventory list.
- text_hud = function(train, flip) end
- ^- optional: Text HUD to show to the driver. The inside display is automatically prepended.
- graphical_hud = function(train, flip) end
- ^- optional: Graphical HUD to show to the driver.
- The HUD formats defined by advtrains are used by default.
-
custom_on_step = function(self, dtime) end
^- optional: Execute custom code on every step
custom_on_activate = function(self, dtime_s) end
@@ -144,48 +152,6 @@ In case there are multiple possibilities, will show a form.
If you can't enter or leave a train because the doors are closed, holding the Sneak key while right-clicking bypasses the "doors have to be open" enforcement.
-# Train HUD
-The text_hud and graphical_hud fields of the wagons allow you to specify the look of your driver HUDs.
-* The text_hud function should return a string that will be shown to the driver. This should usually include the inside display as well
-* The graphical_hud function should return a texture string and the height of the texture. This is used to allow proper positioning of the text HUD.
-
-There are currently a few pre-defined elements that can help create the graphical HUD. These functions are in the advtrains.hud table:
-* texture_escape(str): a trivial function that escapes the textures
-* digit(digit, x, y, w, h, pc, nc): displays a single digit
- * digit: the digit to display
- * x, y: the upper-left corner of the digit display
- * w, h: the width and height of a horizontal segment
- * pc: the color to show when a given segment is lit
- * nc: the color to show when a given segment is not lit
-* number(num, length, x, y, w, h, margin, pc, nc): displays a non-negative integer, possibly using multiple 7-segment displays:
- * num: the number to display
- * length: the numbers of digits to display (if nil: the number of digits in the number).
- * x, y: the upper-left corner of the digit display
- * w, h, pc, nc: (see above)
- * margin: the margin between each digit
- * The behavior of num>=10^length is undefined.
-* leverof(train): returns the lever of the train. This should be preferred over train.lever
-* lever(lever, x, y, w1, w2, h): draws a lever
- * lever: the lever of the train
- * x, y: the upper-left corner of the lever
- * w1: the width of the merkers beside the lever
- * w2: the width of the handle
- * h: the height of the lever
- * In the context of drawing (i.e. the description of the x, y, w1, w2, and h arguments), "the lever" refers to the area that the actual lever is drawn in, not the lever itself.
-* door(o, x, y, w, h, m): draws a simple door indicator
- * o: the state of the door
- * x, y, w, h: the upper-left corner and the size of the indicator
- * m: the margin between the elements of the indicator
- * The indicator includes an indicator for each door and a simple shape showing a vehicle
- * Due to the internals of this function, it is recommended that (w-2*m) is a multiple of 4
-* speed_horizontal(train, x, y, w, h, m): draws a horizontal bar showing the speed
- * train: the train table
- * x, y, w, h: the upper-left cornder and the size of the indicator
- * m: the margin between the elements of the indicator
- * h must be greater than 10
- * Due to the internals of this function, it is recommended that (w-19*m) is a multiple of 20
-* In the above functions, the behavior of negative coordinates and magnitudes (e.g. width, height, margin) and invalid data is undefined.
-
### Tracks
Most modders will be satisfied with the built-in tracks. If cog railways, maglev trains and mine trains are added, it is necessary to understand the definition of tracks. Although the tracks API is there, explaining it would require more effort than me creating the wanted definitions myself. Contact me if you need to register your own rails using my registration functions.