[LuaMod] 'path()' member added.
This commit is contained in:
parent
ead5e7dde0
commit
94b959cf03
@ -54,6 +54,16 @@ mod:smelting_recipe {
|
||||
|
||||
## Functions
|
||||
|
||||
### `id`
|
||||
|
||||
Returns the string ID of the mod.
|
||||
|
||||
### `path`
|
||||
|
||||
Returns the path of the mod, relative to current working directory.
|
||||
|
||||
## Registration functions
|
||||
|
||||
### `block`
|
||||
|
||||
Defines a block from a table, see [this page](lua-api-block.md) for more information.
|
||||
|
@ -43,7 +43,7 @@ function show_creative_window(client, screen_width, screen_height, gui_scale)
|
||||
name = "img_background",
|
||||
pos = {x = 0, y = 0},
|
||||
|
||||
texture = "mods/default/textures/gui/creative_window.png",
|
||||
texture = mod:path() .. "/textures/gui/creative_window.png",
|
||||
clip = {x = 0, y = 0, width = 195, height = 136},
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ function show_creative_window(client, screen_width, screen_height, gui_scale)
|
||||
name = "scroll_bar",
|
||||
pos = {x = 175, y = 18},
|
||||
|
||||
texture = "mods/default/textures/gui/tabs.png",
|
||||
texture = mod:path() .. "/textures/gui/tabs.png",
|
||||
clip = {x = 232, y = 0, width = 12, height = 15},
|
||||
clip_selected = {x = 244, y = 0, width = 12, height = 15},
|
||||
|
||||
|
Before Width: | Height: | Size: 1005 B After Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@ -24,6 +24,7 @@
|
||||
--
|
||||
-- =====================================================================================
|
||||
--
|
||||
local modpath = mod:path()
|
||||
|
||||
mod:block {
|
||||
id = "furnace",
|
||||
@ -53,7 +54,7 @@ mod:block {
|
||||
meta = "item_progress",
|
||||
max_value = 200,
|
||||
|
||||
texture = "mods/default/textures/gui/furnace.png",
|
||||
texture = modpath .. "/textures/gui/furnace.png",
|
||||
clip = {x = 176, y = 14, width = 24, height = 17},
|
||||
}
|
||||
|
||||
@ -68,7 +69,7 @@ mod:block {
|
||||
meta = "ticks_remaining",
|
||||
max_meta = "current_burn_time",
|
||||
|
||||
texture = "mods/default/textures/gui/furnace.png",
|
||||
texture = modpath .. "/textures/gui/furnace.png",
|
||||
clip = {x = 176, y = 0, width = 14, height = 14},
|
||||
}
|
||||
|
||||
@ -161,7 +162,7 @@ mod:block {
|
||||
name = "img_background",
|
||||
pos = {x = 0, y = 0},
|
||||
|
||||
texture = "mods/default/textures/gui/furnace.png",
|
||||
texture = modpath .. "/textures/gui/furnace.png",
|
||||
clip = {x = 0, y = 0, width = 176, height = 166},
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
--
|
||||
-- =====================================================================================
|
||||
--
|
||||
local modpath = mod:path()
|
||||
|
||||
mod:block {
|
||||
id = "workbench",
|
||||
@ -91,7 +92,7 @@ mod:block {
|
||||
name = "img_background",
|
||||
pos = {x = 0, y = 0},
|
||||
|
||||
texture = "mods/default/textures/gui/workbench.png",
|
||||
texture = modpath .. "/textures/gui/workbench.png",
|
||||
clip = {x = 0, y = 0, width = 176, height = 166},
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,8 @@ function init(player)
|
||||
player_inv:add_stack("default:diamond", 64);
|
||||
end
|
||||
|
||||
local modpath = mod:path()
|
||||
|
||||
function show_inventory(client, screen_width, screen_height, gui_scale)
|
||||
local gui = LuaGUI.new()
|
||||
|
||||
@ -81,7 +83,7 @@ function show_inventory(client, screen_width, screen_height, gui_scale)
|
||||
name = "img_background",
|
||||
pos = {x = 0, y = 0},
|
||||
|
||||
texture = "mods/default/textures/gui/inventory.png",
|
||||
texture = modpath .. "/textures/gui/inventory.png",
|
||||
clip = {x = 0, y = 0, width = 176, height = 166},
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,7 @@ void TextureAtlas::loadFromRegistry(const std::string &texturePack) {
|
||||
if (!texturePack.empty() && !gk::Filesystem::fileExists("texturepacks/" + texturePack))
|
||||
throw EXCEPTION("Texture pack '" + texturePack +"' doesn't exist");
|
||||
|
||||
// FIXME: Undefined texture should be created from current texture size
|
||||
if (texturePack.empty())
|
||||
addFile("mods/default/textures/blocks/", "undefined.png");
|
||||
else
|
||||
|
@ -52,8 +52,9 @@ void LuaMod::commit() {
|
||||
|
||||
void LuaMod::initUsertype(sol::state &lua) {
|
||||
lua.new_usertype<LuaMod>("LuaMod",
|
||||
sol::constructors<LuaMod(std::string)>(),
|
||||
"id", &LuaMod::id,
|
||||
"path", &LuaMod::path,
|
||||
|
||||
"block", &LuaMod::registerBlock,
|
||||
"item", &LuaMod::registerItem,
|
||||
"crafting_recipe", &LuaMod::registerCraftingRecipe,
|
||||
|
@ -48,6 +48,8 @@ class LuaMod {
|
||||
|
||||
const std::string &id() const { return m_id; }
|
||||
|
||||
std::string path() const { return "mods/" + m_id; }
|
||||
|
||||
static void initUsertype(sol::state &lua);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user