Commit Graph

104 Commits

Author SHA1 Message Date
tenplus1 03cb42f725
Ability to remove minetest.after once set (#10103) 2022-05-21 16:18:00 +02:00
Desour 3ec4ffeb05
Add vector.offset (#10321) 2022-05-21 16:17:58 +02:00
NetherEran 153557e3f7
Some vector functions useful for working with rotations (#9572)
* added vector.rotate

* added vector.forward_from_rotation and vector.up_from_rotation

* added vector.forward_up_to_rotatiton

* fixed some bugs and formatting with vector functions

* shortened name of some new vector functions and added documentation

* made vector.rotate not require a unit vector as axis

* fixed crash with vector.forward_up_to_rot

* renamed new vector functions, made vector.rotate apply a rotation matrix, old vector.rotate is now called vector.rotate_around_axis

* documented vector function changes

* removed some whitespace to appease luacheck

* implemented and fixed optimization of vector.rotate_around_axis by SmallJoker

* added some unit tests for rotation vector functions

* clarified that rotation vectors are in radians and according to the left hand rule

* hopefully appeased luacheck

* renamed rotation_to_horizontal to forward_at_rotation, rotation_to_vertical to up_at_rotation

* handled cases where sin or cos are 0 in rotation vector functions

* added more comments

* clarified documentation of rotation vector functions

* added more unit tests

* changed way in which vector.rotate_around_axis is adjusted for left handed coordinate systems

* made vector.rotate_around_axis actually left handed

* unrolled matrix multiplication

* removed vector.forward_at_rotation and vector.up_at_rotation

* prettified vector.rotate_around_axis, made previous commits not break anything

* removed references to removed vector.forward_at_rotation and vector.up_at_rotation

* removed documentation of removed vector functions

* clarified documentation and fixed styling of rotation vector functions

* restyled comments minorly

* spelling fixes and some hopefully better comments

* allowed 'up' to be missing from vector.directions_to_rotation and removed requirement for unit vectors as arguments

* made vector.rotate_around_axis() right handed again for consistency

* documented previous changes

* made matrix multiplication actually multiply

* renamed vector.directions_to_rotation() to vector.dir_to_rotation()

* optimized a distance comparison

* Fixed potential false positive in unit tests.

Co-authored-by: NetherEran <nethereran@hotmail.com>
2022-05-21 16:17:53 +02:00
Paul Ouellette 81e7460b30
LuaItemStack: Add __tostring metamethod (#8785)
* LuaItemStack: Add __tostring metamethod

* Clean up LuaItemStack::checkobject
2022-05-21 16:17:52 +02:00
Wuzzy b4d042ef54
Add minetest.is_creative_enabled 2022-05-21 16:17:50 +02:00
sfan5 53647bc8e0
builtin: Move common/async_event.lua to mainmenu/async_event.lua
It only works in the context of the mainmenu.
2022-05-21 16:17:45 +02:00
Yaman Qalieh 2f24ef6909
Allow placing auto-rotating nodes on other nodes in on_rightclick (#9859) 2022-05-21 16:17:43 +02:00
HybridDog ddf381bffc
minetest.serialize: Reversible number serialization (#9722)
* minetest.serialize: Reversible number to string conversion

The %a format is not supported in Lua 5.1.
This commit also adds two tests for number serialization.
2022-05-21 16:17:37 +02:00
Wuzzy e45995ad1c
Fix some chatcommands not returning a value (#9503) 2022-05-21 16:17:33 +02:00
Wuzzy 3dc79a8569
Cleanup global namespace pollution in builtin (#9451) 2022-05-21 16:17:32 +02:00
sfan5 7204509308
Fix potential security issue(s), documentation on minetest.deserialize() (#9369)
Also adds an unittest
2022-05-21 16:17:32 +02:00
HybridDog 9c47c36741
Add table.shuffle (#8299) 2022-05-21 16:17:28 +02:00
rubenwardy f81f909463
Add Lua unit tests to builtin using busted (#9184) 2022-05-21 16:17:28 +02:00
HybridDog 6a4a4fb737
Add table.key_value_swap (#9248) 2022-05-21 16:17:27 +02:00
Aaron Suen 0010957299
Fix rotate_node to return the correct itemstack.
All on_* hooks that return an itemstack are NOT guaranteed to
modify and return the original stack.  We cannot count on the
behavior of the existing builtin definitions not to be overridden
by game/mod logic.
2022-05-21 16:17:18 +02:00
Tim Myers d6a5edd1d2
Also print help commands to chat for server terminal (#8869) 2022-05-21 16:17:14 +02:00
rubenwardy d5c162fb03
Add luacheck to check builtin (#7895) 2022-05-21 16:17:08 +02:00
SmallJoker ccfc252728
Builtin: Forward old return values
Was forgotten in 69bf964.
2022-05-21 16:17:07 +02:00
SmallJoker b7d341848b
Add /help formspec for commands and privileges (#8385)
* Trigger for 'all' as well
* Add description textarea, double-click to copy
2022-05-21 16:17:04 +02:00
HybridDog c8730d2591
Use vector.dot and vector.cross in vector.angle 2022-05-21 16:17:03 +02:00
HybridDog 7f7140bae1
Add vector.dot and vector.cross
Mostly copied from MarkuBu's code
2022-05-21 16:17:03 +02:00
Desour aa0ee4cc03
Optimize core.after in a simple way (#8351) 2022-05-21 16:16:58 +02:00
ANAND a07575bd51
core.after: Improve assertion message (#8388) 2022-05-21 16:16:56 +02:00
ANAND 6cf1909254
Builtin: Add vector.angle(). Returns the angle between 2 vectors (#7738) 2022-05-21 16:16:56 +02:00
HybridDog 744d7a14b4
Add math.factorial (#8298) 2022-05-21 16:16:54 +02:00
Pierre-Yves Rollo a1bcc6ba94
Fix string.split returning an empty table if string starts with sepearator (#7827)
Calling string.split(":A:B:C:D", ":") returns an empty array.
This is due to first empty string not making repeat loop decreasing max_split which has a 0 value when reaching until.
Changing max_splits default value from -1 to -2 fixes that issue.
2022-05-21 16:16:23 +02:00
paramat 39398b9ed6
Builtin//misc_helpers: Various fixes (#7737)
Remove unused variable 'seplen'.
Fix 'cparam2'->'param2'.
Do not initialise variable 'p' twice.
2022-05-21 16:16:18 +02:00
paramat cbc774df86
Pointed_thing_to_face_pos: Avoid crash when player is inside a node (#7342)
Avoid crash in some situations when player is inside a node, causing
'above' to equal 'under'.
In this situation return 'under' which is the node position very close
to the face position that would normally be returned.
2022-05-21 16:15:58 +02:00
rubenwardy b744f1d46f
Add online content repository
Replaces mods and texture pack tabs with a single content tab
2022-05-21 16:15:57 +02:00
SmallJoker f2628f1eb4
core.rotate_node: Do not trigger after_place_node (#6900) 2022-05-21 16:15:54 +02:00
HybridDog 0a429927a9
Allow dumping userdata (#7012) 2022-05-21 16:15:47 +02:00
paramat dd112ad6ea
Vector functions: Fix vector.direction() function, improve documentation (#6801)
vector.direction() now returns a normalised vector with direction p1 to p2.
2022-05-21 16:15:39 +02:00
Ezhh 5849b6fc97
Give subgames the ability to disallow specific mapgens (#6792) 2022-05-21 16:15:38 +02:00
paramat c6d98a56e7
Pointed thing to face pos: Use 'eye height' object property (#6754) 2022-05-21 16:15:36 +02:00
SmallJoker b06a8d6016
core.rotate_node: Run callbacks like with any regular placed node (#6648) 2022-05-21 16:15:32 +02:00
DTA7 9b0e13f582
Set placer to nil instead of a non-functional one in item_OnPlace (#6449)
* Set placer to nil instead of a non-functional one

This requires nil checks in core.rotate_node and core.rotate_and_place.
2022-05-21 16:15:23 +02:00
tenplus1 2a3112ab78
Fix Rotate Node Placement (#6424)
This properly checks for creative mode or privilege when using fixed rotate_node() function.
2022-05-21 16:15:22 +02:00
sfan5 10fbc96971
Fix core.wrap_text and make its behaviour consistent with the docs
Code based on initial implementation by @dsohler.
2022-05-21 16:15:19 +02:00
Nathanaël Courant 2a8c81c50e
Add '@n' escape sequences and some documentation on translated strings. 2022-05-21 16:15:12 +02:00
Nathanaël Courant 54fc7afb7e
Add clientside translations. 2022-05-21 16:15:11 +02:00
Gael-de-Sailly dd12312b58
Add minetest.rgba function that returns ColorString from RGBA or RGB values 2022-05-21 16:14:57 +02:00
Ezhh 4bd4d2b3b7
Improve chatcommand params consistency (#5985)
* Fix and improve params consistency

* Move parenthesis requirement to descriptions
2022-05-21 16:14:56 +02:00
red-001 0aaa633975
Fix sending color codes to clients that don't support them. (#5950)
Also remove `disable_escape_sequences` since it's not needed anymore.
2022-05-21 16:14:54 +02:00
red-001 2f8ebed7cc
Add function to get player privileges (#5933)
* [CSM] Add function to get player privileges + move related help functions to common

* Added @Zeno- const
2022-05-21 16:14:52 +02:00
SmallJoker 3fe2935a57
Builtin: Fix subgame mod selection (#5367) 2022-05-21 16:14:48 +02:00
SmallJoker 7b4120ee9f
CSM: Document forgotten functions 2022-05-21 16:14:47 +02:00
SmallJoker 88c24db1a7
minetest.deserialize: Throw error when argument not string (#5738) 2022-05-21 16:14:46 +02:00
ShadowNinja 5030ce5f4b
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.
2022-05-21 16:14:45 +02:00
MarkuBu a99d95ee92
Pointed thing to face pos: Fix crash if opening door with slab or stair
Avoids crash caused when 'pointed thing -under' and '-above' are not
face-neighbours, for example in the case of pointing to the top half
of a door.
2022-05-21 16:14:41 +02:00
red-001 089bca3f7f
Use more gettext (#5553) 2022-05-21 16:14:39 +02:00