Added option for adding the dropped_by name.
parent
713c871b3d
commit
8f9eb4f2da
5
README
5
README
|
@ -26,6 +26,11 @@ The system can be configured by adding settings to the `minetest.conf`:
|
|||
# If the system should be activated, defaults to true.
|
||||
autodrops_activate = true
|
||||
|
||||
# If the droppedby field should be set on the new items, whih if
|
||||
# auto-pickup is used, prevents the items from being picked up instantious,
|
||||
# defaults to true.
|
||||
autodrops_set_dropped_by = true
|
||||
|
||||
# If the stacks that are split in some way, defaults to single.
|
||||
# Possible values are:
|
||||
# random: The dropped stacks are split randomly.
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<td class="summary">Activates the autodrops system without checking the configuration.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#drop">drop (position, stacks)</a></td>
|
||||
<td class="name" nowrap><a href="#drop">drop (position, player, stacks)</a></td>
|
||||
<td class="summary">Drops the given ItemStacks at the given position, based on the settings.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -81,6 +81,10 @@
|
|||
<td class="summary">If the system is currently active/has been activated.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#set_dropped_by">set_dropped_by</a></td>
|
||||
<td class="summary">If the dropped_by field should be set to the player name.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#split">split</a></td>
|
||||
<td class="summary">The split method that is used.</td>
|
||||
</tr>
|
||||
|
@ -128,7 +132,7 @@
|
|||
</dd>
|
||||
<dt>
|
||||
<a name = "drop"></a>
|
||||
<strong>drop (position, stacks)</strong>
|
||||
<strong>drop (position, player, stacks)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Drops the given ItemStacks at the given position, based on the settings.
|
||||
|
@ -139,6 +143,9 @@
|
|||
<li><span class="parameter">position</span>
|
||||
The position at which to drop the items.
|
||||
</li>
|
||||
<li><span class="parameter">player</span>
|
||||
The Player object that caused the dropping.
|
||||
</li>
|
||||
<li><span class="parameter">stacks</span>
|
||||
The List of ItemStacks to drop.
|
||||
</li>
|
||||
|
@ -213,6 +220,20 @@
|
|||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "set_dropped_by"></a>
|
||||
<strong>set_dropped_by</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
If the dropped_by field should be set to the player name.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "split"></a>
|
||||
|
|
|
@ -35,6 +35,9 @@ autodrops = {
|
|||
--- If the system is currently active/has been activated.
|
||||
active = false,
|
||||
|
||||
--- If the dropped_by field should be set to the player name.
|
||||
set_dropped_by = settings.get_bool("autodrops_set_dropped_by", true),
|
||||
|
||||
--- The split method that is used. Possible values are "stack", "random"
|
||||
-- and "single", defaults to "single". "stack" means that the full stack
|
||||
-- as provided is dropped, "random" splits the provided stack randomly and
|
||||
|
@ -67,15 +70,22 @@ end
|
|||
--- Drops the given ItemStacks at the given position, based on the settings.
|
||||
--
|
||||
-- @param position The position at which to drop the items.
|
||||
-- @param player The Player object that caused the dropping.
|
||||
-- @param stacks The List of ItemStacks to drop.
|
||||
function autodrops.drop(position, stacks)
|
||||
itemutil.blop(
|
||||
function autodrops.drop(position, player, stacks)
|
||||
local items = itemutil.blop(
|
||||
position,
|
||||
stacks:to_table(),
|
||||
autodrops.velocity.x,
|
||||
autodrops.velocity.y,
|
||||
autodrops.velocity.z,
|
||||
autodrops.split)
|
||||
|
||||
if autodrops.set_dropped_by then
|
||||
items:foreach(function(item, index)
|
||||
item:get_luaentity().dropped_by = player:get_player_name()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
--- The handler which is registered for handling the node drops.
|
||||
|
@ -86,7 +96,7 @@ end
|
|||
-- @param handled If the event has already been handled or not.
|
||||
-- @return true, because the event has been handled by this function.
|
||||
function autodrops.node_drops_handler(position, drops, player, handled)
|
||||
autodrops.drop(position, drops)
|
||||
autodrops.drop(position, player, drops)
|
||||
|
||||
return true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue