[docs] Lua API overview removed. Reorganized doc pages.
This commit is contained in:
parent
81c98d664a
commit
123df8b5f8
@ -26,7 +26,9 @@ The long-term goal of this project is to provide a viable alternative to Minecra
|
||||
- [Getting started](https://github.com/Unarelith/OpenMiner/wiki/Getting-Started)
|
||||
- [Contributing](https://github.com/Unarelith/OpenMiner/blob/master/CONTRIBUTING.md)
|
||||
- [Coding style](https://github.com/Unarelith/OpenMiner/wiki/Coding-Style)
|
||||
- [Lua API](https://openminer.readthedocs.io/en/latest/lua-api-overview/)
|
||||
- Lua API
|
||||
- [Core API](https://openminer.readthedocs.io/en/latest/lua-api-core/)
|
||||
- [Mod API](https://openminer.readthedocs.io/en/latest/lua-api-mod/)
|
||||
- [Block](https://openminer.readthedocs.io/en/latest/lua-api-block/)
|
||||
- [Item](https://openminer.readthedocs.io/en/latest/lua-api-item/)
|
||||
- [Recipe](https://openminer.readthedocs.io/en/latest/lua-api-recipe/)
|
||||
@ -34,6 +36,7 @@ The long-term goal of this project is to provide a viable alternative to Minecra
|
||||
- [Tree](https://openminer.readthedocs.io/en/latest/lua-api-tree/)
|
||||
- [Biome](https://openminer.readthedocs.io/en/latest/lua-api-biome/)
|
||||
- [Dimension](https://openminer.readthedocs.io/en/latest/lua-api-dimension/)
|
||||
- [GUI API](https://openminer.readthedocs.io/en/latest/lua-api-gui/)
|
||||
- [Network Protocol](https://github.com/Unarelith/OpenMiner/wiki/Network-Protocol)
|
||||
|
||||
## Keys
|
||||
|
@ -10,7 +10,9 @@
|
||||
- [Getting Started](https://github.com/Unarelith/OpenMiner/wiki/Getting-Started)
|
||||
- [Contributing](https://github.com/Unarelith/OpenMiner/blob/master/CONTRIBUTING.md)
|
||||
- [Coding Style](https://github.com/Unarelith/OpenMiner/wiki/Coding-Style)
|
||||
- [Lua API](lua-api-overview.md)
|
||||
- Lua API
|
||||
- [Core API](lua-api-core.md)
|
||||
- [Mod API](lua-api-mod.md)
|
||||
- [Block](lua-api-block.md)
|
||||
- [Item](lua-api-item.md)
|
||||
- [Recipe](lua-api-recipe.md)
|
||||
@ -18,6 +20,7 @@
|
||||
- [Tree](lua-api-tree.md)
|
||||
- [Biome](lua-api-biome.md)
|
||||
- [Dimension](lua-api-dimension.md)
|
||||
- [GUI API](lua-api-gui.md)
|
||||
- [Network Protocol](https://github.com/Unarelith/OpenMiner/wiki/Network-Protocol)
|
||||
|
||||
## Other
|
||||
|
30
docs/lua-api-core.md
Normal file
30
docs/lua-api-core.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Lua API: Core API
|
||||
|
||||
## Functions
|
||||
|
||||
### `openminer:registry()`
|
||||
|
||||
This function returns the `Registry` instance of the server.
|
||||
|
||||
### `openminer:add_listener(event_type, listener)`
|
||||
|
||||
Adds a listener to a specific type of event.
|
||||
|
||||
Example:
|
||||
```lua
|
||||
openminer:add_listener(EventType.OnBlockPlaced, function(pos, player, world, client, server)
|
||||
server:send_chat_message(0, "Block placed at " .. pos.x .. ";" .. pos.y .. ";" .. pos.z .. " by Client" .. player:client_id(), client);
|
||||
end)
|
||||
|
||||
openminer:add_listener(EventType.OnBlockActivated, function(pos, block, player, world, client, server)
|
||||
if block:string_id() == "default:portal" then
|
||||
server:send_chat_message(0, "Swoosh! Changing dimension...", client);
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
Possible events:
|
||||
|
||||
- `OnBlockPlaced`: `funcion(pos, player, world, client, server)`
|
||||
- `OnBlockActivated`: `function(pos, block, player, world, client, server)`
|
||||
|
112
docs/lua-api-cpp.md
Normal file
112
docs/lua-api-cpp.md
Normal file
@ -0,0 +1,112 @@
|
||||
# Lua API: C++ classes in Lua
|
||||
|
||||
**Note:** This page is currently really basic but it will be extended later.
|
||||
|
||||
## Block
|
||||
|
||||
- `u16 id()`
|
||||
- `u16 data()`
|
||||
- `string string_id()`
|
||||
- `string label()`
|
||||
- `stirng mod_name()`
|
||||
- `bool is_opaque()`
|
||||
|
||||
## BlockData
|
||||
|
||||
- `Inventory *inventory`
|
||||
- `BlockMetadata *meta`
|
||||
- `bool use_alt_tiles`
|
||||
|
||||
## BlockMetadata
|
||||
|
||||
- `string get_string(string attribute)`
|
||||
- `void set_string(string attribute, string value)`
|
||||
- `int get_int(string attribute)`
|
||||
- `void set_int(string attribute, int value)`
|
||||
|
||||
## Chunk
|
||||
|
||||
- `u16 get_block(int x, int y, int z)`
|
||||
- `void set_block(int x, int y, int z, u16 block)`
|
||||
- `u16 get_data(int x, int y, int z)`
|
||||
- `void set_data(int x, int y, int z, u16 data)`
|
||||
- `BlockData *add_block_data(int x, int y, int z, int inventoryWidth, int inventoryHeight)`
|
||||
- `BlockData *get_block_data(int x, int y, int z)`
|
||||
|
||||
## ClientInfo
|
||||
|
||||
- `u16 id()`
|
||||
|
||||
## Inventory
|
||||
|
||||
- `void add_stack(string name, u16 amount)`
|
||||
- `ItemStack get_stack(u16 x, u16 y)`
|
||||
- `void set_stack(u16 x, u16 y, string name, u16 amount)`
|
||||
|
||||
## Item
|
||||
|
||||
- `u16 id()`
|
||||
- `string name()`
|
||||
- `u16 burn_time()`
|
||||
- `bool is_fuel()`
|
||||
|
||||
## ItemStack
|
||||
|
||||
- `u16 amount()`
|
||||
- `Item item()`
|
||||
|
||||
## ivec3
|
||||
|
||||
- `int x`
|
||||
- `int y`
|
||||
- `int z`
|
||||
|
||||
## Player
|
||||
|
||||
- `Inventory *inventory()`
|
||||
- `double x()`
|
||||
- `double y()`
|
||||
- `double z()`
|
||||
- `void set_position(double x, double y, double z)`
|
||||
- `u16 dimension()`
|
||||
- `void set_dimension(u16 dimension)`
|
||||
- `u16 client_id()`
|
||||
|
||||
## Recipe
|
||||
|
||||
- `string type()`
|
||||
- `ItemStack result()`
|
||||
|
||||
## Registry
|
||||
|
||||
- `Block get_block(u16 id)`
|
||||
- `Item get_item(u16 id)`
|
||||
- `Sky get_sky(u16 id)`
|
||||
- `Tree get_tree(u16 id)`
|
||||
- `Biome get_biome(u16 id)`
|
||||
- `Recipe get_recipe(Inventory crafting_inventory)`
|
||||
- `Block get_block_from_string(string id)`
|
||||
- `Item get_item_from_string(string id)`
|
||||
- `Sky get_sky_from_string(string id)`
|
||||
- `Tree get_tree_from_string(string id)`
|
||||
- `Biome get_biome_from_string(string id)`
|
||||
- `Block[] blocks()`
|
||||
- `Item[] items()`
|
||||
- `Tree[] trees()`
|
||||
- `Biome[] biomes()`
|
||||
- `Dimension[] dimensions()`
|
||||
|
||||
## ServerCommandHandler
|
||||
|
||||
- `void send_player_change_dimension(u16 clientID, int x, int y, int z, u16 dimension, ClientInfo client)`
|
||||
- `void send_chat_message(u16 senderID, string message, ClientInfo client)`
|
||||
|
||||
## World
|
||||
|
||||
- `u16 get_block(int x, int y, int z)`
|
||||
- `void set_block(int x, int y, int z, u16 block)`
|
||||
- `u16 get_data(int x, int y, int z)`
|
||||
- `void set_data(int x, int y, int z, u16 data)`
|
||||
- `BlockData *add_block_data(int x, int y, int z, int inventoryWidth, int inventoryHeight)`
|
||||
- `BlockData *get_block_data(int x, int y, int z)`
|
||||
|
68
docs/lua-api-gui.md
Normal file
68
docs/lua-api-gui.md
Normal file
@ -0,0 +1,68 @@
|
||||
# Lua API: GUI API Overview
|
||||
|
||||
**Note:** This page is possibly outdated for the moment.
|
||||
|
||||
You can create a new GUI with:
|
||||
```lua
|
||||
local gui = LuaGUI.new()
|
||||
```
|
||||
|
||||
To show the custom GUI use:
|
||||
```lua
|
||||
gui:show(client)
|
||||
```
|
||||
|
||||
## Button
|
||||
|
||||
```lua
|
||||
gui:button {
|
||||
name = "btn_test",
|
||||
pos = {x = 0, y = 0},
|
||||
|
||||
text = "Test button",
|
||||
on_click = function(self)
|
||||
print("Test button pressed")
|
||||
end,
|
||||
}
|
||||
```
|
||||
|
||||
## Inventory
|
||||
|
||||
```lua
|
||||
gui:inventory {
|
||||
name = "inv_main",
|
||||
pos = {x = gui_pos.x + 7, y = gui_pos.y + 83},
|
||||
|
||||
player = "player",
|
||||
inventory = "main",
|
||||
size = {x = 9, y = 3},
|
||||
offset = 9,
|
||||
count = 9 * 3,
|
||||
}
|
||||
```
|
||||
|
||||
## Crafting table
|
||||
|
||||
```lua
|
||||
gui:crafting {
|
||||
name = "inv_crafting",
|
||||
pos = {x = gui_pos.x, y = gui_pos.y},
|
||||
|
||||
block = {x = pos.x, y = pos.y, z = pos.z},
|
||||
|
||||
offset = 0,
|
||||
}
|
||||
```
|
||||
|
||||
## Image
|
||||
|
||||
```lua
|
||||
gui:image {
|
||||
name = "img_background",
|
||||
pos = gui_pos,
|
||||
|
||||
texture = "texture-workbench",
|
||||
clip = {x = 0, y = 0, width = 176, height = 166},
|
||||
}
|
||||
```
|
||||
|
70
docs/lua-api-mod.md
Normal file
70
docs/lua-api-mod.md
Normal file
@ -0,0 +1,70 @@
|
||||
# Lua API: Mod API Overview
|
||||
|
||||
## Example
|
||||
|
||||
```lua
|
||||
local mod = LuaMod.new("mymod")
|
||||
|
||||
mod:block {
|
||||
id = "myblock",
|
||||
name = "My Block",
|
||||
tiles = "myblock.png",
|
||||
}
|
||||
|
||||
mod:item {
|
||||
id = "myitem",
|
||||
name = "My Item",
|
||||
tiles = "myitem.png",
|
||||
}
|
||||
|
||||
mod:crafting_recipe {
|
||||
result = {
|
||||
id = "mymod:myblock",
|
||||
amount = 1
|
||||
},
|
||||
|
||||
pattern = {
|
||||
"###",
|
||||
"# #",
|
||||
"###"
|
||||
},
|
||||
|
||||
keys = {["#"] = "default:cobblestone"}
|
||||
}
|
||||
|
||||
mod:smelting_recipe {
|
||||
input = {id = "mymod:myitem", amount = 1},
|
||||
output = {id = "mymod:myblock", amount = 1}
|
||||
}
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
### `block`
|
||||
|
||||
Defines a block from a table, see [this page](lua-api-block.md) for more information.
|
||||
|
||||
### `biome`
|
||||
|
||||
Defines a biome from a table, see [this page](lua-api-biome.md) for more information.
|
||||
|
||||
### `dimension`
|
||||
|
||||
Defines a dimension from a table, see [this page](lua-api-dimension.md) for more information.
|
||||
|
||||
### `item`
|
||||
|
||||
Defines an item from a table, see [this page](lua-api-item.md) for more information.
|
||||
|
||||
### `recipe`
|
||||
|
||||
Defines a recipe from a table, see [this page](lua-api-recipe.md) for more information.
|
||||
|
||||
### `sky`
|
||||
|
||||
Defines a sky type from a table, see [this page](lua-api-sky.md) for more information.
|
||||
|
||||
### `tree`
|
||||
|
||||
Defines a tree type from a table, see [this page](lua-api-tree.md) for more information.
|
||||
|
@ -1,250 +0,0 @@
|
||||
# Lua API: Overview
|
||||
|
||||
## Lua API
|
||||
|
||||
Note: The Lua API is currently server-side only.
|
||||
|
||||
### Core API
|
||||
|
||||
#### `openminer:registry()`
|
||||
|
||||
This function returns the `Registry` instance of the server.
|
||||
|
||||
#### `openminer:add_listener(event_type, listener)`
|
||||
|
||||
Adds a listener to a specific type of event.
|
||||
|
||||
Example:
|
||||
```lua
|
||||
openminer:add_listener(EventType.OnBlockPlaced, function(pos, player, world, client, server)
|
||||
server:send_chat_message(0, "Block placed at " .. pos.x .. ";" .. pos.y .. ";" .. pos.z .. " by Client" .. player:client_id(), client);
|
||||
end)
|
||||
|
||||
openminer:add_listener(EventType.OnBlockActivated, function(pos, block, player, world, client, server)
|
||||
if block:string_id() == "default:portal" then
|
||||
server:send_chat_message(0, "Swoosh! Changing dimension...", client);
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
Possible events:
|
||||
|
||||
- `OnBlockPlaced`: `funcion(pos, player, world, client, server)`
|
||||
- `OnBlockActivated`: `function(pos, block, player, world, client, server)`
|
||||
|
||||
### Mod API
|
||||
|
||||
Here is an example:
|
||||
|
||||
```lua
|
||||
local mod = LuaMod.new("mymod")
|
||||
|
||||
mod:block {
|
||||
id = "myblock",
|
||||
name = "My Block",
|
||||
tiles = "myblock.png",
|
||||
}
|
||||
|
||||
mod:item {
|
||||
id = "myitem",
|
||||
name = "My Item",
|
||||
tiles = "myitem.png",
|
||||
}
|
||||
|
||||
mod:crafting_recipe {
|
||||
result = {
|
||||
id = "mymod:myblock",
|
||||
amount = 1
|
||||
},
|
||||
|
||||
pattern = {
|
||||
"###",
|
||||
"# #",
|
||||
"###"
|
||||
},
|
||||
|
||||
keys = {["#"] = "default:cobblestone"}
|
||||
}
|
||||
|
||||
mod:smelting_recipe {
|
||||
input = {id = "mymod:myitem", amount = 1},
|
||||
output = {id = "mymod:myblock", amount = 1}
|
||||
}
|
||||
```
|
||||
|
||||
### Custom GUI
|
||||
|
||||
You can create a new GUI with:
|
||||
```lua
|
||||
local gui = LuaGUI.new()
|
||||
```
|
||||
|
||||
To show the custom GUI use:
|
||||
```lua
|
||||
gui:show(client)
|
||||
```
|
||||
|
||||
#### Button
|
||||
|
||||
```lua
|
||||
gui:button {
|
||||
name = "btn_test",
|
||||
pos = {x = 0, y = 0},
|
||||
|
||||
text = "Test button",
|
||||
on_click = function(self)
|
||||
print("Test button pressed")
|
||||
end,
|
||||
}
|
||||
```
|
||||
|
||||
#### Inventory
|
||||
|
||||
```lua
|
||||
gui:inventory {
|
||||
name = "inv_main",
|
||||
pos = {x = gui_pos.x + 7, y = gui_pos.y + 83},
|
||||
|
||||
player = "player",
|
||||
inventory = "main",
|
||||
size = {x = 9, y = 3},
|
||||
offset = 9,
|
||||
count = 9 * 3,
|
||||
}
|
||||
```
|
||||
|
||||
#### Crafting table
|
||||
|
||||
```lua
|
||||
gui:crafting {
|
||||
name = "inv_crafting",
|
||||
pos = {x = gui_pos.x, y = gui_pos.y},
|
||||
|
||||
block = {x = pos.x, y = pos.y, z = pos.z},
|
||||
|
||||
offset = 0,
|
||||
}
|
||||
```
|
||||
|
||||
#### Image
|
||||
|
||||
```lua
|
||||
gui:image {
|
||||
name = "img_background",
|
||||
pos = gui_pos,
|
||||
|
||||
texture = "texture-workbench",
|
||||
clip = {x = 0, y = 0, width = 176, height = 166},
|
||||
}
|
||||
```
|
||||
|
||||
## C++ classes in Lua
|
||||
|
||||
### Block
|
||||
|
||||
- `u16 id()`
|
||||
- `u16 data()`
|
||||
- `string string_id()`
|
||||
- `string label()`
|
||||
- `stirng mod_name()`
|
||||
- `bool is_opaque()`
|
||||
|
||||
### BlockData
|
||||
|
||||
- `Inventory *inventory`
|
||||
- `BlockMetadata *meta`
|
||||
- `bool use_alt_tiles`
|
||||
|
||||
### BlockMetadata
|
||||
|
||||
- `string get_string(string attribute)`
|
||||
- `void set_string(string attribute, string value)`
|
||||
- `int get_int(string attribute)`
|
||||
- `void set_int(string attribute, int value)`
|
||||
|
||||
### Chunk
|
||||
|
||||
- `u16 get_block(int x, int y, int z)`
|
||||
- `void set_block(int x, int y, int z, u16 block)`
|
||||
- `u16 get_data(int x, int y, int z)`
|
||||
- `void set_data(int x, int y, int z, u16 data)`
|
||||
- `BlockData *add_block_data(int x, int y, int z, int inventoryWidth, int inventoryHeight)`
|
||||
- `BlockData *get_block_data(int x, int y, int z)`
|
||||
|
||||
### ClientInfo
|
||||
|
||||
- `u16 id()`
|
||||
|
||||
### Inventory
|
||||
|
||||
- `void add_stack(string name, u16 amount)`
|
||||
- `ItemStack get_stack(u16 x, u16 y)`
|
||||
- `void set_stack(u16 x, u16 y, string name, u16 amount)`
|
||||
|
||||
### Item
|
||||
|
||||
- `u16 id()`
|
||||
- `string name()`
|
||||
- `u16 burn_time()`
|
||||
- `bool is_fuel()`
|
||||
|
||||
### ItemStack
|
||||
|
||||
- `u16 amount()`
|
||||
- `Item item()`
|
||||
|
||||
### ivec3
|
||||
|
||||
- `int x`
|
||||
- `int y`
|
||||
- `int z`
|
||||
|
||||
### Player
|
||||
|
||||
- `Inventory *inventory()`
|
||||
- `double x()`
|
||||
- `double y()`
|
||||
- `double z()`
|
||||
- `void set_position(double x, double y, double z)`
|
||||
- `u16 dimension()`
|
||||
- `void set_dimension(u16 dimension)`
|
||||
- `u16 client_id()`
|
||||
|
||||
### Recipe
|
||||
|
||||
- `string type()`
|
||||
- `ItemStack result()`
|
||||
|
||||
### Registry
|
||||
|
||||
- `Block get_block(u16 id)`
|
||||
- `Item get_item(u16 id)`
|
||||
- `Sky get_sky(u16 id)`
|
||||
- `Tree get_tree(u16 id)`
|
||||
- `Biome get_biome(u16 id)`
|
||||
- `Recipe get_recipe(Inventory crafting_inventory)`
|
||||
- `Block get_block_from_string(string id)`
|
||||
- `Item get_item_from_string(string id)`
|
||||
- `Sky get_sky_from_string(string id)`
|
||||
- `Tree get_tree_from_string(string id)`
|
||||
- `Biome get_biome_from_string(string id)`
|
||||
- `Block[] blocks()`
|
||||
- `Item[] items()`
|
||||
- `Tree[] trees()`
|
||||
- `Biome[] biomes()`
|
||||
- `Dimension[] dimensions()`
|
||||
|
||||
### ServerCommandHandler
|
||||
|
||||
- `void send_player_change_dimension(u16 clientID, int x, int y, int z, u16 dimension, ClientInfo client)`
|
||||
- `void send_chat_message(u16 senderID, string message, ClientInfo client)`
|
||||
|
||||
### World
|
||||
|
||||
- `u16 get_block(int x, int y, int z)`
|
||||
- `void set_block(int x, int y, int z, u16 block)`
|
||||
- `u16 get_data(int x, int y, int z)`
|
||||
- `void set_data(int x, int y, int z, u16 data)`
|
||||
- `BlockData *add_block_data(int x, int y, int z, int inventoryWidth, int inventoryHeight)`
|
||||
- `BlockData *get_block_data(int x, int y, int z)`
|
||||
|
10
mkdocs.yml
10
mkdocs.yml
@ -3,14 +3,18 @@ site_name: OpenMiner
|
||||
nav:
|
||||
- 'Home': 'index.md'
|
||||
- 'Lua API':
|
||||
- 'Overview': 'lua-api-overview.md'
|
||||
- 'Core API': 'lua-api-core.md'
|
||||
- 'Mod API':
|
||||
- 'Overview': 'lua-api-mod.md'
|
||||
- 'Biome': 'lua-api-biome.md'
|
||||
- 'Block': 'lua-api-block.md'
|
||||
- 'Dimension': 'lua-api-dimension.md'
|
||||
- 'Item': 'lua-api-item.md'
|
||||
- 'Recipe': 'lua-api-recipe.md'
|
||||
- 'Sky': 'lua-api-sky.md'
|
||||
- 'Tree': 'lua-api-tree.md'
|
||||
- 'Biome': 'lua-api-biome.md'
|
||||
- 'Dimension': 'lua-api-dimension.md'
|
||||
- 'GUI API':
|
||||
- 'Overview': 'lua-api-gui.md'
|
||||
|
||||
theme:
|
||||
name: readthedocs
|
||||
|
Loading…
x
Reference in New Issue
Block a user