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