Commit Graph

204 Commits

Author SHA1 Message Date
Wuzzy
80fe516e4e Remove “inf” argument from shutdown command help (#5880) 2017-06-02 17:16:30 +02:00
Elijah Duffy
dada983ff4 Add /clearinv chat command (#4994)
Allow players to clear their own inventory or that of another player with /clearinv command. server privilege is required to clear another player's inventory, no privileges are required to clear your own inventory.'
2017-05-20 12:56:17 +02:00
ShadowNinja
43d1f375d1 Use a settings object for the main settings
This unifies the settings APIs.

This also unifies the sync and async registration APIs, since the async
registration API did not support adding non-functions to the API table.
2017-05-06 15:33:19 -04:00
Loïc Blot
29ab20c272 Player data to Database (#5475)
* Player data to Database

Add player data into databases (SQLite3 & PG only)

PostgreSQL & SQLite: better POO Design for databases

Add --migrate-players argument to server + deprecation warning

* Remove players directory if empty
2017-04-23 14:35:08 +02:00
Dániel Juhász
f6d1b682d3 Add /fixlight chat command 2017-04-22 01:24:41 +01:00
Loïc Blot
34d32ce55a Implement delayed server shutdown with cancelation (#4664) 2017-04-15 23:19:18 +02:00
Dániel Juhász
58d83a7bb2 Hardware coloring for itemstacks
Adds the possibility to colorize item stacks based on their metadata.

In the item/node definition you can specify palette (an image file)
and color (fallback color if the item has no palette or metadata).
Then you can add palette_index to the metadata.

Dropped itemstacks with different colors do not merge.
2017-04-08 18:39:15 -07:00
red-001
d4e9dd4643 Move chat command handling code from C++ to Lua (#5528) 2017-04-08 20:03:57 +02:00
paramat
ec0c4d33db Map generation limit: Make per-world
The setting limits map generation but affects nothing else.
Add 'mapgen_limit' to global mapgen parameters.
Move 'blockpos_over_mapgen_limit()' to the only place it is called
from: map.cpp.
Allow teleportation to any part of the world even if over the set
mapgen limit.
Simplify the reading of this limit in mgvalleys.
Remove the 'map_generation_limit' setting.
2017-03-27 03:18:09 +01:00
red-001
e70e15134c Change command prefix to "." and add "help" command. 2017-03-26 05:51:14 +01:00
red-001
d31750cb93 Give CSM access to use core.colorize() (#5113) 2017-03-17 19:20:13 +01:00
Auke Kok
b539985ab8 Fix two nul deref if digging unknown nodes. (#5398)
Introduced by d785456b3fa35faf47cb972fde9e8668382c5e22 (#5162)
2017-03-15 08:04:53 +01:00
Loïc Blot
2c19d51409 [CSM] sound_play & sound_stop support + client_lua_api doc (#5096)
* squashed: CSM: Implement register_globalstep
  * Re-use fatal error mechanism from server to disconnect client on CSM error
  * Little client functions cleanups

* squashed: CSM: add core.after function
  * core.after is shared code between client & server
  * ModApiUtil get_us_time feature enabled for client
2017-03-13 23:56:05 +01:00
red-001
d7bc346981 [CSM] Add client-sided chat commands (#5092) 2017-03-13 23:56:05 +01:00
Vladislav Tsendrovskii
7a4878cd0b Save metainfo for falling nodes 2017-03-11 23:42:19 -08:00
tenplus1
d785456b3f Optimize item.lua
Replace slow ItemStack get_definitions with registered_nodes one's and cached playername as it's used multiple times.  Also removed local item = itemstack:peek_item() as it is never used.
2017-03-10 11:24:10 -08:00
zaoqi
c9ac722ea9 Add minetest.spawn_falling_node(pos) (#5339)
* Add minetest.spawn_falling_node(pos)

* lua_api.txt: Add minetest.spawn_falling_node(pos)

* Update minetest.spawn_falling_node(pos)
2017-03-04 18:36:37 +01:00
red-001
4d634ef675 Fix crash that can be caused by the shutdown command. (#5292) 2017-02-25 09:28:25 +01:00
Dániel Juhász
00123ee04d Fixes for colorwallmounted and colorfacedir nodes
Correct node placement prediction for attached colorwallmounted nodes.
Correct placement direction for colorfacedir and colorwallmounted nodes.
Correct detatch mechanism for attached colorwallmounted nodes.
2017-02-18 22:47:24 +00:00
tenplus1
e9cd7187e8 Statbars.lua: Cache enable_damage setting 2017-02-18 22:46:06 +00:00
red-001
3d25914986 Add support for the new arguments of request_shutdown to the /shutdown chatcommand. (#5252) 2017-02-18 12:16:11 +01:00
Wuzzy
f5d4494a51 Add textures for air and ignore items (#5196) 2017-02-10 08:19:31 +01:00
Nathanaël Courant
3e355ab7d5 Make facedir_to_dir and wallmounted_to_dir work with coloured nodes as well. (#5153) 2017-01-31 15:02:30 -08:00
Auke Kok
7fc6719968 core: Add dir_to_yaw and yaw_to_dir helpers
These are needed to go from things like entity yaw to a vector
and vice versa.
2017-01-23 07:38:39 +00:00
Elijah Duffy
efa54f9c46 Add chatcommand unregister and override API (#5076)
Introduces two functions to unregister and override chatcommands.
minetest.unregister_chatcommand("<name>") and
minetest.override_chatcommand("<name>", {<redifinition>})
2017-01-20 19:49:20 +01:00
rubenwardy
c5967f75f0 Add minetest.player_exists() (#5064) 2017-01-18 11:19:57 +01:00
Ezhh
d218baa3ac Improve priv descriptions (#5047) 2017-01-17 15:41:25 +01:00
red-001
2f56a00d9e Remove client-side chat prediction. (#5055)
Network lag isn't really a big issue with chat and chat prediction makes writing mods harder.
2017-01-17 00:09:47 +01:00
Rui
ec30d49e02 Add staticdata parameter to add_entity (#5009)
* Add staticdata parameter to add_entity
* Add add_entity_with_staticdata to core.features
2017-01-09 20:39:45 +01:00
sfan5
73fdb63597 builtin/.../falling.lua: Avoid crash when hitting unknown nodes 2017-01-09 16:39:40 +01:00
rubenwardy
e8b7179ccd Expose and document chatcommands as minetest.registered_chatcommands 2017-01-04 20:56:07 +00:00
Dorian Wouters
a1346c916e Fix /grant & /revoke not working with custom auth handler (#4974)
core.auth_table is not supposed to be accessed directly.
2016-12-31 18:12:26 +01:00
paramat
5e4d6468a3 Builtin/../falling.lua: Avoid crash when object pos over limit
If the object pos is over limit, 'add entity' will not add an entity,
causing 'obj' to be nil.
2016-12-21 13:30:10 +00:00
red-001
fb1406bdff Don't send a join message in singleplayer mode. 2016-12-03 00:13:02 +01:00
sfan5
c38985825f Allow restricting detached inventories to one player
This combats the problem of sending the hundreds of
"creative" / "armor" or whatever detached invs that
exist on popular servers to each and every player
on join or on change of said invs.
2016-11-28 13:41:19 +01:00
orwell96
0d1c9598a0 Make supplying empty formspec strings close the formspec (#4737)
This will only happen if the formname matches or if formname is "".
2016-11-23 02:15:22 +10:00
paramat
c6ca7a81cc Tool break: Reduce gain of break sounds 2016-11-20 04:43:09 +00:00
Auke Kok
4a0a6723af Builtin/../item: Enable tool breaking sounds
If a tool wears out and is destroyed, it's itemstack count
goes to 0, and we can optionally play a breaking sound.

This patch implements playing a breaking sound when this
occurs. Sounds need to be added to the tool itemdef
registration as the sound name string in the .sound.breaks
member.
2016-11-18 06:15:08 +00:00
est31
afc48c802a 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"
2016-11-16 18:51:36 +01:00
est31
649448a2a9 Rename nodeupdate and nodeupdate_single and make them part of the official API
Now, the renamed forms of nodeupdate and nodeupdate_single are part of the official API.

As nodeupdate has been used by Minetest Game and in mods despite of not
being part of the official API, we ease the transition by still supporting
it for the 0.4.15 release. After the release, the two functions can be removed.

The removal will not violate the stability promise, as that promise only
includes the official and documented API.

Also, make some formerly global functions local. They most likely haven't
been used by mods, therefore they won't get stubs with deprecation warnings,
hard erroring directly.
2016-11-14 13:08:22 +01:00
paramat
3c5da70d7c Builtin/../falling: Fix bugs caused by 'ignore' nodes
Original commit by t4im, rebased and developed by paramat.
Fix CONTENT_IGNORE being replaced by falling nodes or causing large
areas of sand to collapse into itself.
Format some conditional code for clarity.
Add and clarify some comments.
2016-11-07 21:55:17 +00:00
Wuzzy
e82bd3f067 Privileges: Only give singleplayer 4 basic privs
- interact
- shout
- privs
- basic_privs
2016-11-07 21:55:17 +00:00
lhofhansl
f8fd432dca Add debug priv, and allow player to display the scene as wire-frame. (#4709) 2016-11-04 03:14:32 +01:00
red-001
c7d569b863 Chat commands: Trim whitespaces from input of /privs command 2016-10-20 03:39:03 +01:00
red-001
c31e354342 Builtin/../chatcommands: Add /grantme command 2016-10-16 01:13:50 +01:00
tenplus1
a468acce2c Builtin/../falling.lua: Code optimisation 2016-10-14 02:12:32 +01:00
HybridDog
9978d0796f VoxelArea: faster iter function (#4490) 2016-10-08 22:42:17 +10:00
paramat
89dbc0a25d Builtin/falling: Add fallback vector in case of nil 'wallmounted to dir'
The fallback vector is in case 'wallmounted to dir' is nil due
to voxelmanip placing a wallmounted node without resetting a
pre-existing param2 value that is out-of-range for wallmounted.
The fallback vector corresponds to param2 = 0.
2016-10-03 01:56:08 +01:00
raymoo
2516c516bc Forceloading: Transient forceloads
Adds a flag to forceload_block which lets you turn off persistence for
that forceload.
2016-10-03 01:54:36 +01:00
Rui
3a95054db5 Fix typo in core.after (#4560) 2016-10-01 16:16:50 +02:00
paramat
5091cb5ecd Builtin: Change error to warning for light_source > 14 2016-09-21 08:04:11 +02:00
paramat
3aefa5d3ce Register.lua: Throw error if node 'light_source' > core.LIGHT_MAX
Add 'core.LIGHT_MAX = 14' to builtin/game/constants.lua with the intention
to replace misplaced 'default.LIGHT_MAX = 14' in Minetest Game.
Add comment in light.h requiring the constant be changed in both places.
Add lighting bug warning to note in lua_api.txt.
There are hundreds of mod uses of 15 which causes a lighting bug.
2016-09-17 09:33:25 +01:00
paly2
aa33166386 Add minetest.unregister_item and minetest.register_alias_force 2016-09-08 03:26:52 -04:00
SmallJoker
51e13ae588 Builtin: Disallow registering users with the same name
Prevents duplicate names: 'NickName', 'nickname', 'NICKNAME'.
Skips already registered users, so they can connect as usual.
2016-08-29 00:58:39 +01:00
Xunto
0b0075e6ad Move on join and on leave messages to lua (#4460) 2016-08-22 20:21:48 +02:00
Ben Deutsch
82494b8cc1 Zooming the camera requires the 'zoom' privilege 2016-08-10 12:18:25 +02:00
Tim
c8b4bedaa8 Builtin: Add core.MAP_BLOCKSIZE constant 2016-07-26 04:17:07 +01:00
Tim
58eb5f39d4 Builtin: Fix check for a player object in core.check_player_privs
core.check_player_privs accepts as first argument a name or player object, but just tested for a string.
This caused crashes inside builtin, when being passed any unexpected types.

This provides a better (duck-typing like) test, better error reporting.
2016-07-26 04:15:06 +01:00
Tim
d7060c212f Builtin/profiler: Replace game profiler (#4245)
Use the setting "profiler.load" to enable profiling.
Other settings can be found in settingtypes.txt.

* /profiler print [filter] - report statistics to in-game console
* /profiler dump [filter] - report statistics to STDOUT and debug.txt
* /profiler save [format [filter]] - saves statistics to a file in your worldpath
	* txt (default) - same treetable format as used by the dump and print commands
	* csv - ready for spreadsheet import
	* json - useful for adhoc D3 visualizations
	* json_pretty - line wrapped and intended json for humans
	* lua - serialized lua table of the profile-data, for adhoc scripts
* /profiler reset - reset all gathered profile data.
	This can be helpful to discard of any startup measurements that often spike during loading or to get more useful min-values.

[filter] allows limiting the output of the data via substring/pattern matching against the modname.

Note: Serialized data structures might be subject to change with changed or added measurements.
	csv might be the most stable, due to flat structure.

Changes to the previous version include:

* Updated and extended API monitoring
* Correct calculation of average (mean) values (undistorted by idleness)
* Reduce instrumentation overhead.
* Fix crashes related to missing parameters for the future and occasional DIV/0's.
* Prevent issues caused by timetravel (overflow, timejump, NTP corrections)
* Prevent modname clashes with internal names.
* Measure each instrumentation individually and label based on registration order.
* Labeling of ABM's and LBM's for easier classification.
  Giving several ABM's or LBM's the same label will treat them as one.
  Missing labels will be autogenerated based on name or registration order.
* Configurable instrumentation and reporting. Skip e.g. builtin if you don't need it.
* Profile the profiler to measure instrumentation overhead.
2016-07-12 21:51:10 +02:00
Auke Kok
39a9e9874e 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.
2016-06-17 04:41:20 +01:00
Ekdohibs
14ef2b445a Add colored text (not only colored chat).
Add documentation, move files to a proper place and avoid memory leaks.
Make it work with most kind of texts, and allow backgrounds too.
2016-05-31 17:34:29 +02:00
TriBlade9
1d40385d4a Colored chat working as expected for both freetype and non-freetype builds. @nerzhul improvements * Add unit tests * Fix coding style * move guiChatConsole.hpp to client/ 2016-05-31 17:34:29 +02:00
Sokomine
4134d8ad13 protection_bypass priv can now be revoked in singleplayer (#4169) 2016-05-30 22:40:32 +10:00
paramat
643ac9dd7a Item entities: Don't show description as infotext
Partially reverts #3547
Infotext remains optional for objects, empty by default
2016-05-22 08:21:44 +01:00
Wayward One
8b940c005f Add on_punchnode callback 2016-05-17 22:16:21 +10:00
tenplus1
7baddd1735 Avoid teleporting player if /teleport coords are out-of-range 2016-04-29 00:00:35 +10:00
rubenwardy
17bfe2fe5b Builtin: Add basic_privs setting 2016-04-28 07:19:07 +01:00
Auke Kok
a60aa8e226 Fix timer initialization.
This fixes the problem that the first timer tick is an
overrun and causes all timers to expire immediately.

replaces #4003
2016-04-21 10:14:59 +01:00
Auke Kok
855a305057 falling: walk 4 additional diagonally down directions.
This seems very little cost and matches the old behavior more
closely. This will cause some more falling nodes to get added
to falling clusters. With the efficiency of the algorithm, this
really doesn't do much damage.
2016-04-20 06:51:11 +01:00
Auke Kok
d7908ee494 Convert nodeupdate to non-recursive
This took me a while to figure out. We no longer visit all 9 block
around and with the touched node, but instead visit adjacent plus
self. We then walk -non- recursively through all neigbors and if
they cause a nodeupdate, we just keep walking until it ends. On
the way back we prune the tail.

I've tested this with 8000+ sand nodes. Video result is here:

  https://youtu.be/liKKgLefhFQ

Took ~ 10 seconds to process and return to normal.
2016-04-11 00:01:28 -04:00
tenplus1
e72b8f25ee stop falling.lua error
2016-03-27 15:47:01: ERROR[Main]: ServerError: Lua: Runtime error from mod '*builtin*' in callback luaentity_Step(): Node name is not set or is not a string!
2016-03-27 15:47:01: ERROR[Main]: stack traceback:
2016-03-27 15:47:01: ERROR[Main]: 	[C]: in function 'add_node'
2016-03-27 15:47:01: ERROR[Main]: 	/usr/share/minetest/builtin/game/falling.lua:96: in function </usr/share/minetest/builtin/game/falling.lua:43>
2016-03-29 23:56:23 +02:00
Rui
c3f6cdcd54 Falling: Set acceleration on step again
Commit

65c09a96f41705bb8e75fc5ff4276342be91ed11 "Set acceleration only once in falling node"

has made the acceleration being set only once.
But this has introduced a regression.

Fix #3884.
2016-03-25 15:19:39 +01:00
Auke Kok
2f640888d8 Make options local here.
Undoubtably this may cause problems later if unchecked.

```
2016-03-22 21:57:52: WARNING[Server]: Assignment to undeclared global "options" inside a function at .../sofar/git/minetest/bin/../builtin/game/chatcommands.lua:862.
```
2016-03-24 16:52:26 +01:00
paramat
2ce02c99b4 Builtin/game/falling: Re-add comma removed by recent commit 2016-03-19 18:46:08 +00:00
Rui914
65c09a96f4 Set acceleration only once in falling node 2016-03-19 17:56:46 +00:00
Auke Kok
f627ef39e0 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.
2016-03-11 21:09:53 +00:00
Auke Kok
4e59fcf5c1 Add consistent monotonic day counter - get_day_count()
I've written several experimental bits of code that revolve around the
need for a consistent calendar, but implementing one is extremely hard
in mods due to time changes and mods overriding core.get_timeofday(),
which will conflict.

The second part of the problem is that doing this from a mod requires
constant maintenance of a settings file.

An implementation in core is trivial, however, and solves all of
these problems at virtually no cost: No extra branches in server
steps, and a single branch when minetest.set_time_of_day(), which is
entirely reasonable.

We store the day_count value in env_meta.txt.

The use case is obvious: This change allows mods to create an actual
virtual calendar, or properly account for seasonal changes, etc..

We add a "/days" chatcommand that displays the current day count. No
permissions are needed. It can only retrieve the day count, not
modify it.
2016-03-09 01:45:23 +01:00
ShadowNinja
3ce6642a26 Add AreaStore custom ID API 2016-03-07 16:33:20 -05:00
est31
d494733839 Add minetest.register_lbm() to run code on block load only 2016-03-07 19:54:26 +01:00
Rui914
24e8b0ac1e Faster insertion into table 2016-03-06 23:42:04 +00:00
Jeija
31e0667a4a Add Lua interface to HTTPFetchRequest
This allows mods to perform both asynchronous and synchronous HTTP
requests. Mods are only granted access to HTTP APIs if either mod
security is disabled or if they are whitelisted in any of the
the secure.http_mods and secure.trusted_mods settings.

Adds httpfetch_caller_alloc_secure to generate random, non-predictable
caller IDs so that lua mods cannot spy on each others HTTP queries.
2016-02-22 15:39:41 +01:00
Diego Martinez
13dd7959db 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`.
2016-02-11 04:23:17 +00:00
Kahrl
0f03547b03 Log /clearobjects mode 2016-02-11 04:22:58 +00:00
Kahrl
b1428ab4bb Add '/clearobjects quick' 2016-02-11 04:22:58 +00:00
Splizard
0e75eb4324 Add admin command which says who the administator is for the server. 2016-02-04 13:23:02 +01:00
Auke Kok
ad884f23d4 New timer design.
I could honestly not make much sense of the timer implementation
that was here. Instead I've implemented the type of timer algorithm
that I've used before, and tested it instead.

The concept is extremely simple: all timers are put in an ordered
list. We check every server tick if any of the timers have
elapsed, and execute the function associated with this timer.

We know that many timers by themselves cause new timers to be
added to this list, so we iterate *backwards* over the timer
list. This means that new timers being added while timers are
being executed, can never be executed in the same function pass,
as they are always appended to the table *after* the end of
the table, which we will never reach in the current pass over
all the table elements.

We switch time keeping to minetest.get_us_time(). dtime is
likely unreliable and we have our own high-res timer that we
can fix if it is indeed broken. This removes the need to do
any sort of time keeping.
2016-01-29 01:04:51 -05:00
RealBadAngel
87291ea44a Show infotext with description for item entities 2016-01-18 17:21:41 +00:00
paramat
0bbbc6e13d Liquids: Flow into and destroy 'floodable' nodes
Add new node property 'floodable', default false
Define "air" as floodable = true in C++ and lua
2016-01-07 05:57:19 +00:00
HybridDog
5755c9a439 Fix missing localization for obj 2015-12-20 16:25:33 +01:00
Alex Ford
97908cc656 Add on_secondary_use when right clicking an item in the air 2015-12-02 02:18:44 +00:00
Robert Zenz
0cf15470fc Simplify regex used in check_modname_prefix and other improvements.
Simplified the regex used, added comments and changed the error message
to contain the correct mod name.
2015-11-24 01:49:59 +01:00
Rui
4fd394b657 Log static_spawn error only once 2015-11-21 00:13:28 +01:00
Robert Zenz
0876623aed Add the player name to dropped items
The player name is now added in the field "dropped_by" on the created
entity.
2015-11-12 00:47:11 +01:00
kwolekr
f9e394a466 Improve LuaVoxelManip documentation 2015-11-07 11:59:24 -05:00
kwolekr
c2b5da735e Add callback parameter for core.emerge_area() 2015-11-02 18:43:09 -05:00
Rui914
482c4d69b0 minetest. to core. 2015-10-31 02:28:06 +01:00
BlockMen
eb92bfb030 Check if hitter has inventory when punching item
Fixes #3280
2015-10-25 18:15:31 +01:00
Robert Zenz
c32847838d Add more ways to pass data to check_player_privs
The callback can now be invoked with either the player object or name as
the first parameter, and with either a table or a list of strings, like
this:

    minetest.check_player_privs(player_name, { shout = true, fly = true })
    minetest.check_player_privs(player_name, "shout", "fly")
    minetest.check_player_privs(player, { shout = true, fly = true })
    minetest.check_player_privs(player, "shout", "fly")
2015-10-22 19:55:48 +02:00
ShadowNinja
2139d7d45f Refactor logging
- Add warning log level
- Change debug_log_level setting to enumeration string
- Map Irrlicht log events to MT log events
- Encapsulate log_* functions and global variables into a class, Logger
- Unify dstream with standard logging mechanism
- Unify core.debug() with standard core.log() script API
2015-10-14 01:03:54 -04:00
Rui
7f2cefa093 Localize digprop_err function 2015-10-12 02:05:11 +02:00