@@ -742,11 +742,46 @@ Call these functions only at load time!
742
742
* Returns the node at the given position as table in the format
743
743
`{name="node_name", param1=0, param2=0}`, returns `nil`
744
744
for unloaded areas or flavor limited areas.
745
+ * `minetest.get_node_light(pos, timeofday)`
746
+ * Gets the light value at the given position. Note that the light value
747
+ "inside" the node at the given position is returned, so you usually want
748
+ to get the light value of a neighbor.
749
+ * `pos`: The position where to measure the light.
750
+ * `timeofday`: `nil` for current time, `0` for night, `0.5` for day
751
+ * Returns a number between `0` and `15` or `nil`
745
752
* `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns pos or `nil`
746
753
* `radius`: using a maximum metric
747
754
* `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
748
755
* `search_center` is an optional boolean (default: `false`)
749
756
If true `pos` is also checked for the nodes
757
+ * `minetest.find_nodes_in_area(pos1, pos2, nodenames)`: returns a list of
758
+ positions.
759
+ * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
760
+ * First return value: Table with all node positions
761
+ * Second return value: Table with the count of each node with the node name
762
+ as index.
763
+ * Area volume is limited to 4,096,000 nodes
764
+ * `minetest.find_nodes_in_area_under_air(pos1, pos2, nodenames)`: returns a
765
+ list of positions.
766
+ * `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
767
+ * Return value: Table with all node positions with a node air above
768
+ * Area volume is limited to 4,096,000 nodes
769
+ * `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos`
770
+ * Checks if there is anything other than air between pos1 and pos2.
771
+ * Returns false if something is blocking the sight.
772
+ * Returns the position of the blocking node when `false`
773
+ * `pos1`: First position
774
+ * `pos2`: Second position
775
+ * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast`
776
+ * Creates a `Raycast` object.
777
+ * `pos1`: start of the ray
778
+ * `pos2`: end of the ray
779
+ * `objects`: if false, only nodes will be returned. Default is `true`.
780
+ * `liquids`: if false, liquid nodes won't be returned. Default is `false`.
781
+
782
+ * `minetest.find_nodes_with_meta(pos1, pos2)`
783
+ * Get a table of positions of nodes that have metadata within a region
784
+ {pos1, pos2}.
750
785
* `minetest.get_meta(pos)`
751
786
* Get a `NodeMetaRef` at that position
752
787
* `minetest.get_node_level(pos)`
@@ -1073,6 +1108,32 @@ Can be obtained via `minetest.get_meta(pos)`.
1073
1108
* `fields`: key-value storage
1074
1109
* `inventory`: `{list1 = {}, ...}}`
1075
1110
1111
+ ### `Raycast`
1112
+
1113
+ A raycast on the map. It works with selection boxes.
1114
+ Can be used as an iterator in a for loop as:
1115
+
1116
+ local ray = Raycast(...)
1117
+ for pointed_thing in ray do
1118
+ ...
1119
+ end
1120
+
1121
+ The map is loaded as the ray advances. If the map is modified after the
1122
+ `Raycast` is created, the changes may or may not have an effect on the object.
1123
+
1124
+ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
1125
+ `minetest.raycast(pos1, pos2, objects, liquids)` where:
1126
+
1127
+ * `pos1`: start of the ray
1128
+ * `pos2`: end of the ray
1129
+ * `objects`: if false, only nodes will be returned. Default is true.
1130
+ * `liquids`: if false, liquid nodes won't be returned. Default is false.
1131
+
1132
+ #### Methods
1133
+
1134
+ * `next()`: returns a `pointed_thing` with exact pointing location
1135
+ * Returns the next thing pointed by the ray or nil.
1136
+
1076
1137
-----------------
1077
1138
### Definitions
1078
1139
* `minetest.get_node_def(nodename)`
0 commit comments