Commit Graph

19 Commits

Author SHA1 Message Date
Jude Melton-Houghton e7dd9737bd Reduce `minetest.after` time complexity and provide ordering guarantee
---------

Co-authored-by: Lars Mueller <appgurulars@gmx.de>
2024-01-16 23:46:43 +01:00
AFCMS 68f81ace97
Add `vector.in_area()` utility function (#13390) 2023-04-12 10:46:26 +01:00
Jude Melton-Houghton ab1fe80150
Error when string.split is given empty separator (#13132) 2023-01-10 09:25:48 -05:00
Jude Melton-Houghton b38ffdec27
Implement vector and node conversion in Lua (#12609)
Co-authored-by: sfan5 <sfan5@live.de>
2022-10-18 18:01:44 -04:00
Lars Müller 5a562a597c
Serialization spec: Fix number fuzzing (#12496) 2022-07-02 20:58:23 +01:00
Lars Müller 3eafcab64e
Builtin: Redo serialize.lua (#11427)
Features:

* Support for arbitrary references, including self-referencing
* Short output, references "long" strings as a bonus
* Around the same speed, potentially slower if long, short keys are present
* Properly works with NaN and inf
2022-06-11 20:00:26 +02:00
Lars Müller e8b2954586
Builtin: Optimize misc helpers (#12377)
Also add formspec_escape unit test
2022-05-27 21:40:38 +02:00
Wuzzy ac5e8176b9
Add relative numbers for commands by prepending ~ (#9588)
* Add relative numbers for commands by prepending ~

* Some builtin code cleanup

* Disallow nan and inf in minetest.string_to_area

* Remove unused local variable teleportee (makes Luacheck happy)

* Clean up core.string_to_pos

* Make area parsing less permissive

* Rewrite tests as busted tests

* /time: Fix negative minutes not working

Co-authored-by: Lars Mueller <appgurulars@gmx.de>
2022-05-22 10:28:24 -04:00
Lars Müller ae7664597e
Add vector.combine (#11920) 2022-05-04 07:44:14 -04:00
Jude Melton-Houghton 06d197cdd0
Store vector metatable in registry 2022-03-29 18:07:00 +02:00
Desour 1965628705 Fix vector.from_string returning a table without vector metatable 2022-01-02 22:15:41 -05:00
DS 2cefe51d3b
Split vector.new into 3 constructors 2021-09-10 23:16:16 +02:00
DS 8f085e02a1
Add metatables to lua vectors (#11039)
Add backwards-compatible metatable functions for vectors.
2021-06-04 21:22:33 +02:00
DS 2332527765
Add vector.to_string and vector.from_string (#10323)
Writing vectors as strings is very common and should belong to `vector.*`. `minetest.pos_to_string` is also too long to write, implies that one should only use it for positions and leaves no spaces after the commas.
2021-04-05 15:55:56 +02:00
DS 28e87ce9d5
Add vector.offset (#10321) 2020-08-29 16:41:29 +01:00
NetherEran 7148834440
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>
2020-06-09 19:38:39 +02:00
HybridDog 5355cb1d87
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.
2020-04-22 16:43:48 +02:00
sfan5 8d6a0b917c
Fix potential security issue(s), documentation on minetest.deserialize() (#9369)
Also adds an unittest
2020-03-05 22:03:04 +01:00
rubenwardy 1173ff0c13
Add Lua unit tests to builtin using busted (#9184) 2020-01-18 02:09:18 +00:00