Giter VIP home page Giter VIP logo

item_drop's Introduction

Item Drop License

A highly configurable mod providing item magnet and in-world node drops
By PilzAdam, texmex, hybriddog.

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 developed by PilzAdam.

List of features

  • All settings may be configured from within the game itself. (Settings tab > Advanced settings > Mods > item_drop)
  • Drops nodes as in-world items on dig if item_drop.enable_item_drop is true (true by default) It does nothing in creative mode.
  • Puts dropped items to the player's inventory if item_drop.enable_item_pickup is true (true by default)
    • Multiple items are picked in a quick succession instead of all at once which is indicated by the pickup sound.
    • It uses a node radius set in item_drop.pickup_radius (default 0.75), if items are within this radius around the player's belt, they're picked.
    • If item_drop.pickup_age is something positive, items dropped by players are ignored for this time to avoid instantly picking up when dropping.
    • If item_drop.pickup_age is -1, items are only picked when they don't move, it's another fix for instant item picking.
    • If item_drop.magnet_radius is bigger than item_drop.pickup_radius, items between these radii are flying to the player for item_drop.magnet_time seconds, after this time, they're picked or stop flying.
    • Enable manual item pickups by mouse only if item_drop.mouse_pickup is true (true by default)
  • Plays a sound when the items are picked up with the gain level set to item_drop.pickup_sound_gain (default 0.2)
  • Requires a key to be pressed in order to pick items if item_drop.enable_pickup_key is true (true by default)
    • The keytypes to choose from by setting item_pickup_keytype are:
      • Use key (Use)
      • Sneak key (Sneak)
      • Left and Right keys combined (LeftAndRight)
      • Right mouse button (RMB)
      • Sneak key and right mouse button combined (SneakAndRMB)
    • If item_drop.pickup_keyinvert is true, items are collected when the key is not pressed instead of when it's pressed.
  • Displays a particle of the picked item above the player if item_drop.pickup_particle is true (true by default)

Known issues

Bug reports and suggestions

You can report bugs or suggest ideas by filing an issue.

Links

item_drop's People

Contributors

cornernote avatar hybriddog avatar louiscyfer avatar nerzhul avatar panquesito7 avatar pilzadam avatar sfan5 avatar tacotexmex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

item_drop's Issues

mod's handle_node_drops can't handle tsm_surprise

When digging a Surprise block the game crashes:

2018-06-17 09:52:37: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'tsm_surprise' in callback node_on_dig(): .../item_drop/init.lua:227: Couldn't spawn item
2018-06-17 09:52:37: ERROR[Main]: stack traceback:
2018-06-17 09:52:37: ERROR[Main]: 	[C]: in function 'error'
2018-06-17 09:52:37: ERROR[Main]: 	.../item_drop/init.lua:227: in function 'handle_node_drops'
2018-06-17 09:52:37: ERROR[Main]: 	...2d/minetest.app/Contents/Resources/builtin/game/item.lua:598: in function <...2d/minetest.app/Contents/Resources/builtin/game/item.lua:538>

Any ideas, @HybridDog? Is it perhaps that the code can't handle multiple drops?

Support on_pickup item definitions

Let’s look for a new function in item definitions, on_pickup, and run that function on every pickup done by item_drop or by hand.

It’d be useful for experience orbs or other ”pseudo items”, opening up new possibilities. What do you think @HybridDog?

Items are not autopicked up

Minetest 5.0, CDB mod version.

