Commit Graph

123 Commits

Author SHA1 Message Date
Lars Müller
edc7df5480
core.formspec_escape: Restore backwards compat
Support numbers as arguments by using `string.gsub(text, ...)` instead of `text:gsub(...)` which will coerce `text` to a string
2022-06-06 18:32:28 +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
Zughy
6f0c966877
Remove unused variable WARN_INIT 2022-05-08 19:11:15 +02: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
sfan5
4f6f09590c Free arguments of cancelled minetest.after() jobs 2022-01-19 23:30:18 +01:00
Desour
1965628705 Fix vector.from_string returning a table without vector metatable 2022-01-02 22:15:41 -05:00
Wuzzy
80c3c7e642
Improve error message if using "/help --" (#11796) 2021-12-01 20:22:46 +01:00
sfan5
2b5075f0e2 Move archive extraction in content store to async job 2021-10-07 00:20:01 +02:00
Pedro Gimeno
d7e7ade0f6 Add an option -t to force text output in /help
This also improves detection of whether formspecs are available.
2021-10-01 16:22:05 +02:00
DS
2cefe51d3b
Split vector.new into 3 constructors 2021-09-10 23:16:16 +02:00
Lean Rada
d36dca3aba
Optimize vector length calculations (#11549) 2021-08-27 20:22:35 +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
Vincent Robinson
3560691c0a
Add math.round and fix vector.round (#10803) 2021-04-02 00:18:58 +02:00
Wuzzy
cafad6ac03 Translate builtin (#10693)
This PR is the second attempt to translate builtin.
Server-sent translation files can be added to `builtin/locale/`, whereas client-side translations depend on gettext.
2021-03-05 16:29:48 +01:00
rubenwardy
4db7fb4a3b Replace 'minetest.' with 'core.' in builtin 2021-02-11 10:18:22 +00:00
Lars Mueller
8f72d4b294 Fix minetest.is_nan 2020-12-24 22:07:04 +01:00
tenplus1
34e3ede8ee
Ability to remove minetest.after once set (#10103) 2020-09-23 19:11: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
Paul Ouellette
b16f841756
LuaItemStack: Add __tostring metamethod (#8785)
* LuaItemStack: Add __tostring metamethod

* Clean up LuaItemStack::checkobject
2020-06-09 19:37:25 +02:00
Wuzzy
65a6a316d0 Add minetest.is_creative_enabled 2020-05-29 22:45:40 +02:00
sfan5
11723cffe0 builtin: Move common/async_event.lua to mainmenu/async_event.lua
It only works in the context of the mainmenu.
2020-05-17 21:37:01 +02:00
Yaman Qalieh
6c607e2082
Allow placing auto-rotating nodes on other nodes in on_rightclick (#9859) 2020-05-13 13:57:05 +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
Wuzzy
1441281809
Fix some chatcommands not returning a value (#9503) 2020-03-14 15:01:22 +01:00
Wuzzy
ce8cdc0333
Cleanup global namespace pollution in builtin (#9451) 2020-03-06 20:19:14 +00: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
HybridDog
ea5e231959
Add table.shuffle (#8299) 2020-02-01 16:09:45 +01:00
rubenwardy
1173ff0c13
Add Lua unit tests to builtin using busted (#9184) 2020-01-18 02:09:18 +00:00
HybridDog
f9c7e46a34 Add table.key_value_swap (#9248) 2020-01-04 15:44:48 +01:00
Aaron Suen
0df646e068 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.
2019-10-13 17:11:00 +02:00
Tim Myers
c413eeb026 Also print help commands to chat for server terminal (#8869) 2019-09-19 00:37:56 +02:00
rubenwardy
8e757859d6
Add luacheck to check builtin (#7895) 2019-08-06 19:30:18 +01:00
SmallJoker
3ad9a8f3a9 Builtin: Forward old return values
Was forgotten in 69bf964.
2019-08-02 10:20:41 +02:00
SmallJoker
69bf964241
Add /help formspec for commands and privileges (#8385)
* Trigger for 'all' as well
* Add description textarea, double-click to copy
2019-07-20 18:22:32 +02:00
HybridDog
41229696be Use vector.dot and vector.cross in vector.angle 2019-07-16 21:44:42 +02:00
HybridDog
71db715ba5 Add vector.dot and vector.cross
Mostly copied from MarkuBu's code
2019-07-16 21:44:42 +02:00
DS
ad75dba87b Optimize core.after in a simple way (#8351) 2019-03-27 21:05:50 +01:00
ANAND
d50feb89de core.after: Improve assertion message (#8388) 2019-03-17 10:25:47 +01:00
ANAND
7f1c2b8a00 Builtin: Add vector.angle(). Returns the angle between 2 vectors (#7738) 2019-03-17 02:05:03 +00:00
HybridDog
a7c5dc50e5 Add math.factorial (#8298) 2019-03-05 10:11:21 +01:00
Pierre-Yves Rollo
0e306c0842 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.
2018-11-01 21:07:01 +01:00
Paramat
4a2a11262b
Builtin//misc_helpers: Various fixes (#7737)
Remove unused variable 'seplen'.
Fix 'cparam2'->'param2'.
Do not initialise variable 'p' twice.
2018-09-23 21:06:51 +01:00
Paramat
45e48295d2
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.
2018-05-16 20:49:46 +01:00
rubenwardy
87ad4d8e7f
Add online content repository
Replaces mods and texture pack tabs with a single content tab
2018-04-19 20:14:53 +01:00
SmallJoker
8f827ee680
core.rotate_node: Do not trigger after_place_node (#6900) 2018-03-29 21:44:13 +02:00
you
a6bb2c4ea8 Allow dumping userdata (#7012) 2018-02-08 19:17:06 +01:00