Commit Graph

16 Commits

Author SHA1 Message Date
est31 8fd57dc4bb
Introduce builtin_shared and use it to fix #4778
Fixes #4778 which was about the error:

ServerError: Lua: Runtime error from mod '' in callback item_OnPlace():
/usr/local/share/minetest/builtin/game/item.lua:278: attempt to call global 'check_attached_node' (a nil value)

The issue was a regression of commit 649448a2a91fbf3e944b2f2e739f4e2292af1df0

"Rename nodeupdate and nodeupdate_single and make them part of the official API"
2022-05-21 16:14:02 +02:00
Auke Kok db3e245ff0
Builtin/game/item: Add `place_param2` nodedef field
This allows a nodedef to specify a fixed value for param2 to be
used for all normal placements.

There are several uses for this:

- nodes that require param2 to be set to a non-zero value for
  internal mod use. E.g. leafdecay could use this to detect that
  leaves are played by players.
- force wallmounted or facedir value at placement at placement

This overrides any player look direction or other on-the-fly
param2 setting during placement.
2022-05-21 16:13:42 +02:00
Auke Kok 9e994e0e39
Introduce "protection_bypass" privilege.
This privilege allows map protection bypassing for server operators
and world moderators.

Initially I had thought that bypassing protection mods would have been
something that could entirely be done inside mods and minetest_game,
but the concept of protection is defined in core, in the code of
core.is_protected().

I don't feel that it would be logical to introduce a protection
concept in core, but not some way around that for server operators
to maintain map parts that need fixing, de-griefing or cleanup.

Others had noticed the same problems, and proposed a patch to
minetest_game. That patch is fine by itself, but it fails to add
protection bypass functionality for digging normal nodes and placing
nodes.

So, instead, we indroduce the new priv "protection_bypass" in core,
and modify 'on_place_node' and 'node_dig' to allow bypassing node
protections if the player holds this priv.

This priv was tested with protector redo by tenplus1.

A followup patch to Minetest Game will include allowing special checks
for doors, trapdoors, chests in Minetest Game.

Protection mods will likely want to mimic the changes in their relevant
code sections.
2022-05-21 16:13:25 +02:00
Diego Martínez 60a5b2ac4d
Initialize facedir and wallmounted tables only once.
This makes the functions a bit faster since they don't
have to recreate the tables every invocation, and makes
the code more readable.

Also, document `wallmounted_to_dir`.

The function was implemented but not documented in `lua_api.txt`.
2022-05-21 16:13:18 +02:00
paramat b36217f608
Liquids: Flow into and destroy 'floodable' nodes
Add new node property 'floodable', default false
Define "air" as floodable = true in C++ and lua
2022-05-21 16:13:10 +02:00
HybridDog 93de351e5f
Fix missing localization for obj 2022-05-21 16:13:09 +02:00
Alex Ford 8341ca836e
Add on_secondary_use when right clicking an item in the air 2022-05-21 16:13:07 +02:00
Robert Zenz 4662b21222
Add the player name to dropped items
The player name is now added in the field "dropped_by" on the created
entity.
2022-05-21 16:13:04 +02:00
Fernando Carmona Varo 095cfc2c70
Added minetest.wallmounted_to_dir 2022-05-21 16:12:53 +02:00
est31 e1b5a8789e
Some map border related fixes
1. Check for entity addition success in spawn_item implementation
2. Check for success in item_drop callback, so that the player
doesn't lose the item if they are outside bounds and try to drop it.
3. When existing player joins game, check that their position is inside
map bounds. If not, set their position to the return value of findSpawnPos().
4. Make findSpawnPos() respect the border

2 fixes a lua crash if a player drops an item outside map bounds.
3 fixes an assertion crash if a player leaves when being outside map bounds,
and then rejoins.
2022-05-21 16:12:52 +02:00
kwolekr 3120d9e8e2
SAPI: Track last executed mod and include in error messages 2022-05-21 16:12:46 +02:00
rubenwardy aabe33eea2
Fix minetest.item_eat's replace_with_item, fixes #2292 2022-05-21 16:12:24 +02:00
Lord James d87cb5ab42
New feature: drop a item instead a stack while...
sneaking
2022-05-21 16:11:47 +02:00
rubenwardy 68ed7cbe50
Add item eat callback 2022-05-21 16:11:45 +02:00
ShadowNinja 37c32c715f
Use "core" namespace internally 2022-05-21 16:11:41 +02:00
ShadowNinja 148b74312e
Organize builtin into subdirectories 2022-05-21 16:11:40 +02:00