Add disabled definition property

This commit is contained in:
octacian 2017-03-01 17:30:50 -08:00
parent 4d97ea6d80
commit 8bb8a49701
3 changed files with 33 additions and 1 deletions

28
api.lua
View File

@ -3,6 +3,11 @@ local BASENAME = "microexpansion"
-- [function] Register Recipe -- [function] Register Recipe
function microexpansion.register_recipe(output, recipe) function microexpansion.register_recipe(output, recipe)
-- Check if disabled
if recipe.disabled == true then
return
end
local function isint(n) local function isint(n)
return n==math.floor(n) return n==math.floor(n)
end end
@ -29,12 +34,22 @@ function microexpansion.register_recipe(output, recipe)
end end
for _, i in ipairs(recipe) do for _, i in ipairs(recipe) do
-- Check if disabled
if recipe.disabled == true then
return
end
register(_) register(_)
end end
end end
-- [function] Register oredef -- [function] Register oredef
function microexpansion.register_oredef(ore, def) function microexpansion.register_oredef(ore, def)
-- Check if disabled
if def.disabled == true then
return
end
local function register(_) local function register(_)
local def = def[_] local def = def[_]
def.ore = "microexpansion:"..ore def.ore = "microexpansion:"..ore
@ -42,6 +57,11 @@ function microexpansion.register_oredef(ore, def)
end end
for _, i in ipairs(def) do for _, i in ipairs(def) do
-- Check if disabled
if def.disabled == true then
return
end
register(_) register(_)
end end
end end
@ -59,6 +79,10 @@ end
-- [function] Register Item -- [function] Register Item
function microexpansion.register_item(itemstring, def) function microexpansion.register_item(itemstring, def)
-- Check if disabled
if def.disabled == true then
return
end
-- Set usedfor -- Set usedfor
if def.usedfor then if def.usedfor then
def.description = def.description .. "\n"..minetest.colorize("grey", def.usedfor) def.description = def.description .. "\n"..minetest.colorize("grey", def.usedfor)
@ -83,6 +107,10 @@ end
-- [function] Register Node -- [function] Register Node
function microexpansion.register_node(itemstring, def) function microexpansion.register_node(itemstring, def)
-- Check if disabled
if def.disabled == true then
return
end
-- Set usedfor -- Set usedfor
if def.usedfor then if def.usedfor then
def.description = def.description .. "\n"..minetest.colorize("grey", def.usedfor) def.description = def.description .. "\n"..minetest.colorize("grey", def.usedfor)

View File

@ -1,6 +1,8 @@
# Core API # Core API
The core API is composed of several functions to make registering new items, nodes, and recipes for items and nodes more efficient and intuitive. Code for this public API is in `./api.lua`. This documentation is divided up per function. The core API is composed of several functions to make registering new items, nodes, and recipes for items and nodes more efficient and intuitive. Code for this public API is in `./api.lua`. This documentation is divided up per function.
__Note:__ Any definition table for registering anything using the ME API allow a `disabled` property to be specified. If set to `false`, the node/item will not be registered, if not set, it will.
#### `register_recipe(output, def)` #### `register_recipe(output, def)`
__Usage:__ `microexpansion.register_recipe(<output (string)>, <recipe (table)>)` __Usage:__ `microexpansion.register_recipe(<output (string)>, <recipe (table)>)`

View File

@ -20,6 +20,7 @@ me.register_node("incranium", {
y_max = -90, y_max = -90,
}, },
}, },
disabled = true,
}) })
-- "Supernatet", pronounced "Super-nat-et" is Latin for "float", this ore will -- "Supernatet", pronounced "Super-nat-et" is Latin for "float", this ore will
@ -39,5 +40,6 @@ me.register_node("supernatet", {
clust_size = 3, clust_size = 3,
y_min = -300, y_min = -300,
y_max = -90, y_max = -90,
} },
status = "unstable",
}) })