mod_api.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. boost_cart API
  2. ==============
  3. This file provides information about the API of boost_cart for the use in
  4. mods. The API might change slightly when the development goes on, so avoid
  5. using internal tables or functions which are not documented here.
  6. Types
  7. -----
  8. * `SwitchIgnore` -> `number/nil`
  9. * Specifies which player control was pressed. This value is used to prefer
  10. straight rails instead of preferring left and right rail checks.
  11. * `1`: Ignore left rail
  12. * `2`: Ignore right rail
  13. * `nil`: Ignore no rail
  14. Entity movement
  15. ---------------
  16. These functions are grouped so that they make sense and then sorted alphabetically.
  17. * `boost_cart:manage_attachment(player, obj)`
  18. * Attaches or detaches the player to/from an object, depending on what is
  19. supplied to `obj`.
  20. * `player`: `ObjectRef` of the player
  21. * `obj`: `ObjectRef` (to attach) or `nil` (to detach)
  22. * `boost_cart:get_sign(n)` -> `number`
  23. * Returns the sign for the given number. Values: `-1`, `0`, `1`
  24. * `n`: any `number`
  25. * `boost_cart:velocity_to_dir(vel)` -> `vector`
  26. * Returns the cart direction depending on `vel`. Each coordinate can have
  27. one of the `get_sign()` return values.
  28. * `vel`: velocity as `vector`
  29. * `boost_cart:boost_rail(pos, amount)`
  30. * Sets the rail acceleration for the given position to `amount` and punches
  31. carts which are at the given position.
  32. * `pos`: `vector`, rail position
  33. * `amount`: `number`, negative to brake, positive to boost
  34. * `boost_cart:get_rail_direction(pos, dir, ctrl, old_switch, railtype)`
  35. -> `vector, SwitchIgnore`
  36. * Returns the direction to where the next rail is, and which player control that
  37. should be ignored in the next call.
  38. * `pos`: `vector`, position of the cart
  39. * `dir`: `vector`, movement direction of the cart (see `velocity_to_dir()`)
  40. * `ctrl`: Player controls table or `nil` (no player)
  41. * `old_switch`: `SwitchIgnore`
  42. * `railtype`: (optional) `number`, gets passed indirectly to `is_rail()`
  43. Rail helper functions
  44. ---------------------
  45. * `boost_cart:get_rail_groups(groups)` -> `table`
  46. * Returns a group table with preset values for a common rail node
  47. * `groups`: (optional) `table`, additional groups append (or overwrite)
  48. * Hint: To register an incompatible rail type, set the group
  49. `connect_to_raillike` to the value returned by
  50. `minetest.raillike_group(new_rail_type)`
  51. * `boost_cart:is_rail(pos, [railtype])` -> `boolean`
  52. * Returns whether the node at `pos` is a rail. When `railtype` is specified,
  53. `true` is only returned when the node is in the same rail group.
  54. * `pos`: `vector` of the node to check
  55. * `railtype`: (optional) `number`, rail group number
  56. * `boost_cart:register_rail(name, def)`
  57. * Registers a new rail with preset node definition defaults as fallback
  58. * `name`: `string`, node name of the new rail
  59. * `def`: Node definition table, containing at least the following keys:
  60. * `description`
  61. * `groups`
  62. * `tiles`