mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-12-25 15:02:25 +01:00
fix code style
This commit is contained in:
parent
48874e4598
commit
d0e2a070bd
@ -19,6 +19,8 @@ ignore = {
|
||||
"211",
|
||||
"212",
|
||||
"213",
|
||||
"422",
|
||||
"432",
|
||||
"611",
|
||||
"612",
|
||||
"621",
|
||||
|
34
api.lua
34
api.lua
@ -1,6 +1,8 @@
|
||||
-- microexpansion/api.lua
|
||||
local BASENAME = "microexpansion"
|
||||
|
||||
--FIXME: this is very full of bad coding
|
||||
|
||||
-- [function] Register Recipe
|
||||
function microexpansion.register_recipe(output, recipe)
|
||||
-- Check if disabled
|
||||
@ -33,36 +35,26 @@ function microexpansion.register_recipe(output, recipe)
|
||||
minetest.register_craft(def)
|
||||
end
|
||||
|
||||
for _, i in ipairs(recipe) do
|
||||
-- Check if disabled
|
||||
if recipe.disabled == true then
|
||||
return
|
||||
end
|
||||
-- Check if disabled
|
||||
if recipe.disabled == true then
|
||||
return
|
||||
end
|
||||
|
||||
register(_)
|
||||
for i in ipairs(recipe) do
|
||||
register(i)
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Register oredef
|
||||
function microexpansion.register_oredef(ore, def)
|
||||
function microexpansion.register_oredef(ore, defs)
|
||||
-- Check if disabled
|
||||
if def.disabled == true then
|
||||
if defs.disabled == true then
|
||||
return
|
||||
end
|
||||
|
||||
local function register(_)
|
||||
local def = def[_]
|
||||
def.ore = "microexpansion:"..ore
|
||||
minetest.register_ore(def)
|
||||
end
|
||||
|
||||
for _, i in ipairs(def) do
|
||||
-- Check if disabled
|
||||
if def.disabled == true then
|
||||
return
|
||||
end
|
||||
|
||||
register(_)
|
||||
for _,d in ipairs(defs) do
|
||||
d.ore = "microexpansion:"..ore
|
||||
minetest.register_ore(d)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,7 +28,7 @@ me.register_machine("fuel_fired_generator", {
|
||||
status = "unstable",
|
||||
machine = {
|
||||
type = "provider",
|
||||
on_survey = function(pos)
|
||||
on_survey = function() -- args: pos
|
||||
--TODO: burn fuel
|
||||
return 5 -- Generate 5 ME/tick
|
||||
end,
|
||||
|
@ -7,15 +7,6 @@ local power = me.power
|
||||
--- Helper Functions
|
||||
---
|
||||
|
||||
-- [local function] Renumber table
|
||||
local function renumber_table(t)
|
||||
local result = {}
|
||||
for _, value in pairs(t) do
|
||||
table.insert(result,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
|
||||
@ -53,7 +44,6 @@ function power.trace(pos)
|
||||
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
|
||||
@ -61,9 +51,9 @@ function power.trace(pos)
|
||||
end
|
||||
|
||||
-- [local function] Indexed
|
||||
local function indexed(pos)
|
||||
local function indexed(p)
|
||||
for _, i in pairs(list) do
|
||||
if vector.equals(pos, i.pos) then
|
||||
if vector.equals(p, i.pos) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -71,23 +61,23 @@ function power.trace(pos)
|
||||
|
||||
-- [local function] Trace
|
||||
local function trace(nodes)
|
||||
for _, pos in pairs(nodes) do
|
||||
if not indexed(pos) then
|
||||
local machine = minetest.get_meta(pos)
|
||||
for _, p in pairs(nodes) do
|
||||
if not indexed(p) then
|
||||
local machine = minetest.get_meta(p)
|
||||
if machine:get_string("network_ignore") ~= "true" then
|
||||
local node = me.get_node(pos).name
|
||||
local node = me.get_node(p).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)
|
||||
me.network_set_demand(p, 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))
|
||||
list[#list + 1] = { pos = p, demand = machine:get_int("demand") }
|
||||
trace(power.get_connected_nodes(p, false))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -80,12 +80,12 @@ microexpansion.register_node("drive", {
|
||||
me.update_connected_machines(pos)
|
||||
return
|
||||
end
|
||||
for _,stack in pairs(items) do
|
||||
me.insert_item(stack, ctrl_inv, "main")
|
||||
for _,s in pairs(items) do
|
||||
me.insert_item(s, ctrl_inv, "main")
|
||||
end
|
||||
me.update_connected_machines(pos)
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
allow_metadata_inventory_take = function(pos,_,_,stack) --args: pos, listname, index, stack, player
|
||||
--FIXME sometimes items vanish if one cell is filled
|
||||
local meta = minetest.get_meta(pos)
|
||||
local own_inv = meta:get_inventory()
|
||||
|
Loading…
Reference in New Issue
Block a user