Added support for new auto-pickup fields.

master
Robert Zenz 2016-01-10 13:28:28 +01:00
parent 601ff18171
commit 30441c5cb9
3 changed files with 56 additions and 1 deletions

8
README
View File

@ -27,6 +27,14 @@ The system can be configured by adding settings to the `minetest.conf`:
# If the system should be activated, defaults to true.
deathinventorydrop_activate = true
# If the field should be set to disable automatically pickup provided
# by the auto-pickup mod, defaults to false.
autodrops_autopickup_disable = false
# The value for the timeout before the auto-pickup mod is allowed to pick
# it up, defaults to 2.
autodrops_autopickup_timeout = 2
# The name of the lists to drop, a comma separated list, defaults to "main".
deathinventorydrop_inventories = main

View File

@ -84,6 +84,14 @@
<td class="summary">If the system is active/has been activated.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#autopickup_disable">autopickup_disable</a></td>
<td class="summary">If the field should be set to disable auto-pickup.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#autopickup_timeout">autopickup_timeout</a></td>
<td class="summary">The timeout value to set for auto-pickup.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#inventories">inventories</a></td>
<td class="summary">The list of inventories/list names to drop, they need to be in players
inventory, defaults to "main".</td>
@ -251,6 +259,34 @@
</dd>
<dt>
<a name = "autopickup_disable"></a>
<strong>autopickup_disable</strong>
</dt>
<dd>
If the field should be set to disable auto-pickup.
</dd>
<dt>
<a name = "autopickup_timeout"></a>
<strong>autopickup_timeout</strong>
</dt>
<dd>
The timeout value to set for auto-pickup.
</dd>
<dt>
<a name = "inventories"></a>

View File

@ -34,6 +34,12 @@ deathinventorydrop = {
--- If the system is active/has been activated.
active = false,
--- If the field should be set to disable auto-pickup.
autopickup_disable = settings.get_bool("deathinventorydrop_autopickup_disable", false),
--- The timeout value to set for auto-pickup.
autopickup_timeout = settings.get_number("deathinventorydrop_autopickup_timeout", 2),
--- The list of inventories/list names to drop, they need to be in players
-- inventory, defaults to "main".
inventories = settings.get_list("deathinventorydrop_inventories", "main"),
@ -116,13 +122,18 @@ function deathinventorydrop.drop_inventory(player, inventory, list_name)
total_item_count,
deathinventorydrop.percentage_destroyed_items)
itemutil.blop(
local spawned_items = itemutil.blop(
player,
items,
deathinventorydrop.velocity.x,
deathinventorydrop.velocity.y,
deathinventorydrop.velocity.z,
deathinventorydrop.split)
spawned_items:foreach(function(spawned_item, index)
spawned_item:get_luaentity().autopickup_disable = deathinventorydrop.autopickup_disable
spawned_item:get_luaentity().autopickup_timeout = deathinventorydrop.autopickup_timeout
end)
inventory:set_list(list_name, retained_items)
end