mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Use Lua code blocks in lua_api.md
This commit is contained in:
parent
9c90358912
commit
d197ff0f9d
@ -170,26 +170,28 @@ from the available ones of the following files:
|
|||||||
|
|
||||||
Examples of sound parameter tables:
|
Examples of sound parameter tables:
|
||||||
|
|
||||||
-- Play locationless
|
```lua
|
||||||
{
|
-- Play locationless
|
||||||
gain = 1.0, -- default
|
{
|
||||||
}
|
gain = 1.0, -- default
|
||||||
-- Play locationless, looped
|
}
|
||||||
{
|
-- Play locationless, looped
|
||||||
gain = 1.0, -- default
|
{
|
||||||
loop = true,
|
gain = 1.0, -- default
|
||||||
}
|
loop = true,
|
||||||
-- Play in a location
|
}
|
||||||
{
|
-- Play in a location
|
||||||
pos = {x = 1, y = 2, z = 3},
|
{
|
||||||
gain = 1.0, -- default
|
pos = {x = 1, y = 2, z = 3},
|
||||||
}
|
gain = 1.0, -- default
|
||||||
-- Play connected to an object, looped
|
}
|
||||||
{
|
-- Play connected to an object, looped
|
||||||
object = <an ObjectRef>,
|
{
|
||||||
gain = 1.0, -- default
|
object = <an ObjectRef>,
|
||||||
loop = true,
|
gain = 1.0, -- default
|
||||||
}
|
loop = true,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Looped sounds must either be connected to an object or played locationless.
|
Looped sounds must either be connected to an object or played locationless.
|
||||||
|
|
||||||
@ -205,7 +207,9 @@ Representations of simple things
|
|||||||
|
|
||||||
### Position/vector
|
### Position/vector
|
||||||
|
|
||||||
{x=num, y=num, z=num}
|
```lua
|
||||||
|
{x=num, y=num, z=num}
|
||||||
|
```
|
||||||
|
|
||||||
For helper functions see "Vector helpers".
|
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
|
E.g. A flag field of value
|
||||||
|
|
||||||
{place_center_x = true, place_center_y=false, place_center_z=true}
|
```lua
|
||||||
|
{place_center_x = true, place_center_y=false, place_center_z=true}
|
||||||
|
```
|
||||||
|
|
||||||
is equivalent to
|
is equivalent to
|
||||||
|
|
||||||
{place_center_x = true, noplace_center_y=true, place_center_z=true}
|
```lua
|
||||||
|
{place_center_x = true, noplace_center_y=true, place_center_z=true}
|
||||||
|
```
|
||||||
|
|
||||||
which is equivalent to
|
which is equivalent to
|
||||||
|
|
||||||
"place_center_x, noplace_center_y, place_center_z"
|
```lua
|
||||||
|
"place_center_x, noplace_center_y, place_center_z"
|
||||||
|
```
|
||||||
|
|
||||||
or even
|
or even
|
||||||
|
|
||||||
"place_center_x, place_center_z"
|
```lua
|
||||||
|
"place_center_x, place_center_z"
|
||||||
|
```
|
||||||
|
|
||||||
since, by default, no schematic attributes are set.
|
since, by default, no schematic attributes are set.
|
||||||
|
|
||||||
@ -996,14 +1008,14 @@ Please do not try to access the reference until the camera is initialized, other
|
|||||||
* `get_fov()`
|
* `get_fov()`
|
||||||
* Returns a table with X, Y, maximum and actual FOV in degrees:
|
* Returns a table with X, Y, maximum and actual FOV in degrees:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
x = number,
|
x = number,
|
||||||
y = number,
|
y = number,
|
||||||
max = number,
|
max = number,
|
||||||
actual = number
|
actual = number
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `get_pos()`
|
* `get_pos()`
|
||||||
* Returns position of camera with view bobbing
|
* Returns position of camera with view bobbing
|
||||||
@ -1053,16 +1065,16 @@ Methods:
|
|||||||
* `get_physics_override()`
|
* `get_physics_override()`
|
||||||
* returns:
|
* returns:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
speed = float,
|
speed = float,
|
||||||
jump = float,
|
jump = float,
|
||||||
gravity = float,
|
gravity = float,
|
||||||
sneak = boolean,
|
sneak = boolean,
|
||||||
sneak_glitch = boolean,
|
sneak_glitch = boolean,
|
||||||
new_move = boolean,
|
new_move = boolean,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `get_override_pos()`
|
* `get_override_pos()`
|
||||||
* returns override position
|
* returns override position
|
||||||
@ -1075,38 +1087,38 @@ Methods:
|
|||||||
* `get_movement_acceleration()`
|
* `get_movement_acceleration()`
|
||||||
* returns acceleration of the player in different environments:
|
* returns acceleration of the player in different environments:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
fast = float,
|
fast = float,
|
||||||
air = float,
|
air = float,
|
||||||
default = float,
|
default = float,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `get_movement_speed()`
|
* `get_movement_speed()`
|
||||||
* returns player's speed in different environments:
|
* returns player's speed in different environments:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
walk = float,
|
walk = float,
|
||||||
jump = float,
|
jump = float,
|
||||||
crouch = float,
|
crouch = float,
|
||||||
fast = float,
|
fast = float,
|
||||||
climb = float,
|
climb = float,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `get_movement()`
|
* `get_movement()`
|
||||||
* returns player's movement in different environments:
|
* returns player's movement in different environments:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
liquid_fluidity = float,
|
liquid_fluidity = float,
|
||||||
liquid_sink = float,
|
liquid_sink = float,
|
||||||
liquid_fluidity_smooth = float,
|
liquid_fluidity_smooth = float,
|
||||||
gravity = float,
|
gravity = float,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `get_last_look_horizontal()`:
|
* `get_last_look_horizontal()`:
|
||||||
* returns last look horizontal angle
|
* returns last look horizontal angle
|
||||||
@ -1115,20 +1127,20 @@ Methods:
|
|||||||
* `get_control()`:
|
* `get_control()`:
|
||||||
* returns pressed player controls
|
* returns pressed player controls
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
up = boolean,
|
up = boolean,
|
||||||
down = boolean,
|
down = boolean,
|
||||||
left = boolean,
|
left = boolean,
|
||||||
right = boolean,
|
right = boolean,
|
||||||
jump = boolean,
|
jump = boolean,
|
||||||
aux1 = boolean,
|
aux1 = boolean,
|
||||||
sneak = boolean,
|
sneak = boolean,
|
||||||
zoom = boolean,
|
zoom = boolean,
|
||||||
dig = boolean,
|
dig = boolean,
|
||||||
place = boolean,
|
place = boolean,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `get_armor_groups()`
|
* `get_armor_groups()`
|
||||||
* returns a table with the armor group ratings
|
* returns a table with the armor group ratings
|
||||||
@ -1176,10 +1188,12 @@ Can be obtained via `minetest.get_meta(pos)`.
|
|||||||
A raycast on the map. It works with selection boxes.
|
A raycast on the map. It works with selection boxes.
|
||||||
Can be used as an iterator in a for loop as:
|
Can be used as an iterator in a for loop as:
|
||||||
|
|
||||||
local ray = Raycast(...)
|
```lua
|
||||||
for pointed_thing in ray do
|
local ray = Raycast(...)
|
||||||
...
|
for pointed_thing in ray do
|
||||||
end
|
...
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
The map is loaded as the ray advances. If the map is modified after the
|
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.
|
`Raycast` is created, the changes may or may not have an effect on the object.
|
||||||
@ -1207,97 +1221,100 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
|
|||||||
#### Node Definition
|
#### Node Definition
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
has_on_construct = bool, -- Whether the node has the on_construct callback defined
|
has_on_construct = bool, -- Whether the node has the on_construct callback defined
|
||||||
has_on_destruct = bool, -- Whether the node has the on_destruct callback defined
|
has_on_destruct = bool, -- Whether the node has the on_destruct callback defined
|
||||||
has_after_destruct = bool, -- Whether the node has the after_destruct callback defined
|
has_after_destruct = bool, -- Whether the node has the after_destruct callback defined
|
||||||
name = string, -- The name of the node e.g. "air", "default:dirt"
|
name = string, -- The name of the node e.g. "air", "default:dirt"
|
||||||
groups = table, -- The groups of the node
|
groups = table, -- The groups of the node
|
||||||
paramtype = string, -- Paramtype of the node
|
paramtype = string, -- Paramtype of the node
|
||||||
paramtype2 = string, -- ParamType2 of the node
|
paramtype2 = string, -- ParamType2 of the node
|
||||||
drawtype = string, -- Drawtype of the node
|
drawtype = string, -- Drawtype of the node
|
||||||
mesh = <string>, -- Mesh name if existent
|
mesh = <string>, -- Mesh name if existent
|
||||||
minimap_color = <Color>, -- Color of node on minimap *May not exist*
|
minimap_color = <Color>, -- Color of node on minimap *May not exist*
|
||||||
visual_scale = number, -- Visual scale of node
|
visual_scale = number, -- Visual scale of node
|
||||||
alpha = number, -- Alpha of the node. Only used for liquids
|
alpha = number, -- Alpha of the node. Only used for liquids
|
||||||
color = <Color>, -- Color of node *May not exist*
|
color = <Color>, -- Color of node *May not exist*
|
||||||
palette_name = <string>, -- Filename of palette *May not exist*
|
palette_name = <string>, -- Filename of palette *May not exist*
|
||||||
palette = <{ -- List of colors
|
palette = <{ -- List of colors
|
||||||
Color,
|
Color,
|
||||||
Color
|
Color
|
||||||
}>,
|
}>,
|
||||||
waving = number, -- 0 of not waving, 1 if waving
|
waving = number, -- 0 of not waving, 1 if waving
|
||||||
connect_sides = number, -- Used for connected nodes
|
connect_sides = number, -- Used for connected nodes
|
||||||
connects_to = { -- List of nodes to connect to
|
connects_to = { -- List of nodes to connect to
|
||||||
"node1",
|
"node1",
|
||||||
"node2"
|
"node2"
|
||||||
},
|
},
|
||||||
post_effect_color = Color, -- Color overlayed on the screen when the player is in the node
|
post_effect_color = Color, -- Color overlayed on the screen when the player is in the node
|
||||||
leveled = number, -- Max level for node
|
leveled = number, -- Max level for node
|
||||||
sunlight_propogates = bool, -- Whether light passes through the block
|
sunlight_propogates = bool, -- Whether light passes through the block
|
||||||
light_source = number, -- Light emitted by the block
|
light_source = number, -- Light emitted by the block
|
||||||
is_ground_content = bool, -- Whether caves should cut through the node
|
is_ground_content = bool, -- Whether caves should cut through the node
|
||||||
walkable = bool, -- Whether the player collides with the node
|
walkable = bool, -- Whether the player collides with the node
|
||||||
pointable = bool, -- Whether the player can select the node
|
pointable = bool, -- Whether the player can select the node
|
||||||
diggable = bool, -- Whether the player can dig the node
|
diggable = bool, -- Whether the player can dig the node
|
||||||
climbable = bool, -- Whether the player can climb up the node
|
climbable = bool, -- Whether the player can climb up the node
|
||||||
buildable_to = bool, -- Whether the player can replace the node by placing a node on it
|
buildable_to = bool, -- Whether the player can replace the node by placing a node on it
|
||||||
rightclickable = bool, -- Whether the player can place nodes pointing at this node
|
rightclickable = bool, -- Whether the player can place nodes pointing at this node
|
||||||
damage_per_second = number, -- HP of damage per second when the player is in the node
|
damage_per_second = number, -- HP of damage per second when the player is in the node
|
||||||
liquid_type = <string>, -- A string containing "none", "flowing", or "source" *May not exist*
|
liquid_type = <string>, -- A string containing "none", "flowing", or "source" *May not exist*
|
||||||
liquid_alternative_flowing = <string>, -- Alternative node for liquid *May not exist*
|
liquid_alternative_flowing = <string>, -- Alternative node for liquid *May not exist*
|
||||||
liquid_alternative_source = <string>, -- Alternative node for liquid *May not exist*
|
liquid_alternative_source = <string>, -- Alternative node for liquid *May not exist*
|
||||||
liquid_viscosity = <number>, -- How slow the liquid flows *May not exist*
|
liquid_viscosity = <number>, -- How slow the liquid flows *May not exist*
|
||||||
liquid_renewable = <boolean>, -- Whether the liquid makes an infinite source *May not exist*
|
liquid_renewable = <boolean>, -- Whether the liquid makes an infinite source *May not exist*
|
||||||
liquid_range = <number>, -- How far the liquid flows *May not exist*
|
liquid_range = <number>, -- How far the liquid flows *May not exist*
|
||||||
drowning = bool, -- Whether the player will drown in the node
|
drowning = bool, -- Whether the player will drown in the node
|
||||||
floodable = bool, -- Whether nodes will be replaced by liquids (flooded)
|
floodable = bool, -- Whether nodes will be replaced by liquids (flooded)
|
||||||
node_box = table, -- Nodebox to draw the node with
|
node_box = table, -- Nodebox to draw the node with
|
||||||
collision_box = table, -- Nodebox to set the collision area
|
collision_box = table, -- Nodebox to set the collision area
|
||||||
selection_box = table, -- Nodebox to set the area selected by the player
|
selection_box = table, -- Nodebox to set the area selected by the player
|
||||||
sounds = { -- Table of sounds that the block makes
|
sounds = { -- Table of sounds that the block makes
|
||||||
sound_footstep = SimpleSoundSpec,
|
sound_footstep = SimpleSoundSpec,
|
||||||
sound_dig = SimpleSoundSpec,
|
sound_dig = SimpleSoundSpec,
|
||||||
sound_dug = SimpleSoundSpec
|
sound_dug = SimpleSoundSpec
|
||||||
},
|
},
|
||||||
legacy_facedir_simple = bool, -- Whether to use old facedir
|
legacy_facedir_simple = bool, -- Whether to use old facedir
|
||||||
legacy_wallmounted = bool -- Whether to use old wallmounted
|
legacy_wallmounted = bool -- Whether to use old wallmounted
|
||||||
move_resistance = <number>, -- How slow players can move through the node *May not exist*
|
move_resistance = <number>, -- How slow players can move through the node *May not exist*
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Item Definition
|
#### Item Definition
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
name = string, -- Name of the item e.g. "default:stone"
|
name = string, -- Name of the item e.g. "default:stone"
|
||||||
description = string, -- Description of the item e.g. "Stone"
|
description = string, -- Description of the item e.g. "Stone"
|
||||||
type = string, -- Item type: "none", "node", "craftitem", "tool"
|
type = string, -- Item type: "none", "node", "craftitem", "tool"
|
||||||
inventory_image = string, -- Image in the inventory
|
inventory_image = string, -- Image in the inventory
|
||||||
wield_image = string, -- Image in wieldmesh
|
wield_image = string, -- Image in wieldmesh
|
||||||
palette_image = string, -- Image for palette
|
palette_image = string, -- Image for palette
|
||||||
color = Color, -- Color for item
|
color = Color, -- Color for item
|
||||||
wield_scale = Vector, -- Wieldmesh scale
|
wield_scale = Vector, -- Wieldmesh scale
|
||||||
stack_max = number, -- Number of items stackable together
|
stack_max = number, -- Number of items stackable together
|
||||||
usable = bool, -- Has on_use callback defined
|
usable = bool, -- Has on_use callback defined
|
||||||
liquids_pointable = bool, -- Whether you can point at liquids with the item
|
liquids_pointable = bool, -- Whether you can point at liquids with the item
|
||||||
tool_capabilities = <table>, -- If the item is a tool, tool capabilities of the item
|
tool_capabilities = <table>, -- If the item is a tool, tool capabilities of the item
|
||||||
groups = table, -- Groups of the item
|
groups = table, -- Groups of the item
|
||||||
sound_place = SimpleSoundSpec, -- Sound played when placed
|
sound_place = SimpleSoundSpec, -- Sound played when placed
|
||||||
sound_place_failed = SimpleSoundSpec, -- Sound played when placement failed
|
sound_place_failed = SimpleSoundSpec, -- Sound played when placement failed
|
||||||
node_placement_prediction = string -- Node placed in client until server catches up
|
node_placement_prediction = string -- Node placed in client until server catches up
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
### Chat command definition (`register_chatcommand`)
|
### Chat command definition (`register_chatcommand`)
|
||||||
|
|
||||||
{
|
```lua
|
||||||
params = "<name> <privilege>", -- Short parameter description
|
{
|
||||||
description = "Remove privilege from player", -- Full description
|
params = "<name> <privilege>", -- Short parameter description
|
||||||
func = function(param), -- Called when command is run.
|
description = "Remove privilege from player", -- Full description
|
||||||
-- Returns boolean success and text output.
|
func = function(param), -- Called when command is run.
|
||||||
}
|
-- Returns boolean success and text output.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Server info
|
### Server info
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
@ -1309,29 +1326,30 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
|
|||||||
```
|
```
|
||||||
|
|
||||||
### HUD Definition (`hud_add`, `hud_get`)
|
### HUD Definition (`hud_add`, `hud_get`)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
hud_elem_type = "image", -- see HUD element types, default "text"
|
hud_elem_type = "image", -- see HUD element types, default "text"
|
||||||
-- ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
|
-- ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
|
||||||
position = {x=0.5, y=0.5},
|
position = {x=0.5, y=0.5},
|
||||||
-- ^ Left corner position of element, default `{x=0,y=0}`.
|
-- ^ Left corner position of element, default `{x=0,y=0}`.
|
||||||
name = "<name>", -- default ""
|
name = "<name>", -- default ""
|
||||||
scale = {x=2, y=2}, -- default {x=0,y=0}
|
scale = {x=2, y=2}, -- default {x=0,y=0}
|
||||||
text = "<text>", -- default ""
|
text = "<text>", -- default ""
|
||||||
number = 2, -- default 0
|
number = 2, -- default 0
|
||||||
item = 3, -- default 0
|
item = 3, -- default 0
|
||||||
-- ^ Selected item in inventory. 0 for no item selected.
|
-- ^ Selected item in inventory. 0 for no item selected.
|
||||||
direction = 0, -- default 0
|
direction = 0, -- default 0
|
||||||
-- ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
|
-- ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
|
||||||
alignment = {x=0, y=0}, -- default {x=0, y=0}
|
alignment = {x=0, y=0}, -- default {x=0, y=0}
|
||||||
-- ^ See "HUD Element Types"
|
-- ^ See "HUD Element Types"
|
||||||
offset = {x=0, y=0}, -- default {x=0, y=0}
|
offset = {x=0, y=0}, -- default {x=0, y=0}
|
||||||
-- ^ See "HUD Element Types"
|
-- ^ See "HUD Element Types"
|
||||||
size = { x=100, y=100 }, -- default {x=0, y=0}
|
size = { x=100, y=100 }, -- default {x=0, y=0}
|
||||||
-- ^ Size of element in pixels
|
-- ^ Size of element in pixels
|
||||||
style = 0,
|
style = 0,
|
||||||
-- ^ For "text" elements sets font style: bitfield with 1 = bold, 2 = italic, 4 = monospace
|
-- ^ For "text" elements sets font style: bitfield with 1 = bold, 2 = italic, 4 = monospace
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Escape sequences
|
Escape sequences
|
||||||
@ -1478,55 +1496,59 @@ Same as `image`, but does not accept a `position`; the position is instead deter
|
|||||||
|
|
||||||
### Particle definition (`add_particle`)
|
### Particle definition (`add_particle`)
|
||||||
|
|
||||||
{
|
```lua
|
||||||
pos = {x=0, y=0, z=0},
|
{
|
||||||
velocity = {x=0, y=0, z=0},
|
pos = {x=0, y=0, z=0},
|
||||||
acceleration = {x=0, y=0, z=0},
|
velocity = {x=0, y=0, z=0},
|
||||||
|
acceleration = {x=0, y=0, z=0},
|
||||||
-- ^ Spawn particle at pos with velocity and acceleration
|
-- ^ Spawn particle at pos with velocity and acceleration
|
||||||
expirationtime = 1,
|
expirationtime = 1,
|
||||||
-- ^ Disappears after expirationtime seconds
|
-- ^ Disappears after expirationtime seconds
|
||||||
size = 1,
|
size = 1,
|
||||||
collisiondetection = false,
|
collisiondetection = false,
|
||||||
-- ^ collisiondetection: if true collides with physical objects
|
-- ^ collisiondetection: if true collides with physical objects
|
||||||
collision_removal = false,
|
collision_removal = false,
|
||||||
-- ^ collision_removal: if true then particle is removed when it collides,
|
-- ^ collision_removal: if true then particle is removed when it collides,
|
||||||
-- ^ requires collisiondetection = true to have any effect
|
-- ^ requires collisiondetection = true to have any effect
|
||||||
vertical = false,
|
vertical = false,
|
||||||
-- ^ vertical: if true faces player using y axis only
|
-- ^ vertical: if true faces player using y axis only
|
||||||
texture = "image.png",
|
texture = "image.png",
|
||||||
-- ^ Uses texture (string)
|
-- ^ Uses texture (string)
|
||||||
animation = {Tile Animation definition},
|
animation = {Tile Animation definition},
|
||||||
-- ^ optional, specifies how to animate the particle texture
|
-- ^ optional, specifies how to animate the particle texture
|
||||||
glow = 0
|
glow = 0
|
||||||
-- ^ optional, specify particle self-luminescence in darkness
|
-- ^ optional, specify particle self-luminescence in darkness
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### `ParticleSpawner` definition (`add_particlespawner`)
|
### `ParticleSpawner` definition (`add_particlespawner`)
|
||||||
|
|
||||||
{
|
```lua
|
||||||
amount = 1,
|
{
|
||||||
time = 1,
|
amount = 1,
|
||||||
|
time = 1,
|
||||||
-- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
|
-- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base
|
||||||
minpos = {x=0, y=0, z=0},
|
minpos = {x=0, y=0, z=0},
|
||||||
maxpos = {x=0, y=0, z=0},
|
maxpos = {x=0, y=0, z=0},
|
||||||
minvel = {x=0, y=0, z=0},
|
minvel = {x=0, y=0, z=0},
|
||||||
maxvel = {x=0, y=0, z=0},
|
maxvel = {x=0, y=0, z=0},
|
||||||
minacc = {x=0, y=0, z=0},
|
minacc = {x=0, y=0, z=0},
|
||||||
maxacc = {x=0, y=0, z=0},
|
maxacc = {x=0, y=0, z=0},
|
||||||
minexptime = 1,
|
minexptime = 1,
|
||||||
maxexptime = 1,
|
maxexptime = 1,
|
||||||
minsize = 1,
|
minsize = 1,
|
||||||
maxsize = 1,
|
maxsize = 1,
|
||||||
-- ^ The particle's properties are random values in between the bounds:
|
-- ^ The particle's properties are random values in between the bounds:
|
||||||
-- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
|
-- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration),
|
||||||
-- ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
|
-- ^ minsize/maxsize, minexptime/maxexptime (expirationtime)
|
||||||
collisiondetection = false,
|
collisiondetection = false,
|
||||||
-- ^ collisiondetection: if true uses collision detection
|
-- ^ collisiondetection: if true uses collision detection
|
||||||
collision_removal = false,
|
collision_removal = false,
|
||||||
-- ^ collision_removal: if true then particle is removed when it collides,
|
-- ^ collision_removal: if true then particle is removed when it collides,
|
||||||
-- ^ requires collisiondetection = true to have any effect
|
-- ^ requires collisiondetection = true to have any effect
|
||||||
vertical = false,
|
vertical = false,
|
||||||
-- ^ vertical: if true faces player using y axis only
|
-- ^ vertical: if true faces player using y axis only
|
||||||
texture = "image.png",
|
texture = "image.png",
|
||||||
-- ^ Uses texture (string)
|
-- ^ Uses texture (string)
|
||||||
}
|
}
|
||||||
|
```
|
4132
doc/lua_api.md
4132
doc/lua_api.md
File diff suppressed because it is too large
Load Diff
@ -22,14 +22,16 @@ Gamedata
|
|||||||
|
|
||||||
The "gamedata" table is read when calling `core.start()`. It should contain:
|
The "gamedata" table is read when calling `core.start()`. It should contain:
|
||||||
|
|
||||||
{
|
```lua
|
||||||
playername = <name>,
|
{
|
||||||
password = <password>,
|
playername = <name>,
|
||||||
address = <IP/address>,
|
password = <password>,
|
||||||
port = <port>,
|
address = <IP/address>,
|
||||||
selected_world = <index>, -- 0 for client mode
|
port = <port>,
|
||||||
singleplayer = <true/false>,
|
selected_world = <index>, -- 0 for client mode
|
||||||
}
|
singleplayer = <true/false>,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Functions
|
Functions
|
||||||
@ -116,53 +118,57 @@ HTTP Requests
|
|||||||
|
|
||||||
Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
|
Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
|
||||||
|
|
||||||
{
|
```lua
|
||||||
url = "http://example.org",
|
{
|
||||||
|
url = "http://example.org",
|
||||||
|
|
||||||
timeout = 10,
|
timeout = 10,
|
||||||
-- Timeout for connection in seconds. Default is 3 seconds.
|
-- Timeout for connection in seconds. Default is 3 seconds.
|
||||||
|
|
||||||
post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
|
post_data = "Raw POST request data string" OR {field1 = "data1", field2 = "data2"},
|
||||||
-- Optional, if specified a POST request with post_data is performed.
|
-- Optional, if specified a POST request with post_data is performed.
|
||||||
-- Accepts both a string and a table. If a table is specified, encodes
|
-- Accepts both a string and a table. If a table is specified, encodes
|
||||||
-- table as x-www-form-urlencoded key-value pairs.
|
-- table as x-www-form-urlencoded key-value pairs.
|
||||||
-- If post_data is not specified, a GET request is performed instead.
|
-- If post_data is not specified, a GET request is performed instead.
|
||||||
|
|
||||||
user_agent = "ExampleUserAgent",
|
user_agent = "ExampleUserAgent",
|
||||||
-- Optional, if specified replaces the default minetest user agent with
|
-- Optional, if specified replaces the default minetest user agent with
|
||||||
-- given string
|
-- given string
|
||||||
|
|
||||||
extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
|
extra_headers = { "Accept-Language: en-us", "Accept-Charset: utf-8" },
|
||||||
-- Optional, if specified adds additional headers to the HTTP request.
|
-- Optional, if specified adds additional headers to the HTTP request.
|
||||||
-- You must make sure that the header strings follow HTTP specification
|
-- You must make sure that the header strings follow HTTP specification
|
||||||
-- ("Key: Value").
|
-- ("Key: Value").
|
||||||
|
|
||||||
multipart = boolean
|
multipart = boolean
|
||||||
-- Optional, if true performs a multipart HTTP request.
|
-- Optional, if true performs a multipart HTTP request.
|
||||||
-- Default is false.
|
-- Default is false.
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### `HTTPRequestResult` definition
|
### `HTTPRequestResult` definition
|
||||||
|
|
||||||
Passed to `HTTPApiTable.fetch` callback. Returned by
|
Passed to `HTTPApiTable.fetch` callback. Returned by
|
||||||
`HTTPApiTable.fetch_async_get`.
|
`HTTPApiTable.fetch_async_get`.
|
||||||
|
|
||||||
{
|
```lua
|
||||||
completed = true,
|
{
|
||||||
-- If true, the request has finished (either succeeded, failed or timed
|
completed = true,
|
||||||
-- out)
|
-- If true, the request has finished (either succeeded, failed or timed
|
||||||
|
-- out)
|
||||||
|
|
||||||
succeeded = true,
|
succeeded = true,
|
||||||
-- If true, the request was successful
|
-- If true, the request was successful
|
||||||
|
|
||||||
timeout = false,
|
timeout = false,
|
||||||
-- If true, the request timed out
|
-- If true, the request timed out
|
||||||
|
|
||||||
code = 200,
|
code = 200,
|
||||||
-- HTTP status code
|
-- HTTP status code
|
||||||
|
|
||||||
data = "response"
|
data = "response"
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Formspec
|
Formspec
|
||||||
@ -209,38 +215,40 @@ GUI
|
|||||||
* name of current renderer, e.g. "OpenGL 4.6"
|
* name of current renderer, e.g. "OpenGL 4.6"
|
||||||
* `core.get_window_info()`: Same as server-side `get_player_window_information` API.
|
* `core.get_window_info()`: Same as server-side `get_player_window_information` API.
|
||||||
|
|
||||||
-- Note that none of these things are constant, they are likely to change
|
```lua
|
||||||
-- as the player resizes the window and moves it between monitors
|
-- Note that none of these things are constant, they are likely to change
|
||||||
|
-- as the player resizes the window and moves it between monitors
|
||||||
|
--
|
||||||
|
-- real_gui_scaling and real_hud_scaling can be used instead of DPI.
|
||||||
|
-- OSes don't necessarily give the physical DPI, as they may allow user configuration.
|
||||||
|
-- real_*_scaling is just OS DPI / 96 but with another level of user configuration.
|
||||||
|
{
|
||||||
|
-- Current size of the in-game render target.
|
||||||
--
|
--
|
||||||
-- real_gui_scaling and real_hud_scaling can be used instead of DPI.
|
-- This is usually the window size, but may be smaller in certain situations,
|
||||||
-- OSes don't necessarily give the physical DPI, as they may allow user configuration.
|
-- such as side-by-side mode.
|
||||||
-- real_*_scaling is just OS DPI / 96 but with another level of user configuration.
|
size = {
|
||||||
{
|
x = 1308,
|
||||||
-- Current size of the in-game render target.
|
y = 577,
|
||||||
--
|
},
|
||||||
-- This is usually the window size, but may be smaller in certain situations,
|
|
||||||
-- such as side-by-side mode.
|
|
||||||
size = {
|
|
||||||
x = 1308,
|
|
||||||
y = 577,
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Estimated maximum formspec size before Minetest will start shrinking the
|
-- Estimated maximum formspec size before Minetest will start shrinking the
|
||||||
-- formspec to fit. For a fullscreen formspec, use a size 10-20% larger than
|
-- formspec to fit. For a fullscreen formspec, use a size 10-20% larger than
|
||||||
-- this and `padding[-0.01,-0.01]`.
|
-- this and `padding[-0.01,-0.01]`.
|
||||||
max_formspec_size = {
|
max_formspec_size = {
|
||||||
x = 20,
|
x = 20,
|
||||||
y = 11.25
|
y = 11.25
|
||||||
},
|
},
|
||||||
|
|
||||||
-- GUI Scaling multiplier
|
-- GUI Scaling multiplier
|
||||||
-- Equal to the setting `gui_scaling` multiplied by `dpi / 96`
|
-- Equal to the setting `gui_scaling` multiplied by `dpi / 96`
|
||||||
real_gui_scaling = 1,
|
real_gui_scaling = 1,
|
||||||
|
|
||||||
-- HUD Scaling multiplier
|
-- HUD Scaling multiplier
|
||||||
-- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
|
-- Equal to the setting `hud_scaling` multiplied by `dpi / 96`
|
||||||
real_hud_scaling = 1,
|
real_hud_scaling = 1,
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -262,7 +270,7 @@ Package - content which is downloadable from the content db, may or may not be i
|
|||||||
|
|
||||||
Ex:
|
Ex:
|
||||||
|
|
||||||
```
|
```lua
|
||||||
{
|
{
|
||||||
mods = "/home/user/.minetest/mods",
|
mods = "/home/user/.minetest/mods",
|
||||||
share = "/usr/share/minetest/mods",
|
share = "/usr/share/minetest/mods",
|
||||||
@ -281,42 +289,45 @@ 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)
|
* `core.get_games()` -> table of all games (possible in async calls)
|
||||||
* `name` in return value is deprecated, use `title` instead.
|
* `name` in return value is deprecated, use `title` instead.
|
||||||
* returns a table (ipairs) with values:
|
* returns a table (ipairs) with values:
|
||||||
|
```lua
|
||||||
{
|
{
|
||||||
id = <id>,
|
id = <id>,
|
||||||
path = <full path to game>,
|
path = <full path to game>,
|
||||||
gamemods_path = <path>,
|
gamemods_path = <path>,
|
||||||
title = <title of game>,
|
title = <title of game>,
|
||||||
menuicon_path = <full path to menuicon>,
|
menuicon_path = <full path to menuicon>,
|
||||||
author = "author",
|
author = "author",
|
||||||
DEPRECATED:
|
--DEPRECATED:
|
||||||
addon_mods_paths = {[1] = <path>,},
|
addon_mods_paths = {[1] = <path>,},
|
||||||
}
|
}
|
||||||
|
```
|
||||||
* `core.get_content_info(path)`
|
* `core.get_content_info(path)`
|
||||||
* returns
|
* returns
|
||||||
|
```lua
|
||||||
{
|
{
|
||||||
name = "technical_id",
|
name = "technical_id",
|
||||||
type = "mod" or "modpack" or "game" or "txp",
|
type = "mod" or "modpack" or "game" or "txp",
|
||||||
title = "Human readable title",
|
title = "Human readable title",
|
||||||
description = "description",
|
description = "description",
|
||||||
author = "author",
|
author = "author",
|
||||||
path = "path/to/content",
|
path = "path/to/content",
|
||||||
depends = {"mod", "names"}, -- mods only
|
depends = {"mod", "names"}, -- mods only
|
||||||
optional_depends = {"mod", "names"}, -- mods only
|
optional_depends = {"mod", "names"}, -- mods only
|
||||||
}
|
}
|
||||||
|
```
|
||||||
* `core.check_mod_configuration(world_path, mod_paths)`
|
* `core.check_mod_configuration(world_path, mod_paths)`
|
||||||
* Checks whether configuration is valid.
|
* Checks whether configuration is valid.
|
||||||
* `world_path`: path to the world
|
* `world_path`: path to the world
|
||||||
* `mod_paths`: list of enabled mod paths
|
* `mod_paths`: list of enabled mod paths
|
||||||
* returns:
|
* returns:
|
||||||
|
```lua
|
||||||
{
|
{
|
||||||
is_consistent = true, -- true is consistent, false otherwise
|
is_consistent = true, -- true is consistent, false otherwise
|
||||||
unsatisfied_mods = {}, -- list of mod specs
|
unsatisfied_mods = {}, -- list of mod specs
|
||||||
satisfied_mods = {}, -- list of mod specs
|
satisfied_mods = {}, -- list of mod specs
|
||||||
error_message = "", -- message or nil
|
error_message = "", -- message or nil
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Logging
|
Logging
|
||||||
-------
|
-------
|
||||||
@ -346,14 +357,15 @@ Worlds
|
|||||||
|
|
||||||
* `core.get_worlds()` -> list of worlds (possible in async calls)
|
* `core.get_worlds()` -> list of worlds (possible in async calls)
|
||||||
* returns
|
* returns
|
||||||
|
```lua
|
||||||
{
|
{
|
||||||
[1] = {
|
[1] = {
|
||||||
path = <full path to world>,
|
path = <full path to world>,
|
||||||
name = <name of world>,
|
name = <name of world>,
|
||||||
gameid = <gameid of world>,
|
gameid = <gameid of world>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
```
|
||||||
* `core.create_world(worldname, gameid, init_settings)`
|
* `core.create_world(worldname, gameid, init_settings)`
|
||||||
* `core.delete_world(index)`
|
* `core.delete_world(index)`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user