Fix imfs.model, and make inventories work properly with containers.
This commit is contained in:
parent
1040034efa
commit
371a92cc62
1 changed files with 8 additions and 7 deletions
15
init.lua
15
init.lua
|
|
@ -362,14 +362,14 @@ local fs_model = {
|
||||||
out[#out +1] = x:render()
|
out[#out +1] = x:render()
|
||||||
end
|
end
|
||||||
out[#out +1] = string.format(
|
out[#out +1] = string.format(
|
||||||
"model[%f,%f;%f,%f;%s;%s;%s;%f;%s;%s;%s;%f]",
|
"model[%f,%f;%f,%f;%s;%s;%s;%s;%s;%s;%s;%s]",
|
||||||
x or get(e, "x"), y or get(e, "y"),
|
x or get(e, "x"), y or get(e, "y"),
|
||||||
w or get(e, "w"), h or get(e, "h"),
|
w or get(e, "w"), h or get(e, "h"),
|
||||||
e.__id,
|
e.__id,
|
||||||
get(e, "mesh"), get(e, "textures"),
|
get(e, "mesh"), get(e, "textures"),
|
||||||
get(e, "_rotation") or "", get(e, "_continuous") or "",
|
get(e, "_rotation") or "", get(e, "_continuous") or "",
|
||||||
get(e, "_mouse_control"),
|
get(e, "_mouse_control") or "",
|
||||||
get(e, "_animation") or "", get(e, "_animation_speed")
|
get(e, "_animation") or "", get(e, "_animation_speed") or ""
|
||||||
)
|
)
|
||||||
return table.concat(out)
|
return table.concat(out)
|
||||||
end,
|
end,
|
||||||
|
|
@ -390,7 +390,7 @@ local fs_model = {
|
||||||
fs_model.__index = fs_model
|
fs_model.__index = fs_model
|
||||||
setmetatable(fs_model, {
|
setmetatable(fs_model, {
|
||||||
__call = function(_, x, y, w, h, mesh, textures)
|
__call = function(_, x, y, w, h, mesh, textures)
|
||||||
local e = {x = x, y = y, w = w, h = h, mesh = mesh, textures = textures, mouse_control = true}
|
local e = {x = x, y = y, w = w, h = h, mesh = mesh, textures = textures, mouse_control = true, _styles = {}}
|
||||||
e.__id = new_id()
|
e.__id = new_id()
|
||||||
setmetatable(e, fs_model)
|
setmetatable(e, fs_model)
|
||||||
table.insert(ctx, e)
|
table.insert(ctx, e)
|
||||||
|
|
@ -472,9 +472,10 @@ local fs_list = {
|
||||||
w = w or get(e, "w")
|
w = w or get(e, "w")
|
||||||
h = h or get(e, "h")
|
h = h or get(e, "h")
|
||||||
|
|
||||||
-- These lines will cause `w` and `h` to be interpreted as formspec coordinates rather than numbers of slots.
|
-- Interpret `w` and `h` as formspec coordinates rather than numbers of slots.
|
||||||
-- w = w -((w -1) /4)
|
-- This is necessary so that inventories in flex containers will work correctly.
|
||||||
-- h = h -((h -1) /4)
|
w = w -((w -1) /4)
|
||||||
|
h = h -((h -1) /4)
|
||||||
|
|
||||||
return string.format("list[%s;%s;%f,%f;%d,%d;%s]", get(e, "location"), get(e, "list"), x or get(e, "x"), y or get(e, "y"), w, h, get(e, "start"))
|
return string.format("list[%s;%s;%f,%f;%d,%d;%s]", get(e, "location"), get(e, "list"), x or get(e, "x"), y or get(e, "y"), w, h, get(e, "start"))
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue