X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=1efa5678e0956153d18e00f429119583d6655148;hb=edc7df54801ab3bf30f96ac5aad6ce11a102f6b9;hp=882c9c54c89a66c03a2dda7348610be35f0de49c;hpb=c660218e43bfbc9740001d6707618d5eba51b664;p=dragonfireclient.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 882c9c54c..1efa5678e 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1673,10 +1673,16 @@ these formats. ### Serialized This is called "stackstring" or "itemstring". It is a simple string with -1-3 components: the full item identifier, an optional amount and an optional -wear value. Syntax: +1-4 components: - [[ ]] +1. Full item identifier ("item name") +2. Optional amount +3. Optional wear value +4. Optional item metadata + +Syntax: + + [[ [ ]]] Examples: @@ -1684,6 +1690,26 @@ Examples: * `"default:dirt 5"`: 5 dirt * `"default:pick_stone"`: a new stone pickaxe * `"default:pick_wood 1 21323"`: a wooden pickaxe, ca. 1/3 worn out +* `[[default:pick_wood 1 21323 "\u0001description\u0002My worn out pick\u0003"]]`: + * a wooden pickaxe from the `default` mod, + * amount must be 1 (pickaxe is a tool), ca. 1/3 worn out (it's a tool), + * with the `description` field set to `"My worn out pick"` in its metadata +* `[[default:dirt 5 0 "\u0001description\u0002Special dirt\u0003"]]`: + * analogeous to the above example + * note how the wear is set to `0` as dirt is not a tool + +You should ideally use the `ItemStack` format to build complex item strings +(especially if they use item metadata) +without relying on the serialization format. Example: + + local stack = ItemStack("default:pick_wood") + stack:set_wear(21323) + stack:get_meta():set_string("description", "My worn out pick") + local itemstring = stack:to_string() + +Additionally the methods `minetest.itemstring_with_palette(item, palette_index)` +and `minetest.itemstring_with_color(item, colorstring)` may be used to create +item strings encoding color information in their metadata. ### Table format @@ -1779,7 +1805,6 @@ An example: Make meat soup from any meat, any water and any bowl: {"group:water"}, {"group:bowl"}, }, - -- preserve = {"group:bowl"}, -- Not implemented yet (TODO) } Another example: Make red wool from white wool and red dye: @@ -3591,6 +3616,12 @@ Helper functions * `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a position. * returns the exact position on the surface of a pointed node +* `minetest.get_tool_wear_after_use(uses [, initial_wear])` + * Simulates a tool being used once and returns the added wear, + such that, if only this function is used to calculate wear, + the tool will break exactly after `uses` times of uses + * `uses`: Number of times the tool can be used + * `initial_wear`: The initial wear the tool starts with (default: 0) * `minetest.get_dig_params(groups, tool_capabilities [, wear])`: Simulates an item that digs a node. Returns a table with the following fields: @@ -6526,7 +6557,13 @@ an itemstring, a table or `nil`. or those of the hand if none are defined for this item type * `add_wear(amount)` * Increases wear by `amount` if the item is a tool, otherwise does nothing + * Valid `amount` range is [0,65536] * `amount`: number, integer +* `add_wear_by_uses(max_uses)` + * Increases wear in such a way that, if only this function is called, + the item breaks after `max_uses` times + * Valid `max_uses` range is [0,65536] + * Does nothing if item is not a tool or if `max_uses` is 0 * `add_item(item)`: returns leftover `ItemStack` * Put some item or stack onto this stack * `item_fits(item)`: returns `true` if item or stack can be fully added to @@ -7099,6 +7136,8 @@ object you are working with still exists. * `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness) * `get_lighting()`: returns the current state of lighting for the player. * Result is a table with the same fields as `light_definition` in `set_lighting`. +* `respawn()`: Respawns the player using the same mechanism as the death screen, + including calling on_respawnplayer callbacks. `PcgRandom` -----------