mirror of
https://github.com/minetest-mods/item_drop.git
synced 2025-06-30 13:50:34 +02:00
Compare commits
91 Commits
master
...
nalc-1.2.0
Author | SHA1 | Date | |
---|---|---|---|
29983259ee | |||
c6a80bd4fa | |||
fadfbf7e05 | |||
5611b4d639 | |||
26d0532cbd | |||
becdfd113a | |||
934ebff45a | |||
5069afa834 | |||
70b3386322 | |||
1e9e73e978 | |||
f7d62113ff | |||
3a9a506011 | |||
427117d786 | |||
c1637b1975 | |||
e10486d2aa | |||
532a3cb0d0 | |||
56d2eeda5c | |||
c52ff0ea55 | |||
8e89c148be | |||
726b5f4872 | |||
8e1878d101 | |||
f6b8bcd7a7 | |||
6b7ed8e7ca | |||
2730deca16 | |||
fc89b2d2b4 | |||
f5187108f1 | |||
902daba7cf | |||
3c9c0e34e3 | |||
eaa44e2a36 | |||
a69bdd2275 | |||
1b0bc8461c | |||
b42a64cfa4 | |||
d51b468428 | |||
293fd77614 | |||
3e6a731cab | |||
760acbc593 | |||
d282d1ab0c | |||
8e6b386fe3 | |||
31bdc51b42 | |||
c688119069 | |||
376439b214 | |||
49b7bb19ef | |||
4c66b76937 | |||
29df36b2af | |||
2aff58ee02 | |||
92d68aa48a | |||
7afe3723e4 | |||
69f0c08561 | |||
6f8a37bd10 | |||
19ad20305f | |||
e7b8d02922 | |||
0f903cd0b0 | |||
bf9931d6db | |||
739a62a6c6 | |||
271a577881 | |||
729397b6c9 | |||
4912d3c828 | |||
057966141a | |||
78ef2a50f6 | |||
c4365cd4de | |||
bf0bb807fb | |||
22763d3b06 | |||
169d83840f | |||
da2fb1df20 | |||
3bc3a4bd25 | |||
55e89d3710 | |||
4b5e362395 | |||
bc5ef09e21 | |||
bab3c733fa | |||
69a68cb247 | |||
b56c1792de | |||
544381bbfe | |||
9f54694931 | |||
fb2c076b92 | |||
46959e79d2 | |||
e84433d41c | |||
884824989f | |||
962d0a3889 | |||
81d32527f3 | |||
8a14503372 | |||
a7b7c71d50 | |||
5a6f79a5d2 | |||
363b56fc03 | |||
189fea5eff | |||
1f9ceb3eb3 | |||
6befa68ef8 | |||
d336a226cd | |||
16210c79f7 | |||
2c60ac7ab0 | |||
a666252f1c | |||
d9581ec795 |
64
init.lua
64
init.lua
@ -93,34 +93,13 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
|
|||||||
flowingliquid = true,
|
flowingliquid = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get an image string from a tile definition
|
|
||||||
local function tile_to_image(tile, fallback_image)
|
|
||||||
if not tile then
|
|
||||||
return fallback_image
|
|
||||||
end
|
|
||||||
local tile_type = type(tile)
|
|
||||||
if tile_type == "string" then
|
|
||||||
return tile
|
|
||||||
end
|
|
||||||
assert(tile_type == "table", "Tile definition is not a string or table")
|
|
||||||
local image = tile.name or tile.image
|
|
||||||
assert(image, "Tile definition has no image file specified")
|
|
||||||
if tile.color then
|
|
||||||
local colorstr = minetest.colorspec_to_colorstring(tile.color)
|
|
||||||
if colorstr then
|
|
||||||
return image .. "^[multiply:" .. colorstr
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return image
|
|
||||||
end
|
|
||||||
|
|
||||||
-- adds the item to the inventory and removes the object
|
-- adds the item to the inventory and removes the object
|
||||||
local function collect_item(ent, pos, player)
|
local function collect_item(ent, pos, player)
|
||||||
item_drop.before_collect(ent, pos, player)
|
item_drop.before_collect(ent, pos, player)
|
||||||
minetest.sound_play("item_drop_pickup", {
|
minetest.sound_play("item_drop_pickup", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = pickup_gain,
|
gain = pickup_gain,
|
||||||
}, true)
|
})
|
||||||
if pickup_particle then
|
if pickup_particle then
|
||||||
local item = minetest.registered_nodes[
|
local item = minetest.registered_nodes[
|
||||||
ent.itemstring:gsub("(.*)%s.*$", "%1")]
|
ent.itemstring:gsub("(.*)%s.*$", "%1")]
|
||||||
@ -128,11 +107,20 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
|
|||||||
if item and item.tiles and item.tiles[1] then
|
if item and item.tiles and item.tiles[1] then
|
||||||
if inventorycube_drawtypes[item.drawtype] then
|
if inventorycube_drawtypes[item.drawtype] then
|
||||||
local tiles = item.tiles
|
local tiles = item.tiles
|
||||||
-- color in the tile definition is handled by tile_to_image.
|
|
||||||
-- color in the node definition is not yet supported here.
|
local top = tiles[1]
|
||||||
local top = tile_to_image(tiles[1])
|
if type(top) == "table" then
|
||||||
local left = tile_to_image(tiles[3], top)
|
top = top.name
|
||||||
local right = tile_to_image(tiles[5], left)
|
end
|
||||||
|
local left = tiles[3] or top
|
||||||
|
if type(left) == "table" then
|
||||||
|
left = left.name
|
||||||
|
end
|
||||||
|
local right = tiles[5] or left
|
||||||
|
if type(right) == "table" then
|
||||||
|
right = right.name
|
||||||
|
end
|
||||||
|
|
||||||
image = minetest.inventorycube(top, left, right)
|
image = minetest.inventorycube(top, left, right)
|
||||||
else
|
else
|
||||||
image = item.inventory_image or item.tiles[1]
|
image = item.inventory_image or item.tiles[1]
|
||||||
@ -390,7 +378,7 @@ and not minetest.settings:get_bool("creative_mode") then
|
|||||||
|
|
||||||
local old_handle_node_drops = minetest.handle_node_drops
|
local old_handle_node_drops = minetest.handle_node_drops
|
||||||
function minetest.handle_node_drops(pos, drops, player)
|
function minetest.handle_node_drops(pos, drops, player)
|
||||||
if not player or player.is_fake_player then
|
if player.is_fake_player then
|
||||||
-- Node Breaker or similar machines should receive items in the
|
-- Node Breaker or similar machines should receive items in the
|
||||||
-- inventory
|
-- inventory
|
||||||
return old_handle_node_drops(pos, drops, player)
|
return old_handle_node_drops(pos, drops, player)
|
||||||
@ -424,13 +412,29 @@ and not minetest.settings:get_bool("creative_mode") then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
local function pickup_step()
|
||||||
|
local got_item
|
||||||
|
local players = minetest.get_connected_players()
|
||||||
|
for i = 1,#players do
|
||||||
|
got_item = got_item or pickupfunc(players[i])
|
||||||
|
end
|
||||||
|
-- lower step if takeable item(s) were found
|
||||||
|
local time
|
||||||
|
if got_item then
|
||||||
|
time = 0.02
|
||||||
|
else
|
||||||
|
time = 0.2
|
||||||
|
end
|
||||||
|
minetest.after(time, pickup_step)
|
||||||
|
end
|
||||||
|
minetest.after(3.0, pickup_step)
|
||||||
|
end
|
||||||
|
|
||||||
local time = (minetest.get_us_time() - load_time_start) / 1000000
|
local time = (minetest.get_us_time() - load_time_start) / 1000000
|
||||||
local msg = "[item_drop] loaded after ca. " .. time .. " seconds."
|
local msg = "[item_drop] loaded after ca. " .. time .. " seconds."
|
||||||
if time > 0.01 then
|
if time > 0.01 then
|
||||||
print(msg)
|
print(msg)
|
||||||
else
|
else
|
||||||
minetest.log("info", msg)
|
minetest.log("action", msg)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user