replace space indents with tabs and co.

This commit is contained in:
DS-Minetest 2017-07-29 17:41:36 +02:00
parent be54e91335
commit 307688744f
2 changed files with 141 additions and 141 deletions

230
api.lua
View File

@ -3,150 +3,150 @@ local BASENAME = "microexpansion"
-- [function] Register Recipe -- [function] Register Recipe
function microexpansion.register_recipe(output, recipe) function microexpansion.register_recipe(output, recipe)
-- Check if disabled -- Check if disabled
if recipe.disabled == true then if recipe.disabled == true then
return return
end end
local function isint(n) local function isint(n)
return n==math.floor(n) return n==math.floor(n)
end end
local function get_amount(_) local function get_amount(_)
if isint(recipe[_][1]) then if isint(recipe[_][1]) then
return recipe[_][1] return recipe[_][1]
else return 1 end else return 1 end
end end
local function get_type(_) local function get_type(_)
if type(recipe[_][2]) == "string" then if type(recipe[_][2]) == "string" then
return recipe[_][2] return recipe[_][2]
end end
end end
local function register(_) local function register(_)
local def = { local def = {
type = get_type(_), type = get_type(_),
output = output.." "..tostring(get_amount(_)), output = output.." "..tostring(get_amount(_)),
recipe = recipe[_][3] or recipe[_][2] recipe = recipe[_][3] or recipe[_][2]
} }
minetest.register_craft(def) minetest.register_craft(def)
end end
for _, i in ipairs(recipe) do for _, i in ipairs(recipe) do
-- Check if disabled -- Check if disabled
if recipe.disabled == true then if recipe.disabled == true then
return return
end 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 -- Check if disabled
if def.disabled == true then if def.disabled == true then
return return
end end
local function register(_) local function register(_)
local def = def[_] local def = def[_]
def.ore = "microexpansion:"..ore def.ore = "microexpansion:"..ore
minetest.register_ore(def) minetest.register_ore(def)
end end
for _, i in ipairs(def) do for _, i in ipairs(def) do
-- Check if disabled -- Check if disabled
if def.disabled == true then if def.disabled == true then
return return
end end
register(_) register(_)
end end
end end
-- [local function] Choose description colour -- [local function] Choose description colour
local function desc_colour(status, desc) local function desc_colour(status, desc)
if status == "unstable" then if status == "unstable" then
return minetest.colorize("orange", desc) return minetest.colorize("orange", desc)
elseif status == "no" then elseif status == "no" then
return minetest.colorize("red", desc) return minetest.colorize("red", desc)
else else
return minetest.colorize("white", desc) return minetest.colorize("white", desc)
end end
end end
-- [function] Register Item -- [function] Register Item
function microexpansion.register_item(itemstring, def) function microexpansion.register_item(itemstring, def)
-- Check if disabled -- Check if disabled
if def.disabled == true then if def.disabled == true then
return return
end 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)
end end
-- Update inventory image -- Update inventory image
if def.inventory_image then if def.inventory_image then
def.inventory_image = BASENAME.."_"..def.inventory_image..".png" def.inventory_image = BASENAME.."_"..def.inventory_image..".png"
else else
def.inventory_image = BASENAME.."_"..itemstring..".png" def.inventory_image = BASENAME.."_"..itemstring..".png"
end end
-- Colour description -- Colour description
def.description = desc_colour(def.status, def.description) def.description = desc_colour(def.status, def.description)
-- Register craftitem -- Register craftitem
minetest.register_craftitem(BASENAME..":"..itemstring, def) minetest.register_craftitem(BASENAME..":"..itemstring, def)
-- if recipe, Register recipe -- if recipe, Register recipe
if def.recipe then if def.recipe then
microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe) microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe)
end end
end end
-- [function] Register Node -- [function] Register Node
function microexpansion.register_node(itemstring, def) function microexpansion.register_node(itemstring, def)
-- Check if disabled -- Check if disabled
if def.disabled == true then if def.disabled == true then
return return
end 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)
end end
-- Update texture -- Update texture
if auto_complete ~= false then if auto_complete ~= false then
for _,i in ipairs(def.tiles) do for _,i in ipairs(def.tiles) do
if #def.tiles[_]:split("^") <= 1 then if #def.tiles[_]:split("^") <= 1 then
local prefix = "" local prefix = ""
if def.type == "ore" then if def.type == "ore" then
prefix = "ore_" prefix = "ore_"
end end
def.tiles[_] = BASENAME.."_"..prefix..i..".png" def.tiles[_] = BASENAME.."_"..prefix..i..".png"
end end
end end
end end
-- Colour description -- Colour description
def.description = desc_colour(def.status, def.description) def.description = desc_colour(def.status, def.description)
-- Update connect_sides -- Update connect_sides
if def.connect_sides == "nobottom" then if def.connect_sides == "nobottom" then
def.connect_sides = { "top", "front", "left", "back", "right" } def.connect_sides = { "top", "front", "left", "back", "right" }
elseif def.connect_sides == "machine" then elseif def.connect_sides == "machine" then
def.connect_sides = { "top", "bottom", "left", "back", "right" } def.connect_sides = { "top", "bottom", "left", "back", "right" }
end end
-- Register node -- Register node
minetest.register_node(BASENAME..":"..itemstring, def) minetest.register_node(BASENAME..":"..itemstring, def)
-- if recipe, Register recipe -- if recipe, Register recipe
if def.recipe then if def.recipe then
microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe) microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe)
end end
-- if oredef, Register oredef -- if oredef, Register oredef
if def.oredef then if def.oredef then
microexpansion.register_oredef(BASENAME..":"..itemstring, def.oredef) microexpansion.register_oredef(BASENAME..":"..itemstring, def.oredef)
end end
end end

