User Tools

Site Tools


dev:core:funref:is_track_and_drives_on

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
dev:core:funref:is_track_and_drives_on [2019-10-02 20:30]
82.67.173.193 created
dev:core:funref:is_track_and_drives_on [2020-01-22 10:53] (current)
admin ↷ Page moved from reference:advtrains:is_track_and_drives_on to dev:core:funref:is_track_and_drives_on
Line 10: Line 10:
  
 ===== Extended description ===== ===== Extended description =====
-This function creates string from the given Minetest position vector, suitable for use as table index  +This function is used to check whether certain node is valid trackIn case a train can only drive on certain [[dev:core:tracktype]]s, can also restrict the valid tracktypes to the ones given.
-See also ''[[reference:advtrains:encode_pos|advtrains.encode_pos]]''.+
  
 ===== Parameters ===== ===== Parameters =====
   * ''nodename'' //(string)//: the track node name.   * ''nodename'' //(string)//: the track node name.
-  * ''drives_on_p'' //(table)//: a table containing track node names the train can drive on.+  * ''drives_on_p'' //(table)//: a table containing tracktype names the train can drive on. Defaults to advtrains.all_tracktypes.
  
 ===== Returns ===== ===== Returns =====
Line 21: Line 20:
  
 ===== How it works internally ===== ===== How it works internally =====
-Firstly, this function checks the parameter ''drives_on_p''. If it is ''nil'' or empty, the parameter is replaced with ''[[reference:advtrains:all_tracktypes|advtrains.all_tracktypes]]''. Then, it checks the existence of the specified ''nodename'' - if it does not exist, the function returns immediately.  +Firstly, this function checks the parameter ''drives_on_p''. If it is ''nil'' or empty, the parameter is replaced with ''[[dev:core:tracktype|advtrains.all_tracktypes]]''. Then, it checks the existence of the specified ''nodename'' - if it does not exist, the function returns immediately.  
 The third step is to check that the track group of the node definition is present in the ''drives_on_p'' table.\\ The third step is to check that the track group of the node definition is present in the ''drives_on_p'' table.\\
 If one of the keys in the table matches the node name, the function returns **true**. Otherwise it returns **false**. If one of the keys in the table matches the node name, the function returns **true**. Otherwise it returns **false**.
dev/core/funref/is_track_and_drives_on.1570041047.txt.gz · Last modified: 2019-10-02 20:30 by 82.67.173.193