lua: inventory library

This commit is contained in:
MihailRis
2024-02-12 13:56:46 +03:00
parent 617017d979
commit e16f7567b1
14 changed files with 257 additions and 44 deletions
+17 -1
View File
@@ -9,7 +9,7 @@ class LuaState;
class Engine;
class Content;
class ContentPack;
struct ContentPack;
class ContentIndices;
class Level;
class Block;
@@ -29,6 +29,7 @@ namespace scripting {
extern Level* level;
extern BlocksController* blocks;
/* Lua environment wrapper for automatic deletion */
class Environment {
int env;
public:
@@ -64,13 +65,28 @@ namespace scripting {
void on_block_placed(Player* player, const Block* block, int x, int y, int z);
void on_block_broken(Player* player, const Block* block, int x, int y, int z);
bool on_block_interact(Player* player, const Block* block, int x, int y, int z);
/* Called on RMB click on block with the item selected
@return true if prevents default action */
bool on_item_use_on_block(Player* player, const ItemDef* item, int x, int y, int z);
/* Called on LMB click on block with the item selected
@return true if prevents default action */
bool on_item_break_block(Player* player, const ItemDef* item, int x, int y, int z);
/* Called on UI view show */
void on_ui_open(UiDocument* layout, Inventory* inventory);
/* Called on UI view close*/
void on_ui_close(UiDocument* layout, Inventory* inventory);
/* Load script associated with a Block */
void load_block_script(int env, std::string prefix, fs::path file, block_funcs_set& funcsset);
/* Load script associated with an Item */
void load_item_script(int env, std::string prefix, fs::path file, item_funcs_set& funcsset);
/* Load package-specific world script */
void load_world_script(int env, std::string prefix, fs::path file);
/* Load script associated with an UiDocument */
void load_layout_script(int env, std::string prefix, fs::path file, uidocscript& script);
/* Finalize lua state. Using scripting after will lead to Lua panic */
void close();
}