View File

@ -9,9 +9,9 @@ microexpansion.gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
-- logger -- logger
function microexpansion.log(content, log_type) function microexpansion.log(content, log_type)
if not content then return false end if not content then return false end
if log_type == nil then log_type = "action" end if log_type == nil then log_type = "action" end
minetest.log(log_type, "[MicroExpansion] "..content) minetest.log(log_type, "[MicroExpansion] "..content)
end end
-- Load API -- Load API
@ -27,40 +27,40 @@ local settings = Settings(modpath.."/modules.conf"):to_table()
-- [function] Get module path -- [function] Get module path
function microexpansion.get_module_path(name) function microexpansion.get_module_path(name)
local module_path = modpath.."/modules/"..name local module_path = modpath.."/modules/"..name
if io.open(module_path.."/init.lua") then if io.open(module_path.."/init.lua") then
return module_path return module_path
end end
end end
-- [function] Load module (overrides modules.conf) -- [function] Load module (overrides modules.conf)
function microexpansion.load_module(name) function microexpansion.load_module(name)
if loaded_modules[name] ~= false then if loaded_modules[name] ~= false then
local module_init = microexpansion.get_module_path(name).."/init.lua" local module_init = microexpansion.get_module_path(name).."/init.lua"
if module_init then if module_init then
dofile(module_init) dofile(module_init)
loaded_modules[name] = true loaded_modules[name] = true
return true return true
else else
microexpansion.log("Invalid module \""..name.."\". The module either does not exist ".. microexpansion.log("Invalid module \""..name.."\". The module either does not exist "..
"or is missing an init.lua file.", "error") "or is missing an init.lua file.", "error")
end end
else else
return true return true
end end
end end
-- [function] Require module (does not override modules.conf) -- [function] Require module (does not override modules.conf)
function microexpansion.require_module(name) function microexpansion.require_module(name)
if settings[name] and settings[name] ~= false then if settings[name] and settings[name] ~= false then
return microexpansion.load_module(name) return microexpansion.load_module(name)
end end
end end
for name,enabled in pairs(settings) do for name,enabled in pairs(settings) do
if enabled ~= false then if enabled ~= false then
microexpansion.load_module(name) microexpansion.load_module(name)
end end
end end