raycast.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ---@meta
  2. ---Raycast
  3. ----------
  4. --[[
  5. A raycast on the map. It works with selection boxes. Can be used as an iterator
  6. in a for loop as:
  7. local ray = Raycast(...)
  8. for pointed_thing in ray do
  9. ...
  10. end
  11. The map is loaded as the ray advances. If the map is modified after the
  12. `Raycast` is created, the changes may or may not have an effect on the object.
  13. It can be created via `Raycast(pos1, pos2, objects, liquids)` or
  14. `minetest.raycast(pos1, pos2, objects, liquids)` where:
  15. - `pos1`: start of the ray
  16. - `pos2`: end of the ray
  17. - `objects`: if false, only nodes will be returned. Default is true.
  18. - `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be returned.
  19. Default is false.
  20. ]]
  21. ---@class mt.Raycast
  22. local RaycastClass
  23. ---@param pos1 mt.Vector Start of the ray.
  24. ---@param pos2 mt.Vector End of the ray.
  25. ---@param objects boolean If false, only nodes will be returned. Default is true.
  26. ---@param liquids boolean if false (default), liquid nodes (`liquidtype ~= "none"`) won't be returned.
  27. ---@return mt.Raycast
  28. function Raycast(pos1, pos2, objects, liquids) end
  29. minetest.raycast = Raycast
  30. -- Returns a `pointed_thing` with exact pointing location
  31. -- - Returns the next thing pointed by the ray or `nil`.
  32. ---@return mt.PointedThing|nil
  33. function RaycastClass:next() end