forked from Mirrorlandia_minetest/minetest
Use Lua code blocks in lua_api.md
This commit is contained in:
parent
9c90358912
commit
d197ff0f9d
@ -170,6 +170,7 @@ from the available ones of the following files:
|
||||
|
||||
Examples of sound parameter tables:
|
||||
|
||||
```lua
|
||||
-- Play locationless
|
||||
{
|
||||
gain = 1.0, -- default
|
||||
@ -190,6 +191,7 @@ Examples of sound parameter tables:
|
||||
gain = 1.0, -- default
|
||||
loop = true,
|
||||
}
|
||||
```
|
||||
|
||||
Looped sounds must either be connected to an object or played locationless.
|
||||
|
||||
@ -205,7 +207,9 @@ Representations of simple things
|
||||
|
||||
### Position/vector
|
||||
|
||||
```lua
|
||||
{x=num, y=num, z=num}
|
||||
```
|
||||
|
||||
For helper functions see "Vector helpers".
|
||||
|
||||
@ -231,19 +235,27 @@ is present, mapped to a boolean of any value, the specified flag is unset.
|
||||
|
||||
E.g. A flag field of value
|
||||
|
||||
```lua
|
||||
{place_center_x = true, place_center_y=false, place_center_z=true}
|
||||
```
|
||||
|
||||
is equivalent to
|
||||
|
||||
```lua
|
||||
{place_center_x = true, noplace_center_y=true, place_center_z=true}
|
||||
```
|
||||
|
||||
which is equivalent to
|
||||
|
||||
```lua
|
||||
"place_center_x, noplace_center_y, place_center_z"
|
||||
```
|
||||
|
||||
or even
|
||||
|
||||
```lua
|
||||
"place_center_x, place_center_z"
|
||||
```
|
||||
|
||||
since, by default, no schematic attributes are set.
|
||||
|
||||
@ -1176,10 +1188,12 @@ Can be obtained via `minetest.get_meta(pos)`.
|
||||
A raycast on the map. It works with selection boxes.
|
||||
Can be used as an iterator in a for loop as:
|
||||
|
||||
```lua
|
||||
local ray = Raycast(...)
|
||||
for pointed_thing in ray do
|
||||
...
|
||||
end
|
||||
```
|
||||
|
||||
The map is loaded as the ray advances. If the map is modified after the
|
||||
`Raycast` is created, the changes may or may not have an effect on the object.
|
||||
@ -1292,12 +1306,15 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
|
||||
|
||||
### Chat command definition (`register_chatcommand`)
|
||||
|
||||
```lua
|
||||
{
|
||||
params = "<name> <privilege>", -- Short parameter description
|
||||
description = "Remove privilege from player", -- Full description
|
||||
func = function(param), -- Called when command is run.
|
||||
-- Returns boolean success and text output.
|
||||
}
|
||||
```
|
||||
|
||||
### Server info
|
||||
```lua
|
||||
{
|
||||
@ -1309,6 +1326,7 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
|
||||
```
|
||||
|
||||
### HUD Definition (`hud_add`, `hud_get`)
|
||||
|
||||
```lua
|
||||
{
|
||||
hud_elem_type = "image", -- see HUD element types, default "text"
|
||||
@ -1478,6 +1496,7 @@ Same as `image`, but does not accept a `position`; the position is instead deter
|
||||
|
||||
### Particle definition (`add_particle`)
|
||||
|
||||
```lua
|
||||
{
|
||||
pos = {x=0, y=0, z=0},
|
||||
velocity = {x=0, y=0, z=0},
|
||||
@ -1500,9 +1519,11 @@ Same as `image`, but does not accept a `position`; the position is instead deter
|
||||
glow = 0
|
||||
-- ^ optional, specify particle self-luminescence in darkness
|
||||
}
|
||||
```
|
||||
|
||||
### `ParticleSpawner` definition (`add_particlespawner`)
|
||||
|
||||
```lua
|
||||
{
|
||||
amount = 1,
|
||||
time = 1,
|
||||
@ -1530,3 +1551,4 @@ Same as `image`, but does not accept a `position`; the position is instead deter
|
||||
texture = "image.png",
|
||||
-- ^ Uses texture (string)
|
||||
}
|
||||
```
|
202
doc/lua_api.md
202
doc/lua_api.md
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,7 @@ Gamedata
|
||||
|
||||
The "gamedata" table is read when calling `core.start()`. It should contain:
|
||||
|
||||
```lua
|
||||
{
|
||||
playername = <name>,
|
||||
password = <password>,
|
||||
@ -30,6 +31,7 @@ The "gamedata" table is read when calling `core.start()`. It should contain:
|
||||
selected_world = <index>, -- 0 for client mode
|
||||
singleplayer = <true/false>,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Functions
|
||||
@ -116,6 +118,7 @@ HTTP Requests
|
||||
|
||||
Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
|
||||
|
||||
```lua
|
||||
{
|
||||
url = "http://example.org",
|
||||
|
||||
@ -141,12 +144,14 @@ Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
|
||||
-- Optional, if true performs a multipart HTTP request.
|
||||
-- Default is false.
|
||||
}
|
||||
```
|
||||
|
||||
### `HTTPRequestResult` definition
|
||||
|
||||
Passed to `HTTPApiTable.fetch` callback. Returned by
|
||||
`HTTPApiTable.fetch_async_get`.
|
||||
|
||||
```lua
|
||||
{
|
||||
completed = true,
|
||||
-- If true, the request has finished (either succeeded, failed or timed
|
||||
@ -163,6 +168,7 @@ Passed to `HTTPApiTable.fetch` callback. Returned by
|
||||
|
||||
data = "response"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Formspec
|
||||
@ -209,6 +215,7 @@ GUI
|
||||
* name of current renderer, e.g. "OpenGL 4.6"
|
||||
* `core.get_window_info()`: Same as server-side `get_player_window_information` API.
|
||||
|
||||
```lua
|
||||
-- Note that none of these things are constant, they are likely to change
|
||||
-- as the player resizes the window and moves it between monitors
|
||||
--
|
||||
@ -241,6 +248,7 @@ GUI
|
||||
-- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
|
||||
real_hud_scaling = 1,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
@ -262,7 +270,7 @@ Package - content which is downloadable from the content db, may or may not be i
|
||||
|
||||
Ex:
|
||||
|
||||
```
|
||||
```lua
|
||||
{
|
||||
mods = "/home/user/.minetest/mods",
|
||||
share = "/usr/share/minetest/mods",
|
||||
@ -281,7 +289,7 @@ Package - content which is downloadable from the content db, may or may not be i
|
||||
* `core.get_games()` -> table of all games (possible in async calls)
|
||||
* `name` in return value is deprecated, use `title` instead.
|
||||
* returns a table (ipairs) with values:
|
||||
|
||||
```lua
|
||||
{
|
||||
id = <id>,
|
||||
path = <full path to game>,
|
||||
@ -289,12 +297,13 @@ Package - content which is downloadable from the content db, may or may not be i
|
||||
title = <title of game>,
|
||||
menuicon_path = <full path to menuicon>,
|
||||
author = "author",
|
||||
DEPRECATED:
|
||||
--DEPRECATED:
|
||||
addon_mods_paths = {[1] = <path>,},
|
||||
}
|
||||
```
|
||||
* `core.get_content_info(path)`
|
||||
* returns
|
||||
|
||||
```lua
|
||||
{
|
||||
name = "technical_id",
|
||||
type = "mod" or "modpack" or "game" or "txp",
|
||||
@ -305,18 +314,20 @@ Package - content which is downloadable from the content db, may or may not be i
|
||||
depends = {"mod", "names"}, -- mods only
|
||||
optional_depends = {"mod", "names"}, -- mods only
|
||||
}
|
||||
```
|
||||
* `core.check_mod_configuration(world_path, mod_paths)`
|
||||
* Checks whether configuration is valid.
|
||||
* `world_path`: path to the world
|
||||
* `mod_paths`: list of enabled mod paths
|
||||
* returns:
|
||||
|
||||
```lua
|
||||
{
|
||||
is_consistent = true, -- true is consistent, false otherwise
|
||||
unsatisfied_mods = {}, -- list of mod specs
|
||||
satisfied_mods = {}, -- list of mod specs
|
||||
error_message = "", -- message or nil
|
||||
}
|
||||
```
|
||||
|
||||
Logging
|
||||
-------
|
||||
@ -346,7 +357,7 @@ Worlds
|
||||
|
||||
* `core.get_worlds()` -> list of worlds (possible in async calls)
|
||||
* returns
|
||||
|
||||
```lua
|
||||
{
|
||||
[1] = {
|
||||
path = <full path to world>,
|
||||
@ -354,6 +365,7 @@ Worlds
|
||||
gameid = <gameid of world>,
|
||||
},
|
||||
}
|
||||
```
|
||||
* `core.create_world(worldname, gameid, init_settings)`
|
||||
* `core.delete_world(index)`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user