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.txt31
1 files changed, 18 insertions, 13 deletions
diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt
index 3cb58e5..7bd9c44 100644
--- a/advtrains/api_doc.txt
+++ b/advtrains/api_doc.txt
@@ -102,7 +102,7 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
return "<a formspec>"
end,
^- Function that should return the formspec to be displayed when <player> requests to open the wagon's inventory
- ^- Use "list[detached:advtrains_wgn_"..self.unique_id..";<list_name>;<X>,<Y>;<W>,<H>;<Start>]" to display a wagon's inventory list.
+ ^- Use "list[detached:advtrains_wgn_"..self.id..";<list_name>;<X>,<Y>;<W>,<H>;<Start>]" to display a wagon's inventory list.
custom_on_step = function(self, dtime) end
^- optional: Execute custom code on every step
@@ -116,8 +116,8 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
# Notes on wagons
-- Every wagon has the field 'unique_id' which assigns each wagon a random id.
-- All properties written in the lua entity (self) are saved and restored automatically. Minetest's internal staticdata is only used to save the unique_id of the wagon, which serves as a key in an externally saved table.
+- Every wagon has the field 'id' which assigns each wagon a random id.
+- Properties written in the Lua Entity (self) are discarded when the wagon entity is unloaded. At the moment there is no way to store data inside a wagon persistently.
- Assuming Z Axis as the axis parallel to the tracks and Y Axis as the one pointing into the sky, wagon models should be dimensioned in a way that:
- their origin is centered in X and Z direction
- their origin lies 0.5 units above the bottom of the model
@@ -140,22 +140,27 @@ If you can't enter or leave a train because the doors are closed, holding the Sn
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.
However, it is still possible to register single rails by understanding the node properties of rails.
-minetest.register_node(nodename, { -- TODO this is outdated!
+minetest.register_node(nodename, {
... usual node definition ...
groups = {
+ advtrains_track = 1,
advtrains_track_<tracktype>=1
- ^- this group tells that the node is a track
+ ^- these groups tell that the node is a track
not_blocking_trains=1,
^- this group tells that the node should not block trains although it's walkable.
},
- connect1 = 0,
- connect2 = 8,
- ^- These values tell the direction (horizontal) the rail ends are pointing to. 0 means +Z, then rotation values increase clockwise. For a translation of directions to positions see helpers.lua.
- rely1=0,
- rely2=0,
- ^- the Y height of the rail end 1/2. A value of >=1 means that the rail end points to the next y layer at rely-1
- railheight=0,
- ^- the height value of this rail that is saved in the path. usually the median of rely1 and rely2.
+
+ at_rail_y = 0,
+ ^- Height of this rail node (the y position of a wagon that stands centered on this rail)
+ at_conns = {
+ [1] = { c=0..15, y=0..1 },
+ [2] = { c=0..15, y=0..1 },
+ ( [3] = { c=0..15, y=0..1 }, )
+ ( [4] = { c=0..15, y=0..1 }, )
+ }
+ ^- Connections of this rail. There can be up to 4 connections.
+ 2 connections are a normal rail, 3 connections a turnout (1->2 and 2/3->1) and 4 connections a crossing (1<>2 and 3<>4)
+ c is the direction of the connection (0-16) and y is the height of the connection (rail will only connect when this matches)
can_dig=function(pos)
return not advtrains.get_train_at_pos(pos)