Compare commits

..

10 Commits

Author SHA1 Message Date
Panquesito7
afb8a14530 Use mod.conf for optional dependencies
Deletes deprecated 'depends.txt' and 'description.txt'.
2019-10-29 08:05:23 +01:00
Beha
67e7e195d9 Add inventory:setList(list) and inventory:getList() to set the inventory list name. (#56)
* Add inventory:setList(list) and inventory:getList() to inventory element.
This allows multiple inventory elements with the same list name but different inventory locations.
Example: the "main" list in a chest and the player's "main" list.
2019-08-05 15:10:08 +02:00
Alexander Weber
d22f3f0050 do not create new metatable for each state and element 2019-02-15 20:48:42 +00:00
Alexander Weber
e20e7aa7bd Moved state methods to new state class
Using setmetatable also
2019-02-15 20:48:42 +00:00
Alexander Weber
59eef1aa23 Moved element stuff to element class, use setmetatable now 2019-02-15 20:48:42 +00:00
Beha
d5e71d9821 Add show_inv parameter to smartfs.add_to_inventory (#51) 2018-11-29 19:31:14 +01:00
bell07
51190b92f7
readme markup fixes 2018-11-29 19:26:44 +01:00
bell07
ad661e86aa
Fix dynamic elements on unified_inventory pages (#50) (#52) 2018-10-21 13:40:11 +02:00
Beha
fd047c4c99 Add Sfinv support. (#48)
* Add Sfinv support
2018-10-19 20:01:11 +02:00
bell07
580508fa37 Fix showing up complex images
Some complex texture strings contains [ character that needs to be escaped.
Issue found with [halloween](https://github.com/GreenXenith/halloween) preview texture on player tab page button in smart_inventory. The button was dissapeared, after this change visible again.
2018-08-27 20:15:55 +01:00
6 changed files with 551 additions and 438 deletions

View File

@ -9,17 +9,17 @@ This mod provides a 2nd generation way of creating forms - this means that the m
License: WTFPL
#Using Smart Formspec
# Using Smart Formspec
Smartfs provides 2nd generation Minetest forms to replace clunky formspec strings. Each smartfs form is a container filled with GUI elements. A number of default elements are included with smartfs, but modders can also define their own custom elements. This document describes the basic usage of the smartfs API.
##Installation
## Installation
Smartfs can be used as a library or a mod.
To use smartfs as a library, copy the smartfs.lua file to your mod folder and add
local smartfs = dofile(minetest.get\_modpath(minetest.get\_current\_modname()).."/smartfs.lua")
`local smartfs = dofile(minetest.get_modpath(minetest.get_current_modname()).."/smartfs.lua")`
to the top of your init.lua. If your mod is splitted to multiple files you can transport the library reference trough your mod namespace
yourmod.smartfs = dofile(minetest.get\_modpath(minetest.get\_current\_modname()).."/smartfs.lua")
`yourmod.smartfs = dofile(minetest.get_modpath(minetest.get_current_modname()).."/smartfs.lua")`
To use smartfs as a mod, add it to your game's mods folder or to the user mods folder and enable it.
You need to set up a dependency for your mod to use it. The library is available in the global "smartfs" table in this case.
@ -63,7 +63,7 @@ You can also get the element by using state:get(name). The example below will re
button1 = state:get("btn1")
--or
state:get("btn1"):onClick(your\_onclick\_function
state:get("btn1"):onClick(your_onclick_function)
Both of these methods should be used inside the form creation callback function, the function you pass to smartfs.create, or in event callbacks.
@ -72,9 +72,9 @@ Now that you have located your element you can modify it.
button1:setPos(4,0)
## Inventory Support
Smartfs supports adding a button to Inventory+ or Unified Inventory which will open one of your own custom forms. Use the smartfs.add\_to\_inventory(form, icon, title) function where form is the smartfs form linked to by the button, icon is the button image (only for unified inventory), and title is the button text (only for inventory+).
Smartfs supports adding a button to Sfinv, Inventory+, or Unified Inventory which will open one of your own custom forms. Use the `smartfs.add_to_inventory(form, icon, title)` function where form is the smartfs form linked to by the button, icon is the button image (only for unified inventory), title is the button text (for inventory+ and sfinv), and show_inv specifies whether to include the player inventory by default (for unified inventory and sfinv).
smartfs.add_to_inventory(form, icon, title)
smartfs.add_to_inventory(form, icon, title, show_inv)
## Dynamic forms
Dynamic forms allow you to make a form without having to register it before the game finished loading.

View File

@ -1,2 +0,0 @@
unified_inventory?
inventory_plus?

View File

@ -1 +0,0 @@
A library to allow mods to make Formspecs, a form of GUI, easily.

View File

@ -4,7 +4,7 @@
* smartfs.create( name,function ) - creates a new form and adds elements to it by running the function. Use before Minetest loads. (like minetest.register_node)
* smartfs.element( name, data ) - creates a new element type.
* smartfs.dynamic( formname, playername ) - creates a dynamic form. Returns state. See example.lua for example. Remember to call state:show()
* smartfs.add_to_inventory(form, icon, title) - Adds a form to an installed advanced inventory. Returns true on success.
* smartfs.add_to_inventory(form, icon, title, show_inv) - Adds a form to an installed advanced inventory. Returns true on success.
* smartfs.set_player_inventory(form) - Set the form as players main inventory for all player
* smartfs.inventory_mod() - Returns the name of an installed and supported inventory mod that will be used above, or nil.
* smartfs.override_load_checks() - Allows you to use smartfs.create after the game loads. Not recommended!
@ -16,7 +16,7 @@
* form:attach_to_node(nodepos, params) - Attach a form to a node meta (usable in register_node's constructor, on_placenode, or dynamically)
## Supported locations
* unified_inventory or inventory_plus plugins - assigned by smartfs.add_to_inventory() - auto-detection which inventory should be used
* unified_inventory, inventory_plus, or sfinv plugins - assigned by smartfs.add_to_inventory() - auto-detection which inventory should be used
* player / show_formspec() - used for form:show(player)
* (main) inventory - assigned by smartfs.set_player_inventory()
* nodemeta - assigned by form:attach_to_node(nodepos, params)
@ -148,6 +148,8 @@
* element:useDetached( name ) - use a detached inventory with the given name
* element:usePlayer( name ) - use a player inventory other than the current player
* element:getLocation() - returns the inventory location (default: current_player)
* element:setList( list ) - set a custom inventory list name or nil for the default (the element's name)
* element:getList() - returns the list name (defaults to the element's name)
* element:setIndex( index ) - set the inventory starting index
* element:getIndex() - returns the inventory starting index

View File

@ -1,6 +1,7 @@
name = smartfs
title = Smart Formspecs Library
author = rubenwardy
optional_depends = unified_inventory, inventory_plus, sfinv
description = A library to allow mods to make Formspecs, a form of GUI, easily.
license = CC0
forum = https://forum.minetest.net/viewtopic.php?t=7553

View File

@ -79,6 +79,8 @@ function smartfs.inventory_mod()
return "unified_inventory"
elseif minetest.global_exists("inventory_plus") then
return "inventory_plus"
elseif minetest.global_exists("sfinv") then
return "sfinv"
else
return nil
end
@ -87,7 +89,7 @@ end
------------------------------------------------------
-- Smartfs Interface - Adds a form to an installed advanced inventory. Returns true on success.
------------------------------------------------------
function smartfs.add_to_inventory(form, icon, title)
function smartfs.add_to_inventory(form, icon, title, show_inv)
local ldef
local invmod = smartfs.inventory_mod()
if invmod then
@ -95,7 +97,7 @@ function smartfs.add_to_inventory(form, icon, title)
else
return false
end
return ldef.add_to_inventory(form, icon, title)
return ldef.add_to_inventory(form, icon, title, (show_inv == nil) and true or show_inv)
end
------------------------------------------------------
@ -116,7 +118,7 @@ end
------------------------------------------------------
-- Unified inventory plugin
smartfs._ldef.unified_inventory = {
add_to_inventory = function(form, icon, title)
add_to_inventory = function(form, icon, title, show_inv)
unified_inventory.register_button(form.name, {
type = "image",
image = icon,
@ -124,15 +126,21 @@ smartfs._ldef.unified_inventory = {
unified_inventory.register_page(form.name, {
get_formspec = function(player, formspec)
local name = player:get_player_name()
local state
if smartfs.inv[name] and smartfs.inv[name].def.name == form.name then
state = smartfs.inv[name]
else
local statelocation = smartfs._ldef.unified_inventory._make_state_location_(name)
local state = smartfs._makeState_(form, nil, statelocation, name)
state = smartfs._makeState_(form, nil, statelocation, name)
if form.form_setup_callback(state) ~= false then
smartfs.inv[name] = state
return {formspec = state:_buildFormspec_(false)}
else
return nil
smartfs.inv[name] = nil
return ""
end
end
return {formspec = state:_buildFormspec_(false), draw_inventory = show_inv}
end
})
end,
_make_state_location_ = function(player)
@ -175,6 +183,56 @@ smartfs._ldef.inventory_plus = {
end
}
-- Sfinv plugin
smartfs._ldef.sfinv = {
add_to_inventory = function(form, icon, title, show_inv)
sfinv.register_page(form.name, {
title = title,
get = function(self, player, context)
local name = player:get_player_name()
local state
if smartfs.inv[name] then
state = smartfs.inv[name]
else
local statelocation = smartfs._ldef.sfinv._make_state_location_(name)
state = smartfs._makeState_(form, nil, statelocation, name)
smartfs.inv[name] = state
if form.form_setup_callback(state) ~= false then
smartfs.inv[name] = state
else
return ""
end
end
local fs = state:_buildFormspec_(false)
return sfinv.make_formspec(player, context, fs, show_inv)
end,
on_player_receive_fields = function(self, player, _, fields)
local name = player:get_player_name()
if smartfs.inv[name] then
smartfs.inv[name]:_sfs_on_receive_fields_(name, fields)
end
end,
on_leave = function(self, player)
local name = player:get_player_name()
if smartfs.inv[name] then
smartfs.inv[name].players:disconnect(name)
smartfs.inv[name] = nil
end
end,
})
end,
_make_state_location_ = function(player)
return {
type = "inventory",
inventory_handles_fields = true,
player = player,
_show_ = function(state)
sfinv.set_player_inventory_formspec(minetest.get_player_by_name(state.location.player))
end,
}
end
}
-- Show to player
smartfs._ldef.player = {
_make_state_location_ = function(player)
@ -347,7 +405,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
smartfs.opened[name] = nil
end
end
elseif smartfs.inv[name] and smartfs.inv[name].location.type == "inventory" then
elseif smartfs.inv[name] and smartfs.inv[name].location.type == "inventory" and not smartfs.inv[name].location.inventory_handles_fields then
local state = smartfs.inv[name]
state:_sfs_on_receive_fields_(name, fields)
end
@ -400,59 +458,114 @@ function smartfs._attach_to_node_(form, nodepos, params)
end
------------------------------------------------------
-- Smartfs Framework - create a form object (state)
-- Smartfs Framework - Element class Methods
------------------------------------------------------
function smartfs._makeState_(form, params, location, newplayer)
------------------------------------------------------
-- State - -- Object to manage players
------------------------------------------------------
local function _make_players_(newplayer)
local self = {
_list = {}
}
function self.connect(self, player)
self._list[player] = true
end
function self.disconnect(self, player)
self._list[player] = nil
end
function self.get_first(self)
return next(self._list)
end
if newplayer then
self:connect(newplayer)
end
return self
end
local element_class = {}
local element_class_mt = { __index = element_class }
function element_class:remove()
self.root._ele[self.name] = nil
end
------------------------------------------------------
-- State - create returning state object
------------------------------------------------------
return {
_ele = {},
def = form,
players = _make_players_(newplayer),
location = location,
is_inv = (location.type == "inventory"), -- obsolete. Please use location.type="inventory" instead
player = newplayer, -- obsolete. Please use location.player
param = params or {},
get = function(self,name)
function element_class:setPosition(x,y)
self.data.pos = {x=x,y=y}
end
function element_class:getPosition()
return self.data.pos
end
function element_class:setSize(w,h)
self.data.size = {w=w,h=h}
end
function element_class:getSize()
return self.data.size
end
function element_class:setVisible(visible)
if visible == nil then
self.data.visible = true
else
self.data.visible = visible
end
end
function element_class:getVisible()
return self.data.visible
end
function element_class:getAbsName()
return self.root:getNamespace()..self.name
end
function element_class:setBackground(image)
self.data.background = image
end
function element_class:getBackground()
return self.data.background
end
function element_class:getBackgroundString()
if self.data.background then
local size = self:getSize()
if size then
return "background["..
self.data.pos.x..","..self.data.pos.y..";"..
size.w..","..size.h..";"..
self.data.background.."]"
else
return ""
end
else
return ""
end
end
function element_class:setValue(value)
self.data.value = value
end
function element_class:setTooltip(text)
self.data.tooltip = minetest.formspec_escape(text)
end
function element_class:getTooltip()
return self.data.tooltip
end
function element_class:getTooltipString()
if self.data.tooltip then
return "tooltip["..self:getAbsName()..";"..self:getTooltip().."]"
else
return ""
end
end
------------------------------------------------------
-- Smartfs Framework - State class Methods
------------------------------------------------------
local state_class = {}
local state_class_mt = { __index = state_class }
function state_class:get(name)
return self._ele[name]
end,
close = function(self)
end
function state_class:close()
self.closed = true
end,
getSize = function(self)
end
function state_class:getSize()
return self._size
end,
size = function(self,w,h)
end
function state_class:size(w,h)
self._size = {w=w,h=h}
end,
setSize = function(self,w,h)
self._size = {w=w,h=h}
end,
getNamespace = function(self)
end
state_class.setSize = state_class.size
function state_class:getNamespace()
local ref = self
local namespace = ""
while ref.location.type == "container" do
@ -460,8 +573,9 @@ function smartfs._makeState_(form, params, location, newplayer)
ref = ref.location.parentState -- step near to the root
end
return namespace
end,
_buildFormspec_ = function(self,size)
end
function state_class:_buildFormspec_(size)
local res = ""
if self._size and size then
res = "size["..self._size.w..","..self._size.h.."]"
@ -472,9 +586,9 @@ function smartfs._makeState_(form, params, location, newplayer)
end
end
return res
end,
show = location._show_,
_get_element_recursive_ = function(self, field)
end
function state_class:_get_element_recursive_(field)
local topfield
for z in field:gmatch("[^#]+") do
topfield = z
@ -493,9 +607,10 @@ function smartfs._makeState_(form, params, location, newplayer)
else
return nil
end
end,
-- process onInput hook for the state
_sfs_process_oninput_ = function(self, fields, player)
end
-- process onInput hook for the state
function state_class:_sfs_process_oninput_(fields, player)
if self._onInput then
self:_onInput(fields, player)
end
@ -505,10 +620,10 @@ function smartfs._makeState_(form, params, location, newplayer)
eledef:getContainerState():_sfs_process_oninput_(fields, player)
end
end
end,
-- Receive fields and actions from formspec
_sfs_on_receive_fields_ = function(self, player, fields)
end
-- Receive fields and actions from formspec
function state_class:_sfs_on_receive_fields_(player, fields)
local fields_todo = {}
for field, value in pairs(fields) do
local element = self:_get_element_recursive_(field)
@ -546,11 +661,13 @@ function smartfs._makeState_(form, params, location, newplayer)
end
end
return true
end,
onInput = function(self, func)
end
function state_class:onInput(func)
self._onInput = func -- (fields, player)
end,
load = function(self,file)
end
function state_class:load(file)
local file = io.open(file, "r")
if file then
local table = minetest.deserialize(file:read("*all"))
@ -565,8 +682,9 @@ function smartfs._makeState_(form, params, location, newplayer)
end
end
return false
end,
save = function(self,file)
end
function state_class:save(file)
local res = {ele={}}
if self._size then
@ -584,110 +702,42 @@ function smartfs._makeState_(form, params, location, newplayer)
return true
end
return false
end,
setparam = function(self,key,value)
end
function state_class:setparam(key,value)
if not key then return end
self.param[key] = value
return true
end,
getparam = function(self,key,default)
end
function state_class:getparam(key,default)
if not key then return end
return self.param[key] or default
end,
element = function(self,typen,data)
end
function state_class:element(typen,data)
local type = smartfs._edef[typen]
assert(type, "Element type "..typen.." does not exist!")
assert(not self._ele[data.name], "Element "..data.name.." already exists")
data.type = typen
local ele = {
name = data.name,
root = self,
data = data,
remove = function(self)
self.root._ele[self.name] = nil
end,
setPosition = function(self,x,y)
self.data.pos = {x=x,y=y}
end,
getPosition = function(self)
return self.data.pos
end,
setSize = function(self,w,h)
self.data.size = {w=w,h=h}
end,
getSize = function(self)
return self.data.size
end,
setVisible = function(self, visible)
if visible == nil then
self.data.visible = true
else
self.data.visible = visible
end
end,
getVisible = function(self)
return self.data.visible
end,
getAbsName = function(self)
return self.root:getNamespace()..self.name
end,
setBackground = function(self, image)
self.data.background = image
end,
getBackground = function(self)
return self.data.background
end,
getBackgroundString = function(self)
if self.data.background then
local size = self:getSize()
if size then
return "background["..
self.data.pos.x..","..self.data.pos.y..";"..
size.w..","..size.h..";"..
self.data.background.."]"
else
return ""
end
else
return ""
end
end,
setValue = function(self, value)
self.data.value = value
end,
setTooltip = function(self,text)
self.data.tooltip = minetest.formspec_escape(text)
end,
getTooltip = function(self)
return self.data.tooltip
end,
getTooltipString = function(self)
if self.data.tooltip then
return "tooltip["..self:getAbsName()..";"..self:getTooltip().."]"
else
return ""
end
end,
}
ele.data.visible = true --visible by default
local ele = setmetatable({}, element_class_mt)
ele.name = data.name
ele.root = self
ele.data = data
ele.data.type = typen
ele.data.visible = true
for key, val in pairs(type) do
ele[key] = val
end
self._ele[data.name] = ele
type.onCreate(ele)
return self._ele[data.name]
end,
end
------------------------------------------------------
-- State - Element Constructors
------------------------------------------------------
button = function(self, x, y, w, h, name, text, exitf)
------------------------------------------------------
-- Smartfs Framework - State class Methods - Build time only
------------------------------------------------------
function state_class:button(x, y, w, h, name, text, exitf)
return self:element("button", {
pos = {x=x,y=y},
size = {w=w,h=h},
@ -695,8 +745,9 @@ function smartfs._makeState_(form, params, location, newplayer)
value = text,
closes = exitf or false
})
end,
image_button = function(self, x, y, w, h, name, text, image, exitf)
end
function state_class:image_button(x, y, w, h, name, text, image, exitf)
return self:element("button", {
pos = {x=x,y=y},
size = {w=w,h=h},
@ -705,8 +756,9 @@ function smartfs._makeState_(form, params, location, newplayer)
image = image,
closes = exitf or false
})
end,
item_image_button = function(self, x, y, w, h, name, text, item, exitf)
end
function state_class:item_image_button(x, y, w, h, name, text, item, exitf)
return self:element("button", {
pos = {x=x,y=y},
size = {w=w,h=h},
@ -715,24 +767,27 @@ function smartfs._makeState_(form, params, location, newplayer)
item = item,
closes = exitf or false
})
end,
label = function(self, x, y, name, text)
end
function state_class:label(x, y, name, text)
return self:element("label", {
pos = {x=x,y=y},
name = name,
value = text,
vertical = false
})
end,
vertlabel = function(self, x, y, name, text)
end
function state_class:vertlabel(x, y, name, text)
return self:element("label", {
pos = {x=x,y=y},
name = name,
value = text,
vertical = true
})
end,
toggle = function(self, x, y, w, h, name, list)
end
function state_class:toggle(x, y, w, h, name, list)
return self:element("toggle", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -740,8 +795,9 @@ function smartfs._makeState_(form, params, location, newplayer)
id = 1,
list = list
})
end,
field = function(self, x, y, w, h, name, label)
end
function state_class:field(x, y, w, h, name, label)
return self:element("field", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -749,8 +805,9 @@ function smartfs._makeState_(form, params, location, newplayer)
value = "",
label = label
})
end,
pwdfield = function(self, x, y, w, h, name, label)
end
function state_class:pwdfield(x, y, w, h, name, label)
local res = self:element("field", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -760,8 +817,9 @@ function smartfs._makeState_(form, params, location, newplayer)
})
res:isPassword(true)
return res
end,
textarea = function(self, x, y, w, h, name, label)
end
function state_class:textarea(x, y, w, h, name, label)
local res = self:element("field", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -771,8 +829,9 @@ function smartfs._makeState_(form, params, location, newplayer)
})
res:isMultiline(true)
return res
end,
image = function(self, x, y, w, h, name, img)
end
function state_class:image(x, y, w, h, name, img)
return self:element("image", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -780,8 +839,9 @@ function smartfs._makeState_(form, params, location, newplayer)
value = img,
imgtype = "image"
})
end,
background = function(self, x, y, w, h, name, img)
end
function state_class:background(x, y, w, h, name, img)
return self:element("image", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -789,8 +849,9 @@ function smartfs._makeState_(form, params, location, newplayer)
background = img,
imgtype = "background"
})
end,
item_image = function(self, x, y, w, h, name, img)
end
function state_class:item_image(x, y, w, h, name, img)
return self:element("image", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -798,16 +859,18 @@ function smartfs._makeState_(form, params, location, newplayer)
value = img,
imgtype = "item"
})
end,
checkbox = function(self, x, y, name, label, selected)
end
function state_class:checkbox(x, y, name, label, selected)
return self:element("checkbox", {
pos = {x=x, y=y},
name = name,
value = selected,
label = label
})
end,
listbox = function(self, x, y, w, h, name, selected, transparent)
end
function state_class:listbox(x, y, w, h, name, selected, transparent)
return self:element("list", {
pos = {x=x, y=y},
size = {w=w, h=h},
@ -815,37 +878,78 @@ function smartfs._makeState_(form, params, location, newplayer)
selected = selected,
transparent = transparent
})
end,
dropdown = function(self, x, y, w, h, name, selected)
end
function state_class:dropdown(x, y, w, h, name, selected)
return self:element("dropdown", {
pos = {x=x, y=y},
size = {w=w, h=h},
name = name,
selected = selected
})
end,
inventory = function(self, x, y, w, h, name)
end
function state_class:inventory(x, y, w, h, name)
return self:element("inventory", {
pos = {x=x, y=y},
size = {w=w, h=h},
name = name
})
end,
container = function(self, x, y, name, relative)
end
function state_class:container(x, y, name, relative)
return self:element("container", {
pos = {x=x, y=y},
name = name,
relative = false
})
end,
view = function(self, x, y, name, relative)
end
function state_class:view(x, y, name, relative)
return self:element("container", {
pos = {x=x, y=y},
name = name,
relative = true
})
end,
end
------------------------------------------------------
-- Smartfs Framework - create a form object (state)
------------------------------------------------------
function smartfs._makeState_(form, params, location, newplayer)
------------------------------------------------------
-- State - -- Object to manage players
------------------------------------------------------
local function _make_players_(newplayer)
local self = {
_list = {}
}
function self.connect(self, player)
self._list[player] = true
end
function self.disconnect(self, player)
self._list[player] = nil
end
function self.get_first(self)
return next(self._list)
end
if newplayer then
self:connect(newplayer)
end
return self
end
local state = {
_ele = {},
def = form,
players = _make_players_(newplayer),
location = location,
is_inv = (location.type == "inventory"), -- obsolete. Please use location.type="inventory" instead
player = newplayer, -- obsolete. Please use location.player
param = params or {},
show = location._show_,
}
return setmetatable(state, state_class_mt)
end
-----------------------------------------------------------------
@ -885,7 +989,7 @@ smartfs.element("button", {
self.data.pos.x..","..self.data.pos.y..";"..
self.data.size.w..","..self.data.size.h..";"
if self.data.image then
specstring = specstring..self.data.image..";"
specstring = specstring..minetest.formspec_escape(self.data.image)..";"
elseif self.data.item then
specstring = specstring..self.data.item..";"
end
@ -1096,7 +1200,7 @@ smartfs.element("image", {
";"..
self.data.size.w..","..self.data.size.h..
";"..
self.data.value..
minetest.formspec_escape(self.data.value)..
"]"
else
return "image["..
@ -1104,7 +1208,7 @@ smartfs.element("image", {
";"..
self.data.size.w..","..self.data.size.h..
";"..
self.data.value..
minetest.formspec_escape(self.data.value)..
"]"
end
end,
@ -1312,12 +1416,15 @@ smartfs.element("inventory", {
assert(self.data.pos and self.data.pos.x and self.data.pos.y, "list needs valid pos")
assert(self.data.size and self.data.size.w and self.data.size.h, "list needs valid size")
assert(self.name, "list needs name")
-- Default the list name to the element name.
self.data.list = self.name
end,
build = function(self)
return "list["..
(self.data.invlocation or "current_player") ..
";"..
self.name.. --no namespacing
self.data.list ..
";"..
self.data.pos.x..","..self.data.pos.y..
";"..
@ -1347,6 +1454,12 @@ smartfs.element("inventory", {
useDetached = function(self, name)
self.data.invlocation = "detached:" .. name
end,
setList = function(self, list)
self.data.list = list or self.name
end,
getList = function(self)
return self.data.list
end,
setIndex = function(self,index)
self.data.index = index
end,