Replace spaces with tabs
This commit is contained in:
		@@ -7,8 +7,8 @@ MicroExpansion - ME [microexpansion]
 | 
				
			|||||||
* **Licence:** Code: MIT (see LICENSE), Media: CC-BY-SA 3.0
 | 
					* **Licence:** Code: MIT (see LICENSE), Media: CC-BY-SA 3.0
 | 
				
			||||||
* [Github Repository](https://github.com/octacian/microexpansion)
 | 
					* [Github Repository](https://github.com/octacian/microexpansion)
 | 
				
			||||||
* **Downloads:**
 | 
					* **Downloads:**
 | 
				
			||||||
  * [Master (Unstable)](https://github.com/octacian/microexpansion/archive/master.zip)
 | 
						* [Master (Unstable)](https://github.com/octacian/microexpansion/archive/master.zip)
 | 
				
			||||||
  * ...or browse the code on [GitHub](https://github.com/octacian/microexpansion)
 | 
						* ...or browse the code on [GitHub](https://github.com/octacian/microexpansion)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Note**: MicroExpansion requires that you have `minetest-dev` with [this commit](https://github.com/minetest/minetest/commit/f2f9a923515386d787a245fac52f78e815b3a839) or later.
 | 
					**Note**: MicroExpansion requires that you have `minetest-dev` with [this commit](https://github.com/minetest/minetest/commit/f2f9a923515386d787a245fac52f78e815b3a839) or later.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										230
									
								
								api.lua
									
									
									
									
									
								
							
							
						
						
									
										230
									
								
								api.lua
									
									
									
									
									
								
							@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										93
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								init.lua
									
									
									
									
									
								
							@@ -1,7 +1,11 @@
 | 
				
			|||||||
-- microexpansion/init.lua
 | 
					-- microexpansion/init.lua
 | 
				
			||||||
microexpansion = {}
 | 
					microexpansion           = {}
 | 
				
			||||||
microexpansion.modpath = minetest.get_modpath("microexpansion") -- modpath
 | 
					microexpansion.data      = {}
 | 
				
			||||||
local modpath = microexpansion.modpath -- modpath pointer
 | 
					microexpansion.modpath   = minetest.get_modpath("microexpansion") -- Get modpath
 | 
				
			||||||
 | 
					microexpansion.worldpath = minetest.get_worldpath()               -- Get worldpath
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local modpath   = microexpansion.modpath   -- Modpath pointer
 | 
				
			||||||
 | 
					local worldpath = microexpansion.worldpath -- Worldpath pointer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Formspec GUI related stuff
 | 
					-- Formspec GUI related stuff
 | 
				
			||||||
microexpansion.gui_bg = "bgcolor[#080808BB;true]background[5,5;1,1;gui_formbg.png;true]"
 | 
					microexpansion.gui_bg = "bgcolor[#080808BB;true]background[5,5;1,1;gui_formbg.png;true]"
 | 
				
			||||||
@@ -9,14 +13,45 @@ 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
 | 
						assert(content, "microexpansion.log: missing content")
 | 
				
			||||||
  if log_type == nil then log_type = "action" end
 | 
						if not content then return false end
 | 
				
			||||||
  minetest.log(log_type, "[MicroExpansion] "..content)
 | 
						if log_type == nil then log_type = "action" end
 | 
				
			||||||
 | 
						minetest.log(log_type, "[MicroExpansion] "..content)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Load API
 | 
					-- Load API
 | 
				
			||||||
dofile(modpath.."/api.lua")
 | 
					dofile(modpath.."/api.lua")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-----------------
 | 
				
			||||||
 | 
					---- ME DATA ----
 | 
				
			||||||
 | 
					-----------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Load
 | 
				
			||||||
 | 
					function microexpansion.load()
 | 
				
			||||||
 | 
						local res = io.open(worldpath.."/microexpansion.txt", "r")
 | 
				
			||||||
 | 
						if res then
 | 
				
			||||||
 | 
							res = minetest.deserialize(res:read("*all"))
 | 
				
			||||||
 | 
							if type(res) == "table" then
 | 
				
			||||||
 | 
								microexpansion.networks = res.networks or {}
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Load
 | 
				
			||||||
 | 
					microexpansion.load()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Save
 | 
				
			||||||
 | 
					function microexpansion.save()
 | 
				
			||||||
 | 
						local data = {
 | 
				
			||||||
 | 
							networks = microexpansion.networks,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						io.open(worldpath.."/microexpansion.txt", "w"):write(minetest.serialize(data))
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [register on] Server Shutdown
 | 
				
			||||||
 | 
					minetest.register_on_shutdown(microexpansion.save)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-------------------
 | 
					-------------------
 | 
				
			||||||
----- MODULES -----
 | 
					----- MODULES -----
 | 
				
			||||||
-------------------
 | 
					-------------------
 | 
				
			||||||
@@ -27,40 +62,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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,42 +4,42 @@ local me = microexpansion
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- [register] Incranium Ore
 | 
					-- [register] Incranium Ore
 | 
				
			||||||
me.register_node("incranium", {
 | 
					me.register_node("incranium", {
 | 
				
			||||||
  description = "Incranium Ore",
 | 
						description = "Incranium Ore",
 | 
				
			||||||
  tiles = { "incranium" },
 | 
						tiles = { "incranium" },
 | 
				
			||||||
  is_ground_content = true,
 | 
						is_ground_content = true,
 | 
				
			||||||
  groups = { cracky=3, stone=1 },
 | 
						groups = { cracky=3, stone=1 },
 | 
				
			||||||
  type = "ore",
 | 
						type = "ore",
 | 
				
			||||||
  oredef = {
 | 
						oredef = {
 | 
				
			||||||
    {
 | 
							{
 | 
				
			||||||
      ore_type = "blob",
 | 
								ore_type = "blob",
 | 
				
			||||||
      wherein = "default:stone",
 | 
								wherein = "default:stone",
 | 
				
			||||||
      clust_scarcity = 4*4*4,
 | 
								clust_scarcity = 4*4*4,
 | 
				
			||||||
      clust_num_ores = 4,
 | 
								clust_num_ores = 4,
 | 
				
			||||||
      clust_size = 3,
 | 
								clust_size = 3,
 | 
				
			||||||
      y_min = -300,
 | 
								y_min = -300,
 | 
				
			||||||
      y_max = -90,
 | 
								y_max = -90,
 | 
				
			||||||
    },
 | 
							},
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  disabled = true,
 | 
						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
 | 
				
			||||||
-- float up if there are no blocks above it, so be careful!
 | 
					-- float up if there are no blocks above it, so be careful!
 | 
				
			||||||
-- Supernatet ore will be used to craft wings of flight
 | 
					-- Supernatet ore will be used to craft wings of flight
 | 
				
			||||||
me.register_node("supernatet", {
 | 
					me.register_node("supernatet", {
 | 
				
			||||||
  description = "Supernatant Ore",
 | 
						description = "Supernatant Ore",
 | 
				
			||||||
  tiles = { "default_stone.png^microexpansion_ore_supernatet.png" },
 | 
						tiles = { "default_stone.png^microexpansion_ore_supernatet.png" },
 | 
				
			||||||
  is_ground_content = true,
 | 
						is_ground_content = true,
 | 
				
			||||||
  type = "ore",
 | 
						type = "ore",
 | 
				
			||||||
  groups = { cracky=3, stone=1 },
 | 
						groups = { cracky=3, stone=1 },
 | 
				
			||||||
  oredef = {
 | 
						oredef = {
 | 
				
			||||||
    ore_type = "blob",
 | 
							ore_type = "blob",
 | 
				
			||||||
    wherein = "default:stone",
 | 
							wherein = "default:stone",
 | 
				
			||||||
    clust_scarcity = 4*4*4,
 | 
							clust_scarcity = 4*4*4,
 | 
				
			||||||
    clust_num_ores = 4,
 | 
							clust_num_ores = 4,
 | 
				
			||||||
    clust_size = 3,
 | 
							clust_size = 3,
 | 
				
			||||||
    y_min = -300,
 | 
							y_min = -300,
 | 
				
			||||||
    y_max = -90,
 | 
							y_max = -90,
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  status = "unstable",
 | 
						status = "unstable",
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,8 +4,8 @@ local me = microexpansion
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- [register node] Controller
 | 
					-- [register node] Controller
 | 
				
			||||||
me.register_node("ctrl", {
 | 
					me.register_node("ctrl", {
 | 
				
			||||||
  description = "Power Controller",
 | 
						description = "Power Controller",
 | 
				
			||||||
  tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"ctrl_sides",
 | 
							"ctrl_sides",
 | 
				
			||||||
		"ctrl_bottom",
 | 
							"ctrl_bottom",
 | 
				
			||||||
		"ctrl_sides",
 | 
							"ctrl_sides",
 | 
				
			||||||
@@ -13,8 +13,8 @@ me.register_node("ctrl", {
 | 
				
			|||||||
		"ctrl_sides",
 | 
							"ctrl_sides",
 | 
				
			||||||
		"ctrl_sides"
 | 
							"ctrl_sides"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
  drawtype = "nodebox",
 | 
						drawtype = "nodebox",
 | 
				
			||||||
  paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	node_box = {
 | 
						node_box = {
 | 
				
			||||||
		type = "fixed",
 | 
							type = "fixed",
 | 
				
			||||||
		fixed = {
 | 
							fixed = {
 | 
				
			||||||
@@ -31,29 +31,66 @@ me.register_node("ctrl", {
 | 
				
			|||||||
			{-0.1875, -0.5, -0.1875, 0.1875, -0.25, 0.1875}, -- Bottom2
 | 
								{-0.1875, -0.5, -0.1875, 0.1875, -0.25, 0.1875}, -- Bottom2
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
  groups = { cracky = 1, me_connect = 1, },
 | 
						groups = { cracky = 1, me_connect = 1, },
 | 
				
			||||||
  connect_sides = "nobottom",
 | 
						connect_sides = "nobottom",
 | 
				
			||||||
  status = "no",
 | 
						status = "unstable",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						after_place_node = function(pos, player)
 | 
				
			||||||
 | 
							local name = player:get_player_name()
 | 
				
			||||||
 | 
							local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
							local id   = power.new_id()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							meta:set_string("infotext", "Network Controller (owned by "..name..")"
 | 
				
			||||||
 | 
								.."\nNetwork ID: "..id)
 | 
				
			||||||
 | 
							meta:set_string("network_id", id)
 | 
				
			||||||
 | 
							meta:set_string("owner", name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- Initialize other meta
 | 
				
			||||||
 | 
							meta:set_int("input", 0)
 | 
				
			||||||
 | 
							meta:set_int("output", 0)
 | 
				
			||||||
 | 
							meta:set_int("storage", 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							me.networks[id] = pos
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- Trace Network
 | 
				
			||||||
 | 
							power.trace(pos)
 | 
				
			||||||
 | 
						end,
 | 
				
			||||||
 | 
						on_destruct = function(pos, player)
 | 
				
			||||||
 | 
							local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
							local id   = meta:get_string("network_id")
 | 
				
			||||||
 | 
							me.networks[id] = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- Remove unit from network
 | 
				
			||||||
 | 
							me.network_remove(pos)
 | 
				
			||||||
 | 
							-- Trace/clear network
 | 
				
			||||||
 | 
							power.trace(pos)
 | 
				
			||||||
 | 
						end,
 | 
				
			||||||
 | 
						machine = {
 | 
				
			||||||
 | 
							type = "transporter",
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [register node] Cable
 | 
					-- [register node] Cable
 | 
				
			||||||
me.register_node("cable", {
 | 
					me.register_machine("cable", {
 | 
				
			||||||
  description = "ME Cable",
 | 
						description = "ME Cable",
 | 
				
			||||||
  tiles = {
 | 
						tiles = {
 | 
				
			||||||
    "cable",
 | 
							"cable",
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  drawtype = "nodebox",
 | 
						drawtype = "nodebox",
 | 
				
			||||||
  node_box = {
 | 
						node_box = {
 | 
				
			||||||
    type = "connected",
 | 
							type = "connected",
 | 
				
			||||||
    fixed          = {-0.25, -0.25, -0.25, 0.25,  0.25, 0.25},
 | 
							fixed          = {-0.25, -0.25, -0.25, 0.25,  0.25, 0.25},
 | 
				
			||||||
		connect_top    = {-0.25, -0.25, -0.25, 0.25,  0.5,  0.25}, -- y+
 | 
							connect_top    = {-0.25, -0.25, -0.25, 0.25,  0.5,  0.25}, -- y+
 | 
				
			||||||
		connect_bottom = {-0.25, -0.5,  -0.25, 0.25,  0.25, 0.25}, -- y-
 | 
							connect_bottom = {-0.25, -0.5,  -0.25, 0.25,  0.25, 0.25}, -- y-
 | 
				
			||||||
		connect_front  = {-0.25, -0.25, -0.5,  0.25,  0.25, 0.25}, -- z-
 | 
							connect_front  = {-0.25, -0.25, -0.5,  0.25,  0.25, 0.25}, -- z-
 | 
				
			||||||
		connect_back   = {-0.25, -0.25,  0.25, 0.25,  0.25, 0.5 }, -- z+
 | 
							connect_back   = {-0.25, -0.25,  0.25, 0.25,  0.25, 0.5 }, -- z+
 | 
				
			||||||
		connect_left   = {-0.5,  -0.25, -0.25, 0.25,  0.25, 0.25}, -- x-
 | 
							connect_left   = {-0.5,  -0.25, -0.25, 0.25,  0.25, 0.25}, -- x-
 | 
				
			||||||
		connect_right  = {-0.25, -0.25, -0.25, 0.5,   0.25, 0.25}, -- x+
 | 
							connect_right  = {-0.25, -0.25, -0.25, 0.5,   0.25, 0.25}, -- x+
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  connects_to = {"group:me_connect"},
 | 
						paramtype = "light",
 | 
				
			||||||
  groups = { crumbly = 1, me_connect = 1, },
 | 
						groups = { crumbly = 1, },
 | 
				
			||||||
  status = "no",
 | 
						status = "unstable",
 | 
				
			||||||
 | 
						machine = {
 | 
				
			||||||
 | 
							type = "transporter",
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,34 +3,41 @@
 | 
				
			|||||||
local me = microexpansion
 | 
					local me = microexpansion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [register node] Fuel Fired Generator
 | 
					-- [register node] Fuel Fired Generator
 | 
				
			||||||
me.register_node("fuel_fired_generator", {
 | 
					me.register_machine("fuel_fired_generator", {
 | 
				
			||||||
  description = "Fuel-Fired Generator",
 | 
						description = "Fuel-Fired Generator",
 | 
				
			||||||
  tiles = {
 | 
						tiles = {
 | 
				
			||||||
    "machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"fuelgen_front",
 | 
							"fuelgen_front",
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  recipe = {
 | 
						recipe = {
 | 
				
			||||||
    { 1, {
 | 
							{ 1, {
 | 
				
			||||||
        { "default:steel_ingot", "default:furnace", "default:steel_ingot" },
 | 
									{ "default:steel_ingot", "default:furnace", "default:steel_ingot" },
 | 
				
			||||||
        {"default:steel_ingot", "microexpansion:machine_casing", "default:steel_ingot" },
 | 
									{"default:steel_ingot", "microexpansion:machine_casing", "default:steel_ingot" },
 | 
				
			||||||
        { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
									{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
    }
 | 
							}
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  groups = { cracky = 1, me_connect = 1, },
 | 
						groups = { cracky = 1 },
 | 
				
			||||||
  connect_sides = "machine",
 | 
						connect_sides = "machine",
 | 
				
			||||||
  paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
  status = "no",
 | 
						status = "unstable",
 | 
				
			||||||
 | 
						machine = {
 | 
				
			||||||
 | 
							type = "provider",
 | 
				
			||||||
 | 
							on_survey = function(pos)
 | 
				
			||||||
 | 
								return 5 -- Generate 5 ME/tick
 | 
				
			||||||
 | 
							end,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [register node] Super Smelter
 | 
					-- [register node] Super Smelter
 | 
				
			||||||
me.register_node("super_smelter", {
 | 
					me.register_node("super_smelter", {
 | 
				
			||||||
  description = "Super Smelter",
 | 
						description = "Super Smelter",
 | 
				
			||||||
  tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
@@ -38,24 +45,30 @@ me.register_node("super_smelter", {
 | 
				
			|||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"super_smelter_front",
 | 
							"super_smelter_front",
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
  recipe = {
 | 
						recipe = {
 | 
				
			||||||
    { 1, {
 | 
							{ 1, {
 | 
				
			||||||
        { "default:furnace", "default:furnace", "default:furnace" },
 | 
									{ "default:furnace", "default:furnace", "default:furnace" },
 | 
				
			||||||
      	{ "default:steel_ingot", "microexpansion:machine_casing", "default:steel_ingot" },
 | 
									{ "default:steel_ingot", "microexpansion:machine_casing", "default:steel_ingot" },
 | 
				
			||||||
      	{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
									{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
    },
 | 
							},
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
  groups = { cracky = 1, me_connect = 1, },
 | 
						groups = { cracky = 1, me_connect = 1, },
 | 
				
			||||||
  connect_sides = "machine",
 | 
						connect_sides = "machine",
 | 
				
			||||||
  paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
  status = "no",
 | 
						status = "unstable",
 | 
				
			||||||
 | 
						machine = {
 | 
				
			||||||
 | 
							type = "consumer",
 | 
				
			||||||
 | 
							on_survey = function(pos)
 | 
				
			||||||
 | 
								return 5 -- Consume 5 ME/tick
 | 
				
			||||||
 | 
							end,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [register item] Geothermal Generator
 | 
					-- [register item] Geothermal Generator
 | 
				
			||||||
me.register_node("geo_generator", {
 | 
					me.register_node("geo_generator", {
 | 
				
			||||||
  description = "Geothermal Generator",
 | 
						description = "Geothermal Generator",
 | 
				
			||||||
  tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
@@ -63,8 +76,14 @@ me.register_node("geo_generator", {
 | 
				
			|||||||
		"machine_sides",
 | 
							"machine_sides",
 | 
				
			||||||
		"geogen_front",
 | 
							"geogen_front",
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
  groups = { cracky = 1, me_connect = 1, },
 | 
						groups = { cracky = 1, me_connect = 1, },
 | 
				
			||||||
  connect_sides = "machine",
 | 
						connect_sides = "machine",
 | 
				
			||||||
  paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
  status = "no",
 | 
						status = "unstable",
 | 
				
			||||||
 | 
						machine = {
 | 
				
			||||||
 | 
							type = "provider",
 | 
				
			||||||
 | 
							on_survey = function(pos)
 | 
				
			||||||
 | 
								return 10 -- Generate 10 ME/tick
 | 
				
			||||||
 | 
							end,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,16 @@
 | 
				
			|||||||
-- power/init.lua
 | 
					-- power/init.lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local path = microexpansion.get_module_path("power")
 | 
					local me = microexpansion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Power generators, wires, etc...
 | 
					local networks = me.networks
 | 
				
			||||||
 | 
					local path     = microexpansion.get_module_path("power")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					me.power = {}
 | 
				
			||||||
 | 
					local power = me.power
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Load Resources
 | 
					-- Load Resources
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dofile(path.."/ctrl.lua") -- Controller
 | 
					dofile(path.."/network.lua") -- Network Management
 | 
				
			||||||
 | 
					dofile(path.."/register.lua") -- Machine Registration
 | 
				
			||||||
 | 
					dofile(path.."/ctrl.lua") -- Controller/wires
 | 
				
			||||||
dofile(path.."/gen.lua") -- Generators
 | 
					dofile(path.."/gen.lua") -- Generators
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										244
									
								
								modules/power/network.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										244
									
								
								modules/power/network.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,244 @@
 | 
				
			|||||||
 | 
					-- power/network.lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local me = microexpansion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					--- Helper Functions
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [local function] Renumber table
 | 
				
			||||||
 | 
					local function renumber_table(t)
 | 
				
			||||||
 | 
							local result = {}
 | 
				
			||||||
 | 
							for _, value in pairs(t) do
 | 
				
			||||||
 | 
									result[#result+1] = value
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							return result
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [local function] Get netitem by position
 | 
				
			||||||
 | 
					local function get_netitem_by_pos(list, pos)
 | 
				
			||||||
 | 
						for _, i in pairs(list) do
 | 
				
			||||||
 | 
							if vector.equals(pos, i.pos) then
 | 
				
			||||||
 | 
								return i
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					--- API Functions
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Get node
 | 
				
			||||||
 | 
					function me.get_node(pos)
 | 
				
			||||||
 | 
						local node = minetest.get_node_or_nil(pos)
 | 
				
			||||||
 | 
						if node then return node end
 | 
				
			||||||
 | 
						local vm = VoxelManip()
 | 
				
			||||||
 | 
						local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
 | 
				
			||||||
 | 
						return minetest.get_node(pos)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Generate new network ID
 | 
				
			||||||
 | 
					function power.new_id()
 | 
				
			||||||
 | 
						local count = 1
 | 
				
			||||||
 | 
						for _, i in pairs(me.networks) do
 | 
				
			||||||
 | 
							count = count + 1
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return "network_"..count
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Can connect
 | 
				
			||||||
 | 
					function power.can_connect(pos)
 | 
				
			||||||
 | 
						local node = me.get_node(pos)
 | 
				
			||||||
 | 
						local res  = minetest.get_item_group(node.name, "me_connect")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if res == 1 then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							return false
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Get connected nodes
 | 
				
			||||||
 | 
					function power.get_connected_nodes(pos, include_ctrl)
 | 
				
			||||||
 | 
						local nodes = {
 | 
				
			||||||
 | 
								{x=pos.x+1, y=pos.y,   z=pos.z},
 | 
				
			||||||
 | 
								{x=pos.x-1, y=pos.y,   z=pos.z},
 | 
				
			||||||
 | 
								{x=pos.x,   y=pos.y+1, z=pos.z},
 | 
				
			||||||
 | 
								{x=pos.x,   y=pos.y-1, z=pos.z},
 | 
				
			||||||
 | 
								{x=pos.x,   y=pos.y,   z=pos.z+1},
 | 
				
			||||||
 | 
								{x=pos.x,   y=pos.y,   z=pos.z-1},
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, pos in pairs(nodes) do
 | 
				
			||||||
 | 
							if not power.can_connect(pos) then
 | 
				
			||||||
 | 
								nodes[_] = nil
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								if include_ctrl == false then
 | 
				
			||||||
 | 
									if me.get_node(pos).name == "microexpansion:ctrl" then
 | 
				
			||||||
 | 
										nodes[_] = nil
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return renumber_table(nodes)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Add machine to network
 | 
				
			||||||
 | 
					function power.add_machine(pos, def)
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Remove machine from network
 | 
				
			||||||
 | 
					function power.remove_machine(pos)
 | 
				
			||||||
 | 
						local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
						meta:set_string("network_ignore", "true")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Trace network
 | 
				
			||||||
 | 
					function power.trace(pos)
 | 
				
			||||||
 | 
						local netpos = me.networks[minetest.get_meta(pos):get_string("network_id")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- if no network, return
 | 
				
			||||||
 | 
						if not netpos then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local meta  = minetest.get_meta(netpos)
 | 
				
			||||||
 | 
						local netid = meta:get_string("network_id")
 | 
				
			||||||
 | 
						local list  = {}
 | 
				
			||||||
 | 
						local demand
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local delete = false
 | 
				
			||||||
 | 
						if meta:get_string("network_ignore") == "true" then
 | 
				
			||||||
 | 
							delete = true
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- [local function] Indexed
 | 
				
			||||||
 | 
						local function indexed(pos)
 | 
				
			||||||
 | 
							for _, i in pairs(list) do
 | 
				
			||||||
 | 
								if vector.equals(pos, i.pos) then
 | 
				
			||||||
 | 
									return true
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- [local function] Trace
 | 
				
			||||||
 | 
						local function trace(nodes)
 | 
				
			||||||
 | 
							for _, pos in pairs(nodes) do
 | 
				
			||||||
 | 
								if not indexed(pos) then
 | 
				
			||||||
 | 
									local machine = minetest.get_meta(pos)
 | 
				
			||||||
 | 
									if machine:get_string("network_ignore") ~= "true" then
 | 
				
			||||||
 | 
										local node = me.get_node(pos).name
 | 
				
			||||||
 | 
										local desc = minetest.registered_nodes[node].description
 | 
				
			||||||
 | 
										if delete then
 | 
				
			||||||
 | 
											machine:set_string("network_id", nil)
 | 
				
			||||||
 | 
											machine:set_string("infotext", desc.."\nNo Network")
 | 
				
			||||||
 | 
											me.network_set_demand(pos, 0)
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
											machine:set_string("network_id", netid)
 | 
				
			||||||
 | 
											machine:set_string("infotext", desc.."\nNetwork ID: "..netid)
 | 
				
			||||||
 | 
										end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										list[#list + 1] = { pos = pos, demand = machine:get_int("demand") }
 | 
				
			||||||
 | 
										trace(power.get_connected_nodes(pos, false))
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						trace(power.get_connected_nodes(netpos))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- Check original list
 | 
				
			||||||
 | 
						local original = minetest.deserialize(meta:get_string("netitems"))
 | 
				
			||||||
 | 
						if original then
 | 
				
			||||||
 | 
							for _, i in pairs(original) do
 | 
				
			||||||
 | 
								if not indexed(i.pos) then
 | 
				
			||||||
 | 
									local node = me.get_node(i.pos).name
 | 
				
			||||||
 | 
									local desc = minetest.registered_nodes[node].description
 | 
				
			||||||
 | 
									local machine = minetest.get_meta(i.pos)
 | 
				
			||||||
 | 
									machine:set_string("network_id", nil)
 | 
				
			||||||
 | 
									machine:set_string("infotext", desc.."\nNo Network")
 | 
				
			||||||
 | 
									me.network_set_demand(pos, 0)
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						meta:set_string("netitems", minetest.serialize(list))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- Update infotext
 | 
				
			||||||
 | 
						meta:set_string("infotext", "Network Controller (owned by "..
 | 
				
			||||||
 | 
							meta:get_string("owner")..")\nNetwork ID: "..meta:get_string("network_id")..
 | 
				
			||||||
 | 
							"\nDemand: "..dump(me.network_get_demand(netpos)))
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					--- Load Management
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Get load information
 | 
				
			||||||
 | 
					function me.network_get_load(pos)
 | 
				
			||||||
 | 
						local ctrl = me.networks[minetest.get_meta(pos):get_string("network_id")]
 | 
				
			||||||
 | 
						if ctrl then
 | 
				
			||||||
 | 
							local meta = minetest.get_meta(ctrl)
 | 
				
			||||||
 | 
							local list = minetest.deserialize(meta:get_string("netitems"))
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---- Generators ----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---- Output ----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Get total network demand
 | 
				
			||||||
 | 
					function me.network_get_demand(pos)
 | 
				
			||||||
 | 
						local ctrl = me.networks[minetest.get_meta(pos):get_string("network_id")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- if no network, return
 | 
				
			||||||
 | 
						if not ctrl then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local meta = minetest.get_meta(ctrl)
 | 
				
			||||||
 | 
						local list = minetest.deserialize(meta:get_string("netitems"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local demand = 0
 | 
				
			||||||
 | 
						for _, i in pairs(list) do
 | 
				
			||||||
 | 
							if i.demand then
 | 
				
			||||||
 | 
								demand = demand + i.demand
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return demand
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Set demand for machine
 | 
				
			||||||
 | 
					function me.network_set_demand(pos, demand)
 | 
				
			||||||
 | 
						-- Update original metadata
 | 
				
			||||||
 | 
						minetest.get_meta(pos):set_int("demand", demand)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local ctrl = me.networks[minetest.get_meta(pos):get_string("network_id")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- if no network, return
 | 
				
			||||||
 | 
						if not ctrl then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local meta = minetest.get_meta(ctrl)
 | 
				
			||||||
 | 
						local list = minetest.deserialize(meta:get_string("netitems"))
 | 
				
			||||||
 | 
						local item = get_netitem_by_pos(list, pos)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if not item then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						item.demand = demand
 | 
				
			||||||
 | 
						meta:set_string("netitems", minetest.serialize(list))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- Update infotext
 | 
				
			||||||
 | 
						meta:set_string("infotext", "Network Controller (owned by "..
 | 
				
			||||||
 | 
							meta:get_string("owner")..")\nNetwork ID: "..meta:get_string("network_id")..
 | 
				
			||||||
 | 
							"\nDemand: "..dump(me.network_get_demand(pos)))
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---- Storage ----
 | 
				
			||||||
							
								
								
									
										88
									
								
								modules/power/register.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								modules/power/register.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,88 @@
 | 
				
			|||||||
 | 
					-- power/register.lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--[[ Machine Registration API ]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local me = microexpansion
 | 
				
			||||||
 | 
					local power = me.power
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Register machine
 | 
				
			||||||
 | 
					function me.register_machine(itemstring, def)
 | 
				
			||||||
 | 
						-- Set after_place_node
 | 
				
			||||||
 | 
						def.after_place_node = function(pos, player)
 | 
				
			||||||
 | 
							if def.after_place_node then
 | 
				
			||||||
 | 
								def.after_place_node(pos, player)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							local meta  = minetest.get_meta(pos)
 | 
				
			||||||
 | 
							local nodes = me.get_connected_nodes(pos)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							meta:set_string("infotext", def.description.."\nNo Network")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for _, pos2 in pairs(nodes) do
 | 
				
			||||||
 | 
								local id = minetest.get_meta(pos2):get_string("network_id")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if id ~= "" then
 | 
				
			||||||
 | 
									meta:set_string("infotext", def.description.."\nNetwork ID: "..id)
 | 
				
			||||||
 | 
									meta:set_string("network_id", id)
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- Trace Network
 | 
				
			||||||
 | 
							power.trace(pos)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- Set demand
 | 
				
			||||||
 | 
							if def.demand then
 | 
				
			||||||
 | 
								me.network_set_demand(pos, def.demand)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if type(def.machine) == "table" then
 | 
				
			||||||
 | 
								power.add_machine(pos, def.machine)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						-- Set on_destruct
 | 
				
			||||||
 | 
						def.on_destruct = function(pos, player)
 | 
				
			||||||
 | 
							if def.on_destruct then
 | 
				
			||||||
 | 
								def.on_destruct(pos, player)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if meta:get_string("network_id") ~= "" then
 | 
				
			||||||
 | 
								-- Set demand
 | 
				
			||||||
 | 
								me.network_set_demand(pos, 0)
 | 
				
			||||||
 | 
								-- Remove item from network
 | 
				
			||||||
 | 
								me.network_remove(pos)
 | 
				
			||||||
 | 
								-- Retrace Network
 | 
				
			||||||
 | 
								power.trace(pos)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						-- Set connects_to
 | 
				
			||||||
 | 
						def.connects_to = {"group:me_connect"}
 | 
				
			||||||
 | 
						-- Set me_connect group
 | 
				
			||||||
 | 
						def.groups = def.groups or {}
 | 
				
			||||||
 | 
						def.groups.me_connect = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						me.register_node(itemstring, def)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- [function] Get machine definition
 | 
				
			||||||
 | 
					function me.get_def(name, key)
 | 
				
			||||||
 | 
						if type(name) == "table" then
 | 
				
			||||||
 | 
							local node = me.get_node(name)
 | 
				
			||||||
 | 
							if node then
 | 
				
			||||||
 | 
								name = node.name
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local def = minetest.registered_nodes[name]
 | 
				
			||||||
 | 
						-- Check name and if registered
 | 
				
			||||||
 | 
						if not name or not def then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if key then
 | 
				
			||||||
 | 
							return def[key]
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							return def
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
@@ -7,24 +7,24 @@ local me = microexpansion
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- [register item] Steel Infused Obsidian Ingot
 | 
					-- [register item] Steel Infused Obsidian Ingot
 | 
				
			||||||
me.register_item("steel_infused_obsidian_ingot", {
 | 
					me.register_item("steel_infused_obsidian_ingot", {
 | 
				
			||||||
  description = "Steel Infused Obsidian Ingot",
 | 
						description = "Steel Infused Obsidian Ingot",
 | 
				
			||||||
  recipe = {
 | 
						recipe = {
 | 
				
			||||||
    { 1, {
 | 
							{ 1, {
 | 
				
			||||||
        { "default:steel_ingot", "default:obsidian_shard", "default:steel_ingot" },
 | 
									{ "default:steel_ingot", "default:obsidian_shard", "default:steel_ingot" },
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
    },
 | 
							},
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [register item] Machine Casing
 | 
					-- [register item] Machine Casing
 | 
				
			||||||
me.register_item("machine_casing", {
 | 
					me.register_item("machine_casing", {
 | 
				
			||||||
  description = "Machine Casing",
 | 
						description = "Machine Casing",
 | 
				
			||||||
  recipe = {
 | 
						recipe = {
 | 
				
			||||||
    { 1, {
 | 
							{ 1, {
 | 
				
			||||||
        {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
 | 
									{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
 | 
				
			||||||
    		{"default:steel_ingot", "default:copper_ingot", "default:steel_ingot"},
 | 
									{"default:steel_ingot", "default:copper_ingot", "default:steel_ingot"},
 | 
				
			||||||
    		{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
 | 
									{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
    },
 | 
							},
 | 
				
			||||||
  },
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,97 +4,97 @@ local BASENAME = "microexpansion"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- [function] register cell
 | 
					-- [function] register cell
 | 
				
			||||||
function microexpansion.register_cell(itemstring, def)
 | 
					function microexpansion.register_cell(itemstring, def)
 | 
				
			||||||
  if not def.inventory_image then
 | 
						if not def.inventory_image then
 | 
				
			||||||
    def.inventory_image = itemstring
 | 
							def.inventory_image = itemstring
 | 
				
			||||||
  end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- register craftitem
 | 
						-- register craftitem
 | 
				
			||||||
  minetest.register_craftitem(BASENAME..":"..itemstring, {
 | 
						minetest.register_craftitem(BASENAME..":"..itemstring, {
 | 
				
			||||||
    description = def.description,
 | 
							description = def.description,
 | 
				
			||||||
    inventory_image = BASENAME.."_"..def.inventory_image..".png",
 | 
							inventory_image = BASENAME.."_"..def.inventory_image..".png",
 | 
				
			||||||
    groups = {microexpansion_cell = 1},
 | 
							groups = {microexpansion_cell = 1},
 | 
				
			||||||
    stack_max = 1,
 | 
							stack_max = 1,
 | 
				
			||||||
    microexpansion = {
 | 
							microexpansion = {
 | 
				
			||||||
      base_desc = def.description,
 | 
								base_desc = def.description,
 | 
				
			||||||
      drive = {
 | 
								drive = {
 | 
				
			||||||
        capacity = def.capacity or 5000,
 | 
									capacity = def.capacity or 5000,
 | 
				
			||||||
      },
 | 
								},
 | 
				
			||||||
    },
 | 
							},
 | 
				
			||||||
  })
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- if recipe, register recipe
 | 
						-- if recipe, register recipe
 | 
				
			||||||
  if def.recipe then
 | 
						if def.recipe then
 | 
				
			||||||
    -- 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
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [function] Get cell size
 | 
					-- [function] Get cell size
 | 
				
			||||||
function microexpansion.get_cell_size(name)
 | 
					function microexpansion.get_cell_size(name)
 | 
				
			||||||
  local item = minetest.registered_craftitems[name]
 | 
						local item = minetest.registered_craftitems[name]
 | 
				
			||||||
  if item then
 | 
						if item then
 | 
				
			||||||
    return item.microexpansion.drive.capacity
 | 
							return item.microexpansion.drive.capacity
 | 
				
			||||||
  end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [function] Calculate max stacks
 | 
					-- [function] Calculate max stacks
 | 
				
			||||||
function microexpansion.int_to_stacks(int)
 | 
					function microexpansion.int_to_stacks(int)
 | 
				
			||||||
  return math.floor(int / 99)
 | 
						return math.floor(int / 99)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [function] Calculate number of pages
 | 
					-- [function] Calculate number of pages
 | 
				
			||||||
function microexpansion.int_to_pagenum(int)
 | 
					function microexpansion.int_to_pagenum(int)
 | 
				
			||||||
  return math.floor(microexpansion.int_to_stacks(int) / 32)
 | 
						return math.floor(microexpansion.int_to_stacks(int) / 32)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [function] Move items from inv to inv
 | 
					-- [function] Move items from inv to inv
 | 
				
			||||||
function microexpansion.move_inv(inv1, inv2)
 | 
					function microexpansion.move_inv(inv1, inv2)
 | 
				
			||||||
  local finv, tinv   = inv1.inv, inv2.inv
 | 
						local finv, tinv   = inv1.inv, inv2.inv
 | 
				
			||||||
  local fname, tname = inv1.name, inv2.name
 | 
						local fname, tname = inv1.name, inv2.name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for i,v in ipairs(finv:get_list(fname) or {}) do
 | 
						for i,v in ipairs(finv:get_list(fname) or {}) do
 | 
				
			||||||
    if tinv and tinv:room_for_item(tname, v) then
 | 
							if tinv and tinv:room_for_item(tname, v) then
 | 
				
			||||||
      local leftover = tinv:add_item( tname, v )
 | 
								local leftover = tinv:add_item( tname, v )
 | 
				
			||||||
      finv:remove_item(fname, v)
 | 
								finv:remove_item(fname, v)
 | 
				
			||||||
      if leftover and not(leftover:is_empty()) then
 | 
								if leftover and not(leftover:is_empty()) then
 | 
				
			||||||
        finv:add_item(fname, v)
 | 
									finv:add_item(fname, v)
 | 
				
			||||||
      end
 | 
								end
 | 
				
			||||||
    end
 | 
							end
 | 
				
			||||||
  end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [function] Update cell description
 | 
					-- [function] Update cell description
 | 
				
			||||||
function microexpansion.cell_desc(inv, listname, spos)
 | 
					function microexpansion.cell_desc(inv, listname, spos)
 | 
				
			||||||
  local stack = inv:get_stack(listname, spos)
 | 
						local stack = inv:get_stack(listname, spos)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if stack:get_name() ~= "" then
 | 
						if stack:get_name() ~= "" then
 | 
				
			||||||
    local meta      = stack:get_meta()
 | 
							local meta      = stack:get_meta()
 | 
				
			||||||
    local base_desc = minetest.registered_craftitems[stack:get_name()].microexpansion.base_desc
 | 
							local base_desc = minetest.registered_craftitems[stack:get_name()].microexpansion.base_desc
 | 
				
			||||||
  	local max_slots = inv:get_size("main")
 | 
							local max_slots = inv:get_size("main")
 | 
				
			||||||
  	local max_items = math.floor(max_slots * 99)
 | 
							local max_items = math.floor(max_slots * 99)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  	local slots, items = 0, 0
 | 
							local slots, items = 0, 0
 | 
				
			||||||
  	-- Get amount of items in drive
 | 
							-- Get amount of items in drive
 | 
				
			||||||
  	for i = 1, max_items do
 | 
							for i = 1, max_items do
 | 
				
			||||||
  		local stack = inv:get_stack("main", i)
 | 
								local stack = inv:get_stack("main", i)
 | 
				
			||||||
  		local item = stack:get_name()
 | 
								local item = stack:get_name()
 | 
				
			||||||
  		if item ~= "" then
 | 
								if item ~= "" then
 | 
				
			||||||
  			slots = slots + 1
 | 
									slots = slots + 1
 | 
				
			||||||
  			local num = stack:get_count()
 | 
									local num = stack:get_count()
 | 
				
			||||||
  			if num == 0 then num = 1 end
 | 
									if num == 0 then num = 1 end
 | 
				
			||||||
  			items = items + num
 | 
									items = items + num
 | 
				
			||||||
  		end
 | 
								end
 | 
				
			||||||
    end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- Calculate Percentage
 | 
							-- Calculate Percentage
 | 
				
			||||||
    local percent = math.floor(items / max_items * 100)
 | 
							local percent = math.floor(items / max_items * 100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- Update description
 | 
							-- Update description
 | 
				
			||||||
    meta:set_string("description", base_desc.."\n"..
 | 
							meta:set_string("description", base_desc.."\n"..
 | 
				
			||||||
      minetest.colorize("grey", tostring(items).."/"..tostring(max_items).." Items ("..tostring(percent).."%)"))
 | 
								minetest.colorize("grey", tostring(items).."/"..tostring(max_items).." Items ("..tostring(percent).."%)"))
 | 
				
			||||||
    -- Update stack
 | 
							-- Update stack
 | 
				
			||||||
    inv:set_stack(listname, spos, stack)
 | 
							inv:set_stack(listname, spos, stack)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,24 +2,24 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- [drive] 8k
 | 
					-- [drive] 8k
 | 
				
			||||||
microexpansion.register_cell("cell_8k", {
 | 
					microexpansion.register_cell("cell_8k", {
 | 
				
			||||||
  description = "8k ME Storage Cell",
 | 
						description = "8k ME Storage Cell",
 | 
				
			||||||
  capacity = 8000,
 | 
						capacity = 8000,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [drive] 16k
 | 
					-- [drive] 16k
 | 
				
			||||||
microexpansion.register_cell("cell_16k", {
 | 
					microexpansion.register_cell("cell_16k", {
 | 
				
			||||||
  description = "16k ME Storage Cell",
 | 
						description = "16k ME Storage Cell",
 | 
				
			||||||
  capacity = 16000,
 | 
						capacity = 16000,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [drive] 32k
 | 
					-- [drive] 32k
 | 
				
			||||||
microexpansion.register_cell("cell_32k", {
 | 
					microexpansion.register_cell("cell_32k", {
 | 
				
			||||||
  description = "32k ME Storage Cell",
 | 
						description = "32k ME Storage Cell",
 | 
				
			||||||
  capacity = 32000,
 | 
						capacity = 32000,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- [drive] 64k
 | 
					-- [drive] 64k
 | 
				
			||||||
microexpansion.register_cell("cell_64k", {
 | 
					microexpansion.register_cell("cell_64k", {
 | 
				
			||||||
  description = "64k ME Storage Cell",
 | 
						description = "64k ME Storage Cell",
 | 
				
			||||||
  capacity = 64000,
 | 
						capacity = 64000,
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,9 +2,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- [register tool] Pickaxe
 | 
					-- [register tool] Pickaxe
 | 
				
			||||||
minetest.register_tool("microexpansion:xtremo_pickaxe", {
 | 
					minetest.register_tool("microexpansion:xtremo_pickaxe", {
 | 
				
			||||||
  description = "In Xtremo Pickaxe",
 | 
						description = "In Xtremo Pickaxe",
 | 
				
			||||||
  inventory_image = "microexpansion_in_xtremo_pickaxe.png",
 | 
						inventory_image = "microexpansion_in_xtremo_pickaxe.png",
 | 
				
			||||||
  tool_capabilities = {
 | 
						tool_capabilities = {
 | 
				
			||||||
		full_punch_interval = 0.9,
 | 
							full_punch_interval = 0.9,
 | 
				
			||||||
		max_drop_level=3,
 | 
							max_drop_level=3,
 | 
				
			||||||
		groupcaps={
 | 
							groupcaps={
 | 
				
			||||||
@@ -16,9 +16,9 @@ minetest.register_tool("microexpansion:xtremo_pickaxe", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- [register tool] Axe
 | 
					-- [register tool] Axe
 | 
				
			||||||
minetest.register_tool("microexpansion:xtremo_axe", {
 | 
					minetest.register_tool("microexpansion:xtremo_axe", {
 | 
				
			||||||
  description = "In Xtremo Axe",
 | 
						description = "In Xtremo Axe",
 | 
				
			||||||
  inventory_image = "microexpansion_in_xtremo_axe.png",
 | 
						inventory_image = "microexpansion_in_xtremo_axe.png",
 | 
				
			||||||
  tool_capabilities = {
 | 
						tool_capabilities = {
 | 
				
			||||||
		full_punch_interval = 0.9,
 | 
							full_punch_interval = 0.9,
 | 
				
			||||||
		max_drop_level=3,
 | 
							max_drop_level=3,
 | 
				
			||||||
		groupcaps={
 | 
							groupcaps={
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user