Compare commits
10 Commits
72107bc648
...
afb8a14530
Author | SHA1 | Date | |
---|---|---|---|
|
afb8a14530 | ||
|
67e7e195d9 | ||
|
d22f3f0050 | ||
|
e20e7aa7bd | ||
|
59eef1aa23 | ||
|
d5e71d9821 | ||
|
51190b92f7 | ||
|
ad661e86aa | ||
|
fd047c4c99 | ||
|
580508fa37 |
14
README.md
14
README.md
@ -9,17 +9,17 @@ This mod provides a 2nd generation way of creating forms - this means that the m
|
|||||||
|
|
||||||
License: WTFPL
|
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.
|
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.
|
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
|
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
|
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.
|
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.
|
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")
|
button1 = state:get("btn1")
|
||||||
--or
|
--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.
|
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)
|
button1:setPos(4,0)
|
||||||
|
|
||||||
## Inventory Support
|
## 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
|
||||||
Dynamic forms allow you to make a form without having to register it before the game finished loading.
|
Dynamic forms allow you to make a form without having to register it before the game finished loading.
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
unified_inventory?
|
|
||||||
inventory_plus?
|
|
@ -1 +0,0 @@
|
|||||||
A library to allow mods to make Formspecs, a form of GUI, easily.
|
|
@ -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.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.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.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.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.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!
|
* 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)
|
* 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
|
## 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)
|
* player / show_formspec() - used for form:show(player)
|
||||||
* (main) inventory - assigned by smartfs.set_player_inventory()
|
* (main) inventory - assigned by smartfs.set_player_inventory()
|
||||||
* nodemeta - assigned by form:attach_to_node(nodepos, params)
|
* 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:useDetached( name ) - use a detached inventory with the given name
|
||||||
* element:usePlayer( name ) - use a player inventory other than the current player
|
* element:usePlayer( name ) - use a player inventory other than the current player
|
||||||
* element:getLocation() - returns the inventory location (default: 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:setIndex( index ) - set the inventory starting index
|
||||||
* element:getIndex() - returns the inventory starting index
|
* element:getIndex() - returns the inventory starting index
|
||||||
|
|
||||||
|
1
mod.conf
1
mod.conf
@ -1,6 +1,7 @@
|
|||||||
name = smartfs
|
name = smartfs
|
||||||
title = Smart Formspecs Library
|
title = Smart Formspecs Library
|
||||||
author = rubenwardy
|
author = rubenwardy
|
||||||
|
optional_depends = unified_inventory, inventory_plus, sfinv
|
||||||
description = A library to allow mods to make Formspecs, a form of GUI, easily.
|
description = A library to allow mods to make Formspecs, a form of GUI, easily.
|
||||||
license = CC0
|
license = CC0
|
||||||
forum = https://forum.minetest.net/viewtopic.php?t=7553
|
forum = https://forum.minetest.net/viewtopic.php?t=7553
|
||||||
|
965
smartfs.lua
965
smartfs.lua
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user