]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - doc/lua_api.txt
Update Lua API documentation to include minetest.get_modnames()
[dragonfireclient.git] / doc / lua_api.txt
index 39267e34e242d3c99f291871b25e32f0e7a95583..d5797d17193a4936c632c8221b1d1a6ef89df566 100644 (file)
@@ -1,4 +1,4 @@
-Minetest Lua Modding API Reference 0.4.dev
+Minetest Lua Modding API Reference 0.4.0
 ==========================================
 More information at http://c55.me/minetest/
 
@@ -342,6 +342,11 @@ Position/vector:
 Currently the API does not provide any helper functions for addition,
 subtraction and whatever; you can define those that you need yourself.
 
+pointed_thing:
+  {type="nothing"}
+  {type="node", under=pos, above=pos}
+  {type="object", ref=ObjectRef}
+
 Items
 ------
 Node (register_node):
@@ -713,6 +718,8 @@ minetest namespace reference
 minetest.get_current_modname() -> string
 minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
 ^ Useful for loading additional .lua modules or static data from mod
+minetest.get_modnames() -> list of installed mods
+^ Return a list of installed mods, sorted alphabetically
 minetest.get_worldpath() -> eg. "/home/user/.minetest/world"
 ^ Useful for storing custom data
 minetest.is_singleplayer()
@@ -754,6 +761,10 @@ minetest.register_on_respawnplayer(func(ObjectRef))
 ^ Called when player is to be respawned
 ^ Called _before_ repositioning of player occurs
 ^ return true in func to disable regular player placement
+minetest.register_on_joinplayer(func(ObjectRef))
+^ Called when a player joins the game
+minetest.register_on_leaveplayer(func(ObjectRef))
+^ Called when a player leaves the game
 minetest.register_on_chat_message(func(name, message))
 
 Other registration functions:
@@ -820,6 +831,13 @@ minetest.get_craft_result(input) -> output, decremented_input
 ^ output.item = ItemStack, if unsuccessful: empty ItemStack
 ^ output.time = number, if unsuccessful: 0
 ^ decremented_input = like input
+minetest.get_craft_recipe(output) -> input
+^ output is a node or item type such as 'default:torch'
+^ input.method = 'normal' or 'cooking' or 'fuel'
+^ input.width = for example 3
+^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
+                              stack 5, stack 6, stack 7, stack 8, stack 9 }
+^ input.items = nil if no recipe found
 
 Defaults for the on_* item definition functions:
 (These return the leftover itemstack)
@@ -988,8 +1006,8 @@ LuaEntitySAO-only: (no-op for other objects)
 - settexturemod(mod)
 - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
 -           select_horiz_by_yawpitch=false)
-- ^ Select sprite from spritesheet with optional animation and DM-style
--   texture selection based on yaw relative to camera
+  ^ Select sprite from spritesheet with optional animation and DM-style
+    texture selection based on yaw relative to camera
 - get_entity_name() (DEPRECATED: Will be removed in a future version)
 - get_luaentity()
 Player-only: (no-op for other objects)
@@ -998,6 +1016,10 @@ Player-only: (no-op for other objects)
 - get_look_dir(): get camera direction as a unit vector
 - get_look_pitch(): pitch in radians
 - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
+- set_inventory_formspec(formspec)
+  ^ Redefine player's inventory form
+  ^ Should usually be called in on_joinplayer
+- get_inventory_formspec() -> formspec string
 
 InvRef: Reference to an inventory
 methods:
@@ -1167,8 +1189,10 @@ Item definition (register_node, register_craftitem, register_tool)
       actual result to client in a short moment.
 
     on_place = func(itemstack, placer, pointed_thing),
+    ^ Shall place item and return the leftover itemstack
     ^ default: minetest.item_place
     on_drop = func(itemstack, dropper, pos),
+    ^ Shall drop item and return the leftover itemstack
     ^ default: minetest.item_drop
     on_use = func(itemstack, user, pointed_thing),
     ^  default: nil