Used new itemutil functions.
parent
42b01c48c4
commit
69da7c5dda
112
doc/index.html
112
doc/index.html
|
@ -52,29 +52,11 @@
|
|||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#blop">blop (position, item)</a></td>
|
||||
<td class="summary">Blops the given item into existence.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#drop">drop (position, stacks)</a></td>
|
||||
<td class="summary">Drops the given ItemStacks at the given position, based on the settings.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#drop_random">drop_random (position, stack)</a></td>
|
||||
<td class="summary">Drops the given stack from the given position by splitting it into random
|
||||
amounts.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#drop_single">drop_single (position, stack)</a></td>
|
||||
<td class="summary">Drops the given stack from the given position by splitting it into single
|
||||
items.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#drop_stack">drop_stack (position, stack)</a></td>
|
||||
<td class="summary">Drops the given stack from the given position.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#node_drops_handler">node_drops_handler (position, drops, player, handled)</a></td>
|
||||
<td class="summary">The handler which is registered for handling the node drops.</td>
|
||||
</tr>
|
||||
|
@ -97,29 +79,6 @@
|
|||
|
||||
<h2><a name="Functions"></a>Functions</h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "blop"></a>
|
||||
<strong>blop (position, item)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Blops the given item into existence.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">position</span>
|
||||
The position at which the item should be spawned.
|
||||
</li>
|
||||
<li><span class="parameter">item</span>
|
||||
The item to spawn.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "drop"></a>
|
||||
<strong>drop (position, stacks)</strong>
|
||||
|
@ -142,77 +101,6 @@
|
|||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "drop_random"></a>
|
||||
<strong>drop_random (position, stack)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Drops the given stack from the given position by splitting it into random
|
||||
amounts.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">position</span>
|
||||
The position at which the items should spawn.
|
||||
</li>
|
||||
<li><span class="parameter">stack</span>
|
||||
The ItemStack to drop.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "drop_single"></a>
|
||||
<strong>drop_single (position, stack)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Drops the given stack from the given position by splitting it into single
|
||||
items.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">position</span>
|
||||
The position at which the items should spawn.
|
||||
</li>
|
||||
<li><span class="parameter">stack</span>
|
||||
The ItemStack to drop.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "drop_stack"></a>
|
||||
<strong>drop_stack (position, stack)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Drops the given stack from the given position.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">position</span>
|
||||
The position at which the items should spawn.
|
||||
</li>
|
||||
<li><span class="parameter">stack</span>
|
||||
The ItemStack to drop.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "node_drops_handler"></a>
|
||||
|
|
|
@ -48,73 +48,18 @@ function autodrops.activate()
|
|||
end
|
||||
end
|
||||
|
||||
--- Blops the given item into existence.
|
||||
--
|
||||
-- @param position The position at which the item should be spawned.
|
||||
-- @param item The item to spawn.
|
||||
function autodrops.blop(position, item)
|
||||
itemutil.blop(
|
||||
position,
|
||||
item,
|
||||
autodrops.velocity.x,
|
||||
autodrops.velocity.y,
|
||||
autodrops.velocity.z)
|
||||
end
|
||||
|
||||
--- Drops the given ItemStacks at the given position, based on the settings.
|
||||
--
|
||||
-- @param position The position at which to drop the items.
|
||||
-- @param stacks The array of ItemStacks to drop.
|
||||
function autodrops.drop(position, stacks)
|
||||
for index, stack in ipairs(stacks) do
|
||||
if autodrops.split == "random" then
|
||||
autodrops.drop_random(position, stack)
|
||||
elseif autodrops.split == "single" then
|
||||
autodrops.drop_single(position, stack)
|
||||
elseif autodrops.split == "stack" then
|
||||
autodrops.drop_stack(position, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Drops the given stack from the given position by splitting it into random
|
||||
-- amounts.
|
||||
--
|
||||
-- @param position The position at which the items should spawn.
|
||||
-- @param stack The ItemStack to drop.
|
||||
function autodrops.drop_random(position, stack)
|
||||
local name = stack:get_name()
|
||||
local remaining = stack:get_count()
|
||||
|
||||
while remaining > 0 do
|
||||
local count = random.next_int(1, remaining + 1)
|
||||
local item_string = name .. " " .. tostring(count)
|
||||
|
||||
autodrops.blop(position, item_string)
|
||||
|
||||
remaining = remaining - count;
|
||||
end
|
||||
end
|
||||
|
||||
--- Drops the given stack from the given position by splitting it into single
|
||||
-- items.
|
||||
--
|
||||
-- @param position The position at which the items should spawn.
|
||||
-- @param stack The ItemStack to drop.
|
||||
function autodrops.drop_single(position, stack)
|
||||
local name = stack:get_name()
|
||||
|
||||
for counter = 1, stack:get_count(), 1 do
|
||||
autodrops.blop(position, name)
|
||||
end
|
||||
end
|
||||
|
||||
--- Drops the given stack from the given position.
|
||||
--
|
||||
-- @param position The position at which the items should spawn.
|
||||
-- @param stack The ItemStack to drop.
|
||||
function autodrops.drop_stack(position, stack)
|
||||
autodrops.blop(position, stack:to_string())
|
||||
itemutil.blop(
|
||||
position,
|
||||
stacks:to_table(),
|
||||
autodrops.velocity.x,
|
||||
autodrops.velocity.y,
|
||||
autodrops.velocity.z,
|
||||
autodrops.split)
|
||||
end
|
||||
|
||||
--- The handler which is registered for handling the node drops.
|
||||
|
@ -126,6 +71,7 @@ end
|
|||
-- @return true, because the event has been handled by this function.
|
||||
function autodrops.node_drops_handler(position, drops, player, handled)
|
||||
autodrops.drop(position, drops)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue