2020-03-12 14:07:18 +01:00
|
|
|
# Lua API: C++ classes in Lua
|
|
|
|
|
|
|
|
**Note:** This page is currently really basic but it will be extended later.
|
|
|
|
|
|
|
|
## Block
|
|
|
|
|
|
|
|
- `u16 id()`
|
|
|
|
- `string string_id()`
|
2020-03-13 19:03:22 +01:00
|
|
|
- `string mod_name()`
|
2020-07-09 22:24:19 +02:00
|
|
|
- `BlockParam param()`
|
2020-07-10 22:42:29 +02:00
|
|
|
- `BlockState get_state()`
|
2020-03-12 14:07:18 +01:00
|
|
|
|
|
|
|
## BlockData
|
|
|
|
|
|
|
|
- `Inventory *inventory`
|
|
|
|
- `BlockMetadata *meta`
|
|
|
|
|
|
|
|
## 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)`
|
2020-03-29 19:19:39 +02:00
|
|
|
- `bool get_bool(string attribute)`
|
|
|
|
- `void set_bool(string attribute, bool value)`
|
2020-03-12 14:07:18 +01:00
|
|
|
|
2020-07-10 22:42:29 +02:00
|
|
|
## BlockParam
|
|
|
|
|
|
|
|
- `u16 get_param(BlockParamType type, u16 block_param)`
|
|
|
|
- `u16 set_param(BlockParamType type, u16 block_param, u16 param_value)`
|
|
|
|
- `bool has_param(BlockParamType type)`
|
|
|
|
|
|
|
|
## BlockParamType
|
|
|
|
|
|
|
|
- `BlockParamType.Rotation`
|
|
|
|
- `BlockParamType.State`
|
|
|
|
- `BlockParamType.Count`
|
|
|
|
|
2020-07-10 23:58:07 +02:00
|
|
|
## BlockState
|
|
|
|
|
|
|
|
- `u16 id()`
|
|
|
|
- `std::string label()`
|
|
|
|
- `ItemStack get_item_drop()`
|
|
|
|
|
2020-03-12 14:07:18 +01:00
|
|
|
## 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 *get_block_data(int x, int y, int z)`
|
2020-07-10 22:42:29 +02:00
|
|
|
- `BlockData *add_block_data(int x, int y, int z, int inventoryWidth, int inventoryHeight)`
|
|
|
|
- `BlockState *get_block_state(int x, int y, int z)`
|
|
|
|
- `void set_block_state(int x, int y, int z, u16 stateID)`
|
2020-03-12 14:07:18 +01:00
|
|
|
|
|
|
|
## ClientInfo
|
|
|
|
|
2020-07-13 12:50:16 +02:00
|
|
|
- `u16 id`
|
|
|
|
- `u16 screen_width`
|
|
|
|
- `u16 screen_height`
|
|
|
|
- `u8 gui_scale`
|
2020-03-12 14:07:18 +01:00
|
|
|
|
2020-05-20 13:38:09 +02:00
|
|
|
## Dimension
|
|
|
|
|
|
|
|
- `u16 id()`
|
|
|
|
|
|
|
|
## EntityWrapper
|
|
|
|
|
|
|
|
- `entt::entity id()`
|
|
|
|
- `PositionComponent *position()`
|
|
|
|
- `NetworkComponent *network()`
|
|
|
|
- `ItemStack *item_stack()`
|
|
|
|
|
2020-03-12 14:07:18 +01:00
|
|
|
## 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()`
|
2020-05-20 13:38:09 +02:00
|
|
|
- `bool has_group(string groupName)`
|
|
|
|
- `u16 get_group_value(string groupName)`
|
2020-03-12 14:07:18 +01:00
|
|
|
|
|
|
|
## ItemStack
|
|
|
|
|
|
|
|
- `u16 amount()`
|
|
|
|
- `Item item()`
|
|
|
|
|
|
|
|
## ivec3
|
|
|
|
|
|
|
|
- `int x`
|
|
|
|
- `int y`
|
|
|
|
- `int z`
|
|
|
|
|
|
|
|
## Player
|
|
|
|
|
2020-06-26 01:31:41 +02:00
|
|
|
- `string name()`
|
2020-03-12 14:07:18 +01:00
|
|
|
- `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()`
|
2020-06-26 01:31:41 +02:00
|
|
|
- `Inventory *inventory()`
|
2020-03-12 14:07:18 +01:00
|
|
|
|
|
|
|
## 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)`
|
2020-07-10 22:42:29 +02:00
|
|
|
- `Key get_key(u16 id)`
|
2020-03-12 14:07:18 +01:00
|
|
|
- `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)`
|
|
|
|
|
2020-04-03 00:26:31 +02:00
|
|
|
## ServerModLoader
|
|
|
|
|
2020-05-20 20:53:22 +02:00
|
|
|
- `LuaMod *register_mod(string mod_id)` (see [Lua Mod API](lua-api-mod.md#example))
|
2020-04-03 00:26:31 +02:00
|
|
|
|
2020-05-20 13:38:09 +02:00
|
|
|
## ServerPlayer
|
|
|
|
|
|
|
|
- `const ClientInfo &client()`
|
2020-06-02 05:51:10 +02:00
|
|
|
- `ItemStack held_item_stack()`
|
2020-06-23 18:40:16 +02:00
|
|
|
- `bool is_online()`
|
2020-05-20 13:38:09 +02:00
|
|
|
|
|
|
|
## ServerWorld
|
|
|
|
|
|
|
|
- `u16 dimension()`
|
|
|
|
|
2020-03-12 14:07:18 +01:00
|
|
|
## 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)`
|
2020-07-05 20:55:23 +02:00
|
|
|
- `const Block &get_block_def(int x, int y, int z)`
|
|
|
|
- `void set_block_from_str(int x, int y, int z, string block_id)`
|
2020-07-10 22:42:29 +02:00
|
|
|
- `const BlockState *get_block_state(int x, int y, int z)`
|
|
|
|
- `void set_block_state(int x, int y, int z, u16 stateID)`
|
2020-03-12 14:07:18 +01:00
|
|
|
|