{x=0, y=1, z=0}})
--indexed into by a table of correlating facedirs
- [({[0]=1, 2, 3, 4,
+ [({[0]=1, 2, 3, 4,
5, 2, 6, 4,
6, 2, 5, 4,
1, 5, 3, 6,
core.log("action", placer:get_player_name() .. " places node "
.. def.name .. " at " .. core.pos_to_string(place_to))
-
+
local oldnode = core.get_node(place_to)
local newnode = {name = def.name, param1 = 0, param2 = param2}
return itemstack
end
-function core.item_eat(hp_change, replace_with_item)
- return function(itemstack, user, pointed_thing) -- closure
- for _, callback in pairs(core.registered_on_item_eats) do
- local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing)
- if result then
- return result
- end
+function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
+ for _, callback in pairs(core.registered_on_item_eats) do
+ local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing)
+ if result then
+ return result
end
- if itemstack:take_item() ~= nil then
- user:set_hp(user:get_hp() + hp_change)
- itemstack:add_item(replace_with_item) -- note: replace_with_item is optional
+ end
+ if itemstack:take_item() ~= nil then
+ user:set_hp(user:get_hp() + hp_change)
+
+ if replace_with_item then
+ if itemstack:is_empty() then
+ itemstack:add_item(replace_with_item)
+ else
+ local inv = user:get_inventory()
+ if inv:room_for_item("main", {name=replace_with_item}) then
+ inv:add_item("main", replace_with_item)
+ else
+ local pos = user:getpos()
+ pos.y = math.floor(pos.y + 0.5)
+ core.add_item(pos, replace_with_item)
+ end
+ end
end
- return itemstack
+ end
+ return itemstack
+end
+
+function core.item_eat(hp_change, replace_with_item)
+ return function(itemstack, user, pointed_thing) -- closure
+ return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
end
end
local wielded = digger:get_wielded_item()
local drops = core.get_node_drops(node.name, wielded:get_name())
-
+
local wdef = wielded:get_definition()
local tp = wielded:get_tool_capabilities()
local dp = core.get_dig_params(def.groups, tp)
end
end
digger:set_wielded_item(wielded)
-
+
-- Handle drops
core.handle_node_drops(pos, drops, digger)
-- Remove node and update
core.remove_node(pos)
-
+
-- Run callback
if def.after_dig_node then
-- Copy pos and node because callback can modify them
on_dig = redef_wrapper(core, 'node_dig'), -- core.node_dig
on_receive_fields = nil,
-
+
on_metadata_inventory_move = core.node_metadata_inventory_move_allow_all,
on_metadata_inventory_offer = core.node_metadata_inventory_offer_allow_all,
on_metadata_inventory_take = core.node_metadata_inventory_take_allow_all,
Meshes
------
If drawtype `mesh` is used, tiles should hold model materials textures.
-Only static meshes are implemented.
+Only static meshes are implemented.
For supported model formats see Irrlicht engine documentation.
a non-zero `scale` parameter in `noise_params`.
**IMPORTANT**: The noise is not transformed by `offset` or `scale` when comparing against the noise
-threshold, but scale is used to determine relative height.
+threshold, but scale is used to determine relative height.
The height of the blob is randomly scattered, with a maximum height of `clust_size`.
`clust_scarcity` and `clust_num_ores` are ignored.
This is essentially an improved version of the so-called "stratus" ore seen in some unofficial mods.
### `blob`
-Creates a deformed sphere of ore according to 3d perlin noise described by
+Creates a deformed sphere of ore according to 3d perlin noise described by
`noise_params`. The maximum size of the blob is `clust_size`, and
`clust_scarcity` has the same meaning as with the `scatter` type.
### `vein
Client predicts damage based on damage groups. Because of this, it is able to
give an immediate response when an entity is damaged or dies; the response is
pre-defined somehow (e.g. by defining a sprite animation) (not implemented;
-TODO).
+TODO).
Currently a smoke puff will appear when an entity dies.
The group `immortal` completely disables normal damage.
* `minetest.create_detached_inventory(name, callbacks)`: returns an `InvRef`
* callbacks: See "Detached inventory callbacks"
* Creates a detached inventory. If it already exists, it is cleared.
+* `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`: returns left over ItemStack
+ * See `minetest.item_eat` and `minetest.register_on_item_eat`
### Formspec
* `minetest.show_formspec(playername, formname, formspec)`
* `minetest.item_drop(itemstack, dropper, pos)`
* Drop the item
* `minetest.item_eat(hp_change, replace_with_item)`
- * Eat the item. `replace_with_item` can be `nil`.
+ * Eat the item.
+ * `replace_with_item` is the itemstring which is added to the inventory.
+ If the player is eating a stack, then replace_with_item goes to a
+ different spot. Can be `nil`
+ * See `minetest.do_item_eat`
### Defaults for the `on_punch` and `on_dig` node definition callbacks
* `minetest.node_punch(pos, node, puncher, pointed_thing)`
---------------
### `NodeMetaRef`
-Node metadata: reference extra data and functionality stored in a node.
+Node metadata: reference extra data and functionality stored in a node.
Can be gotten via `minetest.get_meta(pos)`.
#### Methods
* See "Node Metadata"
### `NoteTimerRef`
-Node Timers: a high resolution persistent per-node timer.
+Node Timers: a high resolution persistent per-node timer.
Can be gotten via `minetest.get_node_timer(pos)`.
#### Methods
### `PerlinNoise`
A perlin noise generator.
It can be created via `PerlinNoise(seed, octaves, persistence, scale)`
-or `PerlinNoise(noiseparams)`.
+or `PerlinNoise(noiseparams)`.
Alternatively with `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
or `minetest.get_perlin(noiseparams)`.