86 Commits

Author SHA1 Message Date
49fb82d4e9 Pitch one sound instead of using multiple ones 2019-07-09 01:16:48 +02:00
5611b4d639 Handle item drops more carefully
Do not ignore itemstrings which contain more than just the name; fixes missing clay drops
Support dropped items with toolwear and/or metadata
2019-07-01 15:46:06 +02:00
26d0532cbd Replace another deprecated function 2019-06-15 13:26:24 +02:00
becdfd113a Merge pull request #24 from Panquesito7/master
Replace deprecated functions with newer ones
2019-06-15 02:51:01 +02:00
934ebff45a Replace deprecated functions with newer ones 2019-06-14 17:47:21 -05:00
5069afa834 Enable pickup_keyinvert by default 2019-06-04 16:44:46 +02:00
70b3386322 Allow disabling the pickup key
To support lecagy setting names, I added two functions. They use the old setting only if the new one is not set.
(I'm not sure if enable_item_pickup_key is a valid legacy setting…)

I did not test this commit thoroughly.
2019-05-29 20:44:59 +02:00
1e9e73e978 Update description.txt 2019-05-27 09:21:59 +02:00
f7d62113ff Update mod.conf 2019-05-27 09:21:28 +02:00
3a9a506011 Fix crash due to a missing function
I accidentally wrote can_pickup instead of item_drop.can_pickup in a previous commit.
2019-05-26 14:13:54 +02:00
427117d786 Fix missing ore drops 2019-05-16 11:36:15 +02:00
532a3cb0d0 Update readme 2019-02-13 02:54:58 +01:00
56d2eeda5c Remove unneeded variable assertion, fix #20 2019-02-12 13:25:34 +01:00
c52ff0ea55 Add a screenshot 2019-02-12 05:37:14 +01:00
8e89c148be Add setting for disabling manual item pickups by mouse 2019-02-12 01:12:59 +01:00
726b5f4872 Ignore items where picking failed
tested with item_helpers
2019-02-05 19:29:40 +01:00
8e1878d101 Fix crash when trying to spawn an unknown item 2019-02-01 17:55:12 +01:00
f6b8bcd7a7 Add three functions which can be used by other mods 2019-01-05 13:54:12 +01:00
6b7ed8e7ca Fix a legacy setting support 2019-01-05 13:26:29 +01:00
fc89b2d2b4 Fix item magnet
There is no field named physical_state, so the item didn't lose the physical property, but it happily hopped towards me after I dropped it.
Disabling physical looked quite wrong, because the item flew through mountains. Instead, it gets zero acceleration now.
To avoid resetting the acceleration in the on_step function, it is overridden to disable acceleration and velocity changes during executing the original on_step.
Small code fix: Add underscores in set_velocity and set_acceleration
2018-10-03 17:58:58 +02:00
f5187108f1 Fix crash when a node texture is a table 2018-08-12 10:33:55 +02:00
902daba7cf Tidy up pickup_particle code 2018-08-12 10:33:49 +02:00
3c9c0e34e3 Merge branch 'master' of https://github.com/minetest-mods/item_drop 2018-06-23 18:39:36 +02:00
eaa44e2a36 Reflect particle feature setting in readme 2018-06-23 18:39:29 +02:00
a69bdd2275 Reflect particle feature setting in readme 2018-06-23 18:39:17 +02:00
1b0bc8461c Add WCILA code origin and license 2018-06-23 10:15:40 +02:00
b42a64cfa4 Merge pull request #14 from minetest-mods/dev
Bug fixes
2018-06-23 10:13:55 +02:00
d51b468428 Simplify inventorycube code (again) 2018-06-23 10:09:02 +02:00
293fd77614 Fix settings bug 2018-06-23 10:02:04 +02:00
3e6a731cab Fix crash on no drops (@HybridDog) 2018-06-23 10:01:40 +02:00
760acbc593 Fix settings bug 2018-06-18 20:54:59 +02:00
d282d1ab0c Merge pull request #13 from minetest-mods/pickerparticle
Pickup particle feature
2018-06-18 10:31:33 +02:00
8e6b386fe3 Complete pickup particle feature 2018-06-18 10:18:06 +02:00
31bdc51b42 Look for legacy setting names 2018-06-17 09:27:43 +02:00
c688119069 Merge pull request #11 from minetest-mods/rewrite
Rewrite
2018-06-17 07:41:43 +02:00
376439b214 Update readme 2018-06-17 07:35:06 +02:00
49b7bb19ef Rename the key press test function 2017-09-16 13:18:20 +02:00
4c66b76937 Disable item pickup age if the player has to hold a key for taking items 2017-09-16 12:59:28 +02:00
29df36b2af Typo 2017-09-15 18:40:11 +02:00
2aff58ee02 Update CONTRIBUTING.md 2017-09-15 16:25:53 +02:00
92d68aa48a Fix missing division for dropped item velocity calculation 2017-09-15 10:27:28 +02:00
7afe3723e4 Merge pull request #6 from minetest-mods/no_pop
Always collect items one by one
2017-09-12 13:15:19 +02:00
69f0c08561 Merge pull request #7 from minetest-mods/readmeup
Update README
2017-09-12 13:14:58 +02:00
6f8a37bd10 Create CONTRIBUTING.md 2017-09-12 13:12:23 +02:00
19ad20305f Update README 2017-09-12 10:49:57 +02:00
e7b8d02922 Always collect items one by one 2017-09-12 10:13:49 +02:00
0f903cd0b0 Revert "Adjust default key settings"
This reverts commit 3bc3a4bd25.
2017-09-12 09:55:16 +02:00
bf9931d6db Reflect pickup sound gain in readme 2017-09-11 14:51:02 +02:00
739a62a6c6 Call on_punch to pick items (DS) 2017-09-11 14:44:31 +02:00
271a577881 Don't override handle_node_drops in creative mode 2017-09-11 14:35:55 +02:00
729397b6c9 Update item dropping code 2017-09-11 14:22:17 +02:00
4912d3c828 Update mod load logging
There's no official setting called log_mods
2017-09-11 14:09:24 +02:00
057966141a Do not pick items if the player has no interact 2017-09-11 14:08:01 +02:00
78ef2a50f6 Lower pickup sound gain 2017-09-11 13:09:11 +02:00
c4365cd4de Higher update delay if no item was found
avoid loud pop noise (in zero velocity mode)
2017-09-08 21:26:08 +02:00
bf0bb807fb Fix key triggering disabling 2017-09-08 20:57:05 +02:00
22763d3b06 Remove damage setting test 2017-09-08 20:46:36 +02:00
169d83840f Fix redundant minetest.after invocations 2017-09-08 20:43:30 +02:00
da2fb1df20 Add item flight time setting, set it to 5 seconds by default 2017-09-08 20:42:28 +02:00
3bc3a4bd25 Adjust default key settings 2017-09-08 20:38:20 +02:00
55e89d3710 Add keyinvert setting 2017-09-08 20:36:36 +02:00
4b5e362395 Add magnet_radius setting 2017-09-08 20:32:48 +02:00
bc5ef09e21 Play the pickup sound positional to all players 2017-09-07 21:22:23 +02:00
bab3c733fa Add code for zero velocity mode 2017-09-07 21:13:10 +02:00
69a68cb247 Fix multiplayer support 2017-09-07 21:00:55 +02:00
b56c1792de Move item flight code 2017-09-07 20:57:02 +02:00
544381bbfe Simplify velocity calculation 2017-09-07 20:44:08 +02:00
9f54694931 Add item pickup age 2017-09-07 20:39:49 +02:00
fb2c076b92 Add item_drop. prefix to settings 2017-09-06 15:56:04 +02:00
46959e79d2 Use tabs for indentation 2017-09-06 15:51:34 +02:00
e84433d41c Use minetest.after instead of globalstep 2017-09-06 13:29:48 +02:00
884824989f Load settings only if they are used 2017-09-06 13:27:21 +02:00
962d0a3889 Short code a bit 2017-09-02 23:58:29 +02:00
81d32527f3 Add description and conf file 2017-08-31 21:33:28 +02:00
8a14503372 Create LICENSE 2017-08-31 21:27:22 +02:00
a7b7c71d50 New readme 2017-08-31 21:21:15 +02:00
5a6f79a5d2 Code touch-up 2017-08-30 21:13:33 +02:00
363b56fc03 Pickup radius, new keytypes, limited globalstep (#1)
Thank you @LouisCyfer 🌮 🎉
2017-08-03 22:42:53 +02:00
189fea5eff Use ctrl var 2017-07-11 23:29:18 +02:00
1f9ceb3eb3 Fix var bug 2017-07-09 18:38:44 +02:00
6befa68ef8 Proper global settingtypes 2017-07-09 17:33:22 +02:00
d336a226cd Remove remove_items, superseded by item_entity_ttl 2017-07-09 16:25:11 +02:00
16210c79f7 Fix global settings bool fallbacks 2017-07-09 16:12:57 +02:00
2c60ac7ab0 Add optional pickup key, either sneak, use or a+d key. Add settable sound gain. 2017-06-26 15:57:23 +02:00
a666252f1c Add settings for pickups and drops 2017-06-26 15:24:56 +02:00
d9581ec795 Replace deprecated calls 2017-06-26 15:15:48 +02:00
7 changed files with 36 additions and 84 deletions

View File

@ -1,11 +0,0 @@
on: [push, pull_request]
name: build
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: https://raw.githubusercontent.com/minetest-mods/item_drop/master/.luacheckrc

View File

@ -1,19 +0,0 @@
unused_args = false
allow_defined_top = true
max_line_length = 999
ignore = {
"name", "drops", "i",
}
globals = {
"minetest",
}
read_globals = {
string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn"}},
"vector", "ItemStack",
"dump",
}

View File

@ -1,14 +1,15 @@
# Item Drop [![](https://github.com/minetest-mods/item_drop/workflows/build/badge.svg)](https://github.com/minetest-mods/item_drop/actions) [![License](https://img.shields.io/badge/license-LGPLv2.1%2B-blue.svg)](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
A highly configurable mod providing item magnet and in-world node drops\
# item_drop
By [PilzAdam](https://github.com/PilzAdam),
[texmex](https://github.com/tacotexmex/), [hybriddog](https://github.com/hybriddog/).
## Description
A highly configurable mod providing item magnet and in-world node drops
## Licensing
LGPLv2.1/CC BY-SA 3.0. Particle code from WCILA mod by Aurailus, originally licensed MIT.
## Notes
`item_drop` can be played with Minetest 0.4.16 or above. It was originally
item_drop can be played with Minetest 0.4.16 or above. It was originally
developed by [PilzAdam](https://github.com/PilzAdam/item_drop).
## List of features

View File

@ -1,4 +1,5 @@
local load_time_start = minetest.get_us_time()
math.randomseed(os.time())
-- Functions which can be overridden by mods
item_drop = {
@ -93,46 +94,35 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
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
local function collect_item(ent, pos, player)
item_drop.before_collect(ent, pos, player)
minetest.sound_play("item_drop_pickup", {
pos = pos,
gain = pickup_gain,
}, true)
pitch = (100 - (math.random(-2, 2)) * 10) / 100,
})
if pickup_particle then
local item = minetest.registered_nodes[
ent.itemstring:gsub("(.*)%s.*$", "%1")]
local image
local image = ""
if item and item.tiles and item.tiles[1] then
if inventorycube_drawtypes[item.drawtype] then
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 = tile_to_image(tiles[1])
local left = tile_to_image(tiles[3], top)
local right = tile_to_image(tiles[5], left)
local top = tiles[1]
if type(top) == "table" then
top = top.name
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)
else
image = item.inventory_image or item.tiles[1]
@ -213,9 +203,9 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
local itemdef = minetest.registered_entities["__builtin:item"]
local old_on_step = itemdef.on_step
local function do_nothing() end
function itemdef.on_step(self, ...)
function itemdef.on_step(self, dtime)
if not self.is_magnet_item then
return old_on_step(self, ...)
return old_on_step(self, dtime)
end
ObjectRef = ObjectRef or getmetatable(self.object)
local old_funcs = {}
@ -224,7 +214,7 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
old_funcs[method] = ObjectRef[method]
ObjectRef[method] = do_nothing
end
old_on_step(self, ...)
old_on_step(self, dtime)
for i = 1, #blocked_methods do
local method = blocked_methods[i]
ObjectRef[method] = old_funcs[method]
@ -264,13 +254,6 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
return keys_pressed ~= key_invert
end
local function is_inside_map(pos)
local bound = 31000
return -bound < pos.x and pos.x < bound
and -bound < pos.y and pos.y < bound
and -bound < pos.z and pos.z < bound
end
-- called for each player to possibly collect an item, returns true if so
local function pickupfunc(player)
if not has_keys_pressed(player)
@ -280,12 +263,8 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
end
local pos = player:get_pos()
if not is_inside_map(pos) then
-- get_objects_inside_radius crashes for too far positions
return
end
pos.y = pos.y+0.5
local inv = player:get_inventory()
local inv
local objectlist = minetest.get_objects_inside_radius(pos,
magnet_mode and magnet_radius or pickup_radius)
@ -294,6 +273,14 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
local ent = opt_get_ent(object)
if ent
and item_drop.can_pickup(ent, player) then
if not inv then
inv = player:get_inventory()
if not inv then
minetest.log("error", "[item_drop] Couldn't " ..
"get inventory")
return
end
end
local item = ItemStack(ent.itemstring)
if inv:room_for_item("main", item) then
local flying_item
@ -388,13 +375,7 @@ and not minetest.settings:get_bool("creative_mode") then
end
end
local old_handle_node_drops = minetest.handle_node_drops
function minetest.handle_node_drops(pos, drops, player)
if not player or player.is_fake_player then
-- Node Breaker or similar machines should receive items in the
-- inventory
return old_handle_node_drops(pos, drops, player)
end
function minetest.handle_node_drops(pos, drops)
for i = 1,#drops do
local item = drops[i]
if type(item) == "string" then

Binary file not shown.

Binary file not shown.

Binary file not shown.