forked from minetest-mods/craftguide
Check compat for background[]
This commit is contained in:
parent
9dd63cd83a
commit
19fb5e2691
2
API.md
2
API.md
|
@ -174,7 +174,7 @@ craftguide.group_stereotypes.radioactive = "mod:item"
|
||||||
You can set a custom background theme by overriding this variable:
|
You can set a custom background theme by overriding this variable:
|
||||||
|
|
||||||
```Lua
|
```Lua
|
||||||
craftguide.background = "<file_name.png>:<middle>"
|
craftguide.background = "<file_name.png>#<middle>"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
22
init.lua
22
init.lua
|
@ -55,9 +55,11 @@ local WH_LIMIT = 8
|
||||||
local XOFFSET = sfinv_only and 3.83 or 4.66
|
local XOFFSET = sfinv_only and 3.83 or 4.66
|
||||||
local YOFFSET = sfinv_only and 6 or 6.6
|
local YOFFSET = sfinv_only and 6 or 6.6
|
||||||
|
|
||||||
local DEV_CORE = sub(core.get_version().string, -3) == "dev"
|
local CORE_VERSION = core.get_version().string
|
||||||
|
CORE_VERSION = match(CORE_VERSION, "[^%-]*"):gsub("%.", "")
|
||||||
|
CORE_VERSION = tonumber(CORE_VERSION)
|
||||||
|
|
||||||
craftguide.background = "craftguide_bg_full.png:10"
|
craftguide.background = "craftguide_bg_full.png#10"
|
||||||
|
|
||||||
local PNG = {
|
local PNG = {
|
||||||
bg = "craftguide_bg.png",
|
bg = "craftguide_bg.png",
|
||||||
|
@ -708,17 +710,19 @@ local function make_formspec(name)
|
||||||
local fs = {}
|
local fs = {}
|
||||||
|
|
||||||
if not sfinv_only then
|
if not sfinv_only then
|
||||||
local bg, middle = match(craftguide.background, "(.-):(%d+)")
|
local bg, middle = match(craftguide.background, "([%w_%.]*)([#%d]*)")
|
||||||
bg = bg or ""
|
bg = bg or ""
|
||||||
middle = middle or "10"
|
middle = tonumber(sub(middle, 2)) or 10
|
||||||
|
|
||||||
fs[#fs + 1] = fmt([[
|
fs[#fs + 1] = [[
|
||||||
size[9.5,8.4]
|
size[9.5,8.4]
|
||||||
no_prepend[]
|
no_prepend[]
|
||||||
bgcolor[#00000000;false]
|
bgcolor[#0000]
|
||||||
background[1,1;1,1;%s;true%s]
|
]]
|
||||||
]],
|
|
||||||
bg, DEV_CORE and ";" .. middle or "")
|
fs[#fs + 1] = CORE_VERSION >= 510 and
|
||||||
|
fmt("background9[1,1;1,1;%s;true;%d]", bg, middle) or
|
||||||
|
fmt("background[1,1;1,1;%s;true]", bg)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt([[
|
fs[#fs + 1] = fmt([[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user