game_api.txt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. Voxelgarden API
  2. ======================
  3. GitHub Repo: https://github.com/CasimirKaPazi/Voxelgarden
  4. Introduction
  5. ------------
  6. The Voxelgarden subgame offers multiple new possibilities in addition to Minetest's built-in API, allowing you to
  7. add new plants to farming mod, buckets for new liquids, new stairs and custom panes.
  8. For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt
  9. Please note:
  10. [XYZ] refers to a section the Minetest API
  11. [#ABC] refers to a section in this document
  12. ^ Explanation for line above
  13. Bucket API
  14. ----------
  15. The bucket API allows registering new types of buckets for non-default liquids.
  16. bucket.register_liquid(
  17. "default:lava_source", -- Source node name
  18. "default:lava_flowing", -- Flowing node name
  19. "bucket:bucket_lava", -- Name to be used for bucket
  20. "bucket_lava.png", -- Bucket texture (for wielditem and inventory_image)
  21. "Lava Bucket" -- Bucket description
  22. )
  23. Doors API
  24. ---------
  25. The doors mod allows modders to register custom doors.
  26. doors.register_door(name, def)
  27. ^ name: "Door name"
  28. ^ def: See [#Door definition]
  29. #Door definition
  30. ----------------
  31. {
  32. description = "Door description",
  33. inventory_image = "mod_door_inv.png",
  34. groups = {group = 1},
  35. tiles_bottom: [Tile definition],
  36. ^ the tiles of the door {front, side}
  37. node_box = regular nodebox, see [Node boxes], OPTIONAL,
  38. selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
  39. selection_box_top = regular nodebox, see [Node boxes], OPTIONAL,
  40. only_placer_can_open = true/false,
  41. ^ If true, only placer can open the door (locked for others)
  42. }
  43. Farming API
  44. -----------
  45. The farming API allows you to easily register plants and hoes.
  46. farming.register_stages(max_stages, name, description)
  47. -> Register growing stages of plants from 1 to max_stages.
  48. -> Returns list of registered nodes.
  49. -> e.g. local stages = farming.register_stages(4, "farming:wheat")
  50. -> use minetest.item_override to change definition afterwards.
  51. farming.register_growing(max_stage, stages, interval, chance, lightlevel)
  52. -> Registers an ABM to turn each plant stage into the next one.
  53. -> stages is a table that can be obtained with farming.register_stages
  54. Stairsplus API
  55. ----------
  56. The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
  57. delivered with minetest_game, to keep them compatible with other mods.
  58. stairsplus.register_stair(modname, subname, recipeitem, groups, images, desc_stair, drop, sounds, sunlight)
  59. -> Registers a stair. Same for corner, slap, wall, panel, micro
  60. -> modname: Name of your mod.
  61. -> subname: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
  62. -> recipeitem: Item used in the craft recipe, e.g. "default:cobble"
  63. -> groups: see [Known damage and digging time defining groups]
  64. Please include "not_in_creative_inventory=1, not_in_craft_guide=1"
  65. -> images: see [Tile definition]
  66. -> desc_stair: used for the description field in the stair's definition
  67. -> drop: Drops other then then node itself.
  68. -> sounds: see [#Default sounds]
  69. -> sunlight: When true, sunlight does propagate.
  70. stairsplus.register_stair_and_slab_and_panel_and_micro(modname, subname, recipeitem, groups, images, desc_stair, desc_corner, desc_slab, desc_wall, desc_panel, desc_micro, drop, sounds, sunlight)
  71. -> A wrapper for all of the above.
  72. Default sounds
  73. --------------
  74. Sounds inside the default table can be used within the sounds field of node definitions.
  75. default.node_sound_defaults()
  76. default.node_sound_stone_defaults()
  77. default.node_sound_dirt_defaults()
  78. default.node_sound_sand_defaults()
  79. default.node_sound_wood_defaults()
  80. default.node_sound_leaves_defaults()
  81. default.node_sound_glass_defaults()
  82. Player API
  83. ----------
  84. The player API can register player models and update the player's appearence
  85. default.player_register_model(name, def)
  86. ^ Register a new model to be used by players.
  87. -> name: model filename such as "character.x", "foo.b3d", etc.
  88. -> def: See [#Model definition]
  89. default.registered_player_models[name]
  90. ^ Get a model's definition
  91. -> see [#Model definition]
  92. default.player_set_model(player, model_name)
  93. ^ Change a player's model
  94. -> player: PlayerRef
  95. -> model_name: model registered with player_register_model()
  96. default.player_set_animation(player, anim_name [, speed])
  97. ^ Applies an animation to a player
  98. -> anim_name: name of the animation.
  99. -> speed: frames per second. If nil, default from the model is used
  100. default.player_set_textures(player, textures)
  101. ^ Sets player textures
  102. -> player: PlayerRef
  103. -> textures: array of textures
  104. ^ If <textures> is nil, the default textures from the model def are used
  105. default.player_get_animation(player)
  106. ^ Returns a table containing fields "model", "textures" and "animation".
  107. ^ Any of the fields of the returned table may be nil.
  108. -> player: PlayerRef
  109. Model Definition
  110. ----------------
  111. {
  112. animation_speed = 30, -- Default animation speed, in FPS.
  113. textures = {"character.png", }, -- Default array of textures.
  114. visual_size = {x=1, y=1,}, -- Used to scale the model.
  115. animations = {
  116. -- <anim_name> = { x=<start_frame>, y=<end_frame>, },
  117. foo = { x= 0, y=19, },
  118. bar = { x=20, y=39, },
  119. -- ...
  120. },
  121. }
  122. Leafdecay
  123. ---------
  124. To enable leaf decay for a node, add it to the "leafdecay" group.
  125. The rating of the group determines how far from a node in the group "tree"
  126. the node can be without decaying.
  127. Add trunk = "mod:treename" in the node definition and it will search for the defined node
  128. instead of group:tree.
  129. If param2 of the node is ~= 0, the node will always be preserved. Thus, if
  130. the player places a node of that kind, you will want to set param2=1 or so.
  131. If the node is in the leafdecay_drop group then it will always be dropped as an item.
  132. Dyes
  133. ----
  134. To make recipes that will work with any dye ever made by anybody, define
  135. them based on groups. You can select any group of groups, based on your need for
  136. amount of colors.
  137. #Color groups
  138. -------------
  139. Base color groups:
  140. - basecolor_white
  141. - basecolor_grey
  142. - basecolor_black
  143. - basecolor_red
  144. - basecolor_yellow
  145. - basecolor_green
  146. - basecolor_cyan
  147. - basecolor_blue
  148. - basecolor_magenta
  149. Extended color groups (* = equal to a base color):
  150. * excolor_white
  151. - excolor_lightgrey
  152. * excolor_grey
  153. - excolor_darkgrey
  154. * excolor_black
  155. * excolor_red
  156. - excolor_orange
  157. * excolor_yellow
  158. - excolor_lime
  159. * excolor_green
  160. - excolor_aqua
  161. * excolor_cyan
  162. - excolor_sky_blue
  163. * excolor_blue
  164. - excolor_violet
  165. * excolor_magenta
  166. - excolor_red_violet
  167. The whole unifieddyes palette as groups:
  168. - unicolor_<excolor>
  169. For the following, no white/grey/black is allowed:
  170. - unicolor_medium_<excolor>
  171. - unicolor_dark_<excolor>
  172. - unicolor_light_<excolor>
  173. - unicolor_<excolor>_s50
  174. - unicolor_medium_<excolor>_s50
  175. - unicolor_dark_<excolor>_s50
  176. Example of one shapeless recipe using a color group:
  177. minetest.register_craft({
  178. type = "shapeless",
  179. output = '<mod>:item_yellow',
  180. recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
  181. })
  182. #Color lists
  183. ------------
  184. dye.basecolors
  185. ^ Array containing the names of available base colors
  186. dye.excolors
  187. ^ Array containing the names of the available extended colors