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

File diff suppressed because it is too large Load Diff