What happened? It just worked... now I need to manually pick up all of them, tried to change various settings, including mouse_pickup, disabled key pickup, did not help. Mod default settings are somewhat confusing, i was expecting usual magnet and pick up behaviour, but it does not. Do I need PHD for that :(

How to make it work as usual? Aka drop on dig and autopick up?

Use branches

@HybridDog, could you start use branches for major features and code rework? I'd really like for master to be stable for users, at all times.

Minetest Game crashes on Mac and will not restart

(Moved from Dreambuilder)

Details of computer and OS:

Macbook Pro 2015 (early)
Running Catalina 10.15.6

Minetest 5.3.0
running Minetest Game

Problem
Following a dig which triggers a fall of gravel, Game crashes in world-of-interest as shown below and will not restart, crashing immediately on attempt.

Other worlds still playable.

Results from debug.txt:

2020-09-17 15:08:00: ACTION[Server]: singleplayer places node default:torch at (-1045,-276,2598)
2020-09-17 15:08:16: WARNING[Server]: Assignment to undeclared global "is_light" inside a function at ...esources/games/minetest_game/mods/walking_light/init.lua:94.
2020-09-17 15:08:20: ACTION[Server]: singleplayer digs mese_crystals:mese_crystal_ore4 at (-1034,-282,2587)
2020-09-17 15:08:38: ACTION[Server]: player singleplayer (id=1, hp=11) punched LuaEntitySAO "__builtin:item" at (-1034,-290,2587) (id=7, hp=1), damage=0
2020-09-17 15:08:50: ACTION[Server]: singleplayer places node default:torch_wall at (-1028,-291,2587)
2020-09-17 15:08:54: ACTION[Server]: singleplayer digs default:stone_with_iron at (-1029,-289,2588)
2020-09-17 15:08:55: ACTION[Server]: singleplayer digs default:stone_with_iron at (-1028,-288,2588)
2020-09-17 15:08:57: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod '*builtin*' in callback luaentity_Step(): ...rt/minetest/mods/dreambuilder_modpack/item_drop/init.lua:381: attempt to index local 'player' (a nil value)
2020-09-17 15:08:57: ERROR[Main]: stack traceback:
2020-09-17 15:08:57: ERROR[Main]: 	...rt/minetest/mods/dreambuilder_modpack/item_drop/init.lua:381: in function 'handle_node_drops'
2020-09-17 15:08:57: ERROR[Main]: 	....0/minetest.app/Contents/Resources/builtin/game/item.lua:613: in function 'on_dig'
2020-09-17 15:08:57: ERROR[Main]: 	...minetest.app/Contents/Resources/builtin/game/falling.lua:248: in function 'try_place'
2020-09-17 15:08:57: ERROR[Main]: 	...minetest.app/Contents/Resources/builtin/game/falling.lua:358: in function <...minetest.app/Contents/Resources/builtin/game/falling.lua:273>
2020-09-17 15:08:57: ACTION[Server]: singleplayer leaves game. List of players: 
2020-09-17 15:08:57: ACTION[Main]: Server: Shutting down

Issue with pipeworks node breaker

When a machine, such as a node breaker from pipeworks, breaks a block it probably shouldn't drop the item, as this makes it impossible to build automated machines (eg automatic cobblestone generators).

No item drop when digging a node which drops multiple items

For example, digging "default:clay" would drop "default:clay_lump 4" (which means 4 clay lumps), while the enabling this mod drops nothing.

This can be fixed by replacing the "init.lua" with the code in the attachment (rename to "init.lua").
The change is made inside "handle_node_drops" and utilizes ItemStack.
init.lua.txt

EDIT: I forgot to make "count" and "name" local...

Wont work on server

I get settings to work in singleplayer and move it to my server and it dosen't work. Magnet dosen't pull items to me and the key press dosent work.

Item magnet

Should the item magnet behaviour (items flying to the player) be kept?

Crash in Hades Revisited

Not sure what this is about.

2020-04-08 13:32:11: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'item_tweaks' in callback environment_Step(): ...est/games/hades_revisited/mods/item_tweaks/item_drop.lua:133: attempt to index upvalue 'v' (a nil value)
2020-04-08 13:32:11: ERROR[Main]: stack traceback:
2020-04-08 13:32:11: ERROR[Main]: 	...est/games/hades_revisited/mods/item_tweaks/item_drop.lua:133: in function 'moveTowards'
2020-04-08 13:32:11: ERROR[Main]: 	...est/games/hades_revisited/mods/item_tweaks/item_drop.lua:184: in function <...est/games/hades_revisited/mods/item_tweaks/item_drop.lua:170>
2020-04-08 13:32:11: ERROR[Main]: 	...inetest.app/Contents/Resources/builtin/game/register.lua:429: in function <...inetest.app/Contents/Resources/builtin/game/register.lua:413>
2020-04-08 13:32:11: ERROR[Main]: stack traceback:

Core mechanics have changed

  • The mod no longer drops items on the node below the newly dug node, but now throws items off to the sides with great velocity, 2-6 nodes away.

  • The pickup feature no longer picks items up that are in range but at player waist level (1 node up)

  • The key-triggered pickup lags more than before.

  • Pickup sound plays multiple times even for one item picked up

This changes core behavior of the mod and is likely to upset players and server owners who depend on the functionality to work a certain way. I need to put the newer commits into a new branch now that it's clear they're not fit for production yet. All contributions are appreciatiated, they just need testing before going into master and some of these commits are clearly not tested enough.

I've reverted master to 962d0a3 and put newer commits in rewrite. master is protected to allow for due process with PRs instead of direct pushing, while rewrite is open as usual (@HybridDog). Additionally I plan to create a new dev branch for vetted and tested new commits.

git checkout -b newbranch # switch to a new branch
git branch -f master 962d0a3889db609c349e3e99a58104bbb22f4c93 # make master point to some older commit 

sound effect volume/discreteness

It seems that the sound effect "ploop" is quite a bit too loud as compared to other sounds-- probably ought not be quite as loud as placing a block. It also seems that volume of "overheard" pickups is a bit too loud as one would expect proximity of pickup effect to be the range of the sound, dropping off fairly sharp.

Perhaps a quieter sample or attenuation or configuration for the sound effect?

There is no sound for drop (q) of items.

Thank you. Love the mod effect on gameplay.

Json related error

Minetest 5.0, mod installed from CDB

WARNING[Main]: Undeclared global variable "item_drop" accessed at ...\_Games\minetest-5.0-gc64\bin\..\mods\item_drop\init.lua:4
ACTION[Main]: [MOD] Mobs Redo loaded
ERROR[Main]: Failed to parse json data * Line 1, Column 1
ERROR[Main]:   Syntax error: value, object or array expected.
ERROR[Main]: data: ""

Pickup sound is too loud

Unlike Minecraft's gentle pick up sound, item_drop ones are pretty high volume (comparable to other minetest sounds). This is very irritating for headphone users (like me), default should be much quieter, around 0.1 (compared to current 0.4)

Crash :-(

2020-05-17 18:53:45: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod '' in callback environment_Step(): Invalid 
float vector dimension range 'x' (expected -2.14748e+06 < x < 2.14748e+06 got -2.14748e+06).
2020-05-17 18:53:45: ERROR[Main]: stack traceback:
2020-05-17 18:53:45: ERROR[Main]:       [C]: in function 'get_objects_inside_radius'
2020-05-17 18:53:45: ERROR[Main]:       ..._World/worldmods/dreambuilder_modpack/item_drop/init.lua:267: in function 'pickupfunc'
2020-05-17 18:53:45: ERROR[Main]:       ..._World/worldmods/dreambuilder_modpack/item_drop/init.lua:309: in function 'func'
2020-05-17 18:53:45: ERROR[Main]:       /usr/local/share/minetest/builtin/common/after.lua:20: in function </usr/local/share/minetest/builtin
/common/after.lua:5>
2020-05-17 18:53:45: ERROR[Main]:       /usr/local/share/minetest/builtin/game/register.lua:429: in function </usr/local/share/minetest/built
in/game/register.lua:413>

New core throwing distance might make some age check methods irrelevant

minetest/minetest#6410 got merged. Will probably find itself into .4.17.

Side effect is the item is now far enough away to avoid auto-pickup, assuming auto pickup range is set to a practical value like a radius of 1 node.

This should make it possible to simplify hindering just-thrown items to be picked up too fast. If it's possible to differ items dropped from player from other items, those just need to be limited from pickup for a very short time.

Make mined items missable, for fun

It is fun and challenging if it is missable. I started working on it locally but started an issue since the CONTRIBUTING file says to discuss changes involving changes to defaults. This would require:

  • Re-enable gravity at end of magnet_time, when magnet_time is 0, and same for pickup_age (change from auto-pickup to drop to ground)
  • Make default magnet_time 0
  • Change some other defaults (below)

I started working on it locally but started an issue since the CONTRIBUTING file says to start an issue to discuss changes involving changes to defaults.

What do you think? It would be more like MC (along with default pickup_radius .4, magnet_radius 1.4). I'm not saying being like MC is always good, just that these settings (and potentially code changes) provide a good result.

  • The change would add a possibility of loss which makes mining more exciting. Instead of the item following you around, the item jumps toward you and you have to be close enough (and that's your only chance if you there is a dropoff between you and the node you broke).
  • It adds kinetics to mining that affect gameplay (more interactivity with world provides more immersion), rather than just an audiovisual change like the current version does (since you always get the item, there is no actual gameplay change in the current version).
  • Helps when player presses the drop key (trickier but doable) which is broken (picked up automatically) if some settings in this mod are set to certain values in the current version.
    • :edit: Correction: The pickup_age is supposed to do gravity rather than collect immediately (?) (fails on certain engine version/mod combinations, unless it is a timing issue. The issue is somehow dropped_by isn't always set)

Some other code changes are necessary to re-enable gravity on the item after magnet_time or pickup_age finishes, etc. I got it working on my local copy.

:edit: It seems to work fine with the following defaults (no code changes would be necessary except defaults--The problem I was having that would require further changes to fix manually dropping items was a bug where MultiCraft wasn't setting dropped item entity's dropped_by string):

item_drop.magnet_time = 3.0
item_drop.magnet_radius = 1.4
item_drop.pickup_age = 2.5
item_drop.pickup_radius = 0.4

Crash when digging 'techage:cooler'

only happens with this block

2022-09-22 19:27:01: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '' in callback environment_Step(): ...k/minetest/minetest-5.6.0/bin/../builtin/game/item_s.lua:15: attempt to index local 'img1' (a nil value)
2022-09-22 19:27:01: ERROR[Main]: stack traceback:
2022-09-22 19:27:01: ERROR[Main]:     ...k/minetest/minetest-5.6.0/bin/../builtin/game/item_s.lua:15: in function 'inventorycube'
2022-09-22 19:27:01: ERROR[Main]:     ...k/minetest/minetest-5.6.0/bin/../mods/item_drop/init.lua:124: in function 'collect_item'
2022-09-22 19:27:01: ERROR[Main]:     ...k/minetest/minetest-5.6.0/bin/../mods/item_drop/init.lua:295: in function 'pickupfunc'
2022-09-22 19:27:01: ERROR[Main]:     ...k/minetest/minetest-5.6.0/bin/../mods/item_drop/init.lua:320: in function 'func'
2022-09-22 19:27:01: ERROR[Main]:     .../minetest/minetest-5.6.0/bin/../builtin/common/after.lua:20: in function <.../minetest/minetest-5.6.0/bin/../builtin/common/after.lua:5>
2022-09-22 19:27:01: ERROR[Main]:     ...minetest/minetest-5.6.0/bin/../builtin/game/register.lua:429: in function <...minetest/minetest-5.6.0/bin/../builtin/game/register.lua:415>

Crash when digging unknown node

Removed the vines mod from a world, which nodes then became unknown. They still contain the node name however, so when digging them item_drop tries to drop such a node which crashes the game.

The handle_node_drops needs to be able to handle the case of unknown nodes with known names.

Does not work with 5.3.0-dev due to changes in item entity params

2020-05-07 17:37:25: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback luaentity_Step(): /usr/local/share/minetest/builtin/game/item_entity.lua:203: assertion failed!
2020-05-07 17:37:25: ERROR[Main]: stack traceback:
2020-05-07 17:37:25: ERROR[Main]: 	[C]: in function 'assert'
2020-05-07 17:37:25: ERROR[Main]: 	/usr/local/share/minetest/builtin/game/item_entity.lua:203: in function 'on_step'
2020-05-07 17:37:25: ERROR[Main]: 	...inetest/games/minetest_game/mods/default/item_entity.lua:43: in function <...inetest/games/minetest_game/mods/default/item_entity.lua:42>

Please apply this patch to fix it:

diff --git a/init.lua b/init.lua
index bc0fc1a..42d3ff6 100644
--- a/init.lua
+++ b/init.lua
@@ -201,9 +201,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, dtime)
+                       function itemdef.on_step(self, dtime, ...)
                                if not self.is_magnet_item then
-                                       return old_on_step(self, dtime)
+                                       return old_on_step(self, dtime, ...)
                                end
                                ObjectRef = ObjectRef or getmetatable(self.object)
                                local old_funcs = {}
@@ -212,7 +212,7 @@ if legacy_setting_getbool("item_drop.enable_item_pickup",
                                        old_funcs[method] = ObjectRef[method]
                                        ObjectRef[method] = do_nothing
                                end
-                               old_on_step(self, dtime)
+                               old_on_step(self, dtime, ...)
                                for i = 1, #blocked_methods do
                                        local method = blocked_methods[i]
                                        ObjectRef[method] = old_funcs[method]

Thanks to @sofar for this fix.

Sounds are stereo

The pickup sounds are stereo. And they are played at a pos. Minetest doesn't support this and plays the sounds positionless (for players in max_hear_distance).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.