Skip to content

Commit 0120fe1

Browse files
SmallJokerparamat
authored andcommittedMay 16, 2017
CSM: Document forgotten functions
1 parent fd32005 commit 0120fe1

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed
 

‎builtin/common/misc_helpers.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ function core.formspec_escape(text)
308308
end
309309

310310

311-
function core.splittext(text,charlimit)
311+
function core.wrap_text(text, charlimit)
312312
local retval = {}
313313

314314
local current_idx = 1

‎builtin/mainmenu/common.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ end
250250

251251
--------------------------------------------------------------------------------
252252
function text2textlist(xpos, ypos, width, height, tl_name, textlen, text, transparency)
253-
local textlines = core.splittext(text, textlen)
253+
local textlines = core.wrap_text(text, textlen)
254254
local retval = "textlist[" .. xpos .. "," .. ypos .. ";" .. width ..
255255
"," .. height .. ";" .. tl_name .. ";"
256256

‎builtin/mainmenu/tab_mods.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ local function get_formspec(tabview, name, tabdata)
7575
if error == nil then
7676
local descriptiontext = descriptionfile:read("*all")
7777

78-
descriptionlines = core.splittext(descriptiontext,42)
78+
descriptionlines = core.wrap_text(descriptiontext, 42)
7979
descriptionfile:close()
8080
else
8181
descriptionlines = {}

‎doc/client_lua_api.md

+37-4
Original file line numberDiff line numberDiff line change
@@ -590,17 +590,24 @@ Helper functions
590590
* `math.sign(x, tolerance)`
591591
* Get the sign of a number.
592592
Optional: Also returns `0` when the absolute value is within the tolerance (default: `0`)
593-
* `string.split(str, separator=",", include_empty=false, max_splits=-1,
594-
* sep_is_pattern=false)`
593+
* `string.split(str, separator=",", include_empty=false, max_splits=-1, sep_is_pattern=false)`
595594
* If `max_splits` is negative, do not limit splits.
596595
* `sep_is_pattern` specifies if separator is a plain string or a pattern (regex).
597596
* e.g. `string:split("a,b", ",") == {"a","b"}`
598597
* `string:trim()`
599598
* e.g. `string.trim("\n \t\tfoo bar\t ") == "foo bar"`
599+
* `minetest.wrap_text(str, limit)`: returns a string
600+
* Adds new lines to the string to keep it within the specified character limit
601+
* limit: Maximal amount of characters in one line
602+
* `minetest.pos_to_string({x=X,y=Y,z=Z}, decimal_places))`: returns string `"(X,Y,Z)"`
603+
* Convert position to a printable string
604+
Optional: 'decimal_places' will round the x, y and z of the pos to the given decimal place.
605+
* `minetest.string_to_pos(string)`: returns a position
606+
* Same but in reverse. Returns `nil` if the string can't be parsed to a position.
607+
* `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions
608+
* Converts a string representing an area box into two positions
600609
* `minetest.is_yes(arg)`
601610
* returns whether `arg` can be interpreted as yes
602-
* `minetest.get_us_time()`
603-
* returns time with microsecond precision. May not return wall time.
604611
* `table.copy(table)`: returns a table
605612
* returns a deep copy of `table`
606613

@@ -649,6 +656,8 @@ Call these functions only at load time!
649656
* Return `true` to mark the message as handled, which means that it will not be sent to server
650657
* `minetest.register_chatcommand(cmd, chatcommand definition)`
651658
* Adds definition to minetest.registered_chatcommands
659+
* `minetest.unregister_chatcommand(name)`
660+
* Unregisters a chatcommands registered with register_chatcommand.
652661
* `minetest.register_on_death(func())`
653662
* Called when the local player dies
654663
* `minetest.register_on_hp_modification(func(hp))`
@@ -683,6 +692,12 @@ Call these functions only at load time!
683692
* `minetest.after(time, func, ...)`
684693
* Call the function `func` after `time` seconds, may be fractional
685694
* Optional: Variable number of arguments that are passed to `func`
695+
* `minetest.get_us_time()`
696+
* Returns time with microsecond precision. May not return wall time.
697+
* `minetest.get_day_count()`
698+
* Returns number days elapsed since world was created, accounting for time changes.
699+
* `minetest.get_timeofday()`
700+
* Returns the time of day: `0` for midnight, `0.5` for midday
686701

687702
### Map
688703
* `minetest.get_node(pos)`
@@ -691,8 +706,17 @@ Call these functions only at load time!
691706
for unloaded areas.
692707
* `minetest.get_node_or_nil(pos)`
693708
* Same as `get_node` but returns `nil` for unloaded areas.
709+
* `minetest.find_node_near(pos, radius, nodenames, [search_center])`: returns pos or `nil`
710+
* `radius`: using a maximum metric
711+
* `nodenames`: e.g. `{"ignore", "group:tree"}` or `"default:dirt"`
712+
* `search_center` is an optional boolean (default: `false`)
713+
If true `pos` is also checked for the nodes
694714
* `minetest.get_meta(pos)`
695715
* Get a `NodeMetaRef` at that position
716+
* `minetest.get_node_level(pos)`
717+
* get level of leveled node (water, snow)
718+
* `minetest.get_node_max_level(pos)`
719+
* get max available level for leveled node
696720

697721
### Player
698722
* `minetest.get_wielded_item()`
@@ -710,6 +734,13 @@ Call these functions only at load time!
710734
* Take a screenshot.
711735
* `minetest.get_server_info()`
712736
* Returns [server info](#server-info).
737+
* `minetest.send_respawn()`
738+
* Sends a respawn request to the server.
739+
740+
### Storage API
741+
* `minetest.get_mod_storage()`:
742+
* returns reference to mod private `StorageRef`
743+
* must be called during mod load time
713744

714745
### Misc.
715746
* `minetest.parse_json(string[, nullvalue])`: returns something
@@ -763,6 +794,8 @@ Call these functions only at load time!
763794
* same as fgettext_ne(), but calls minetest.formspec_escape before returning result
764795
* `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a position
765796
* returns the exact position on the surface of a pointed node
797+
* `minetest.global_exists(name)`
798+
* Checks if a global variable has been set, without triggering a warning.
766799

767800
### UI
768801
* `minetest.ui.minimap`

‎doc/lua_api.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,10 @@ Helper functions
19311931
* e.g. `string:split("a,b", ",") == {"a","b"}`
19321932
* `string:trim()`
19331933
* e.g. `string.trim("\n \t\tfoo bar\t ") == "foo bar"`
1934-
* `minetest.pos_to_string({x=X,y=Y,z=Z}, decimal_places))`: returns `"(X,Y,Z)"`
1934+
* `minetest.wrap_text(str, limit)`: returns a string
Has conversations. Original line has conversations.
1935+
* Adds new lines to the string to keep it within the specified character limit
1936+
* limit: Maximal amount of characters in one line
1937+
* `minetest.pos_to_string({x=X,y=Y,z=Z}, decimal_places))`: returns string `"(X,Y,Z)"`
19351938
* Convert position to a printable string
19361939
Optional: 'decimal_places' will round the x, y and z of the pos to the given decimal place.
19371940
* `minetest.string_to_pos(string)`: returns a position

0 commit comments

Comments
 (0)
Please sign in to comment.