Add GitHub workflow and luacheck (#545)

Add badge to README
Fix luacheck warnings
Remove node_ownership globals (and support)
This commit is contained in:
David Leal 2020-06-12 13:39:00 -05:00 committed by GitHub
parent befe3ecc86
commit a8daa417c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 115 additions and 80 deletions

11
.github/workflows/check-release.yml vendored Normal file
View File

@ -0,0 +1,11 @@
on: [push, pull_request]
name: Check & Release
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: https://raw.githubusercontent.com/minetest-mods/technic/master/.luacheckrc

48
.luacheckrc Normal file
View File

@ -0,0 +1,48 @@
unused_args = false
allow_defined_top = true
max_line_length = 999
globals = {
"technic", "minetest",
"srcstack",
}
read_globals = {
string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn"}},
"intllib", "VoxelArea",
"default", "stairsplus",
"PseudoRandom", "ItemStack",
"mg", "tubelib", "vector",
"moretrees", "bucket",
"unified_inventory", "digilines",
"pipeworks", "screwdriver",
"VoxelManip", "unifieddyes",
"Settings", "mesecon",
"digiline_remote",
"protector", "isprotect",
"homedecor_expect_infinite_stacks",
}
files["concrete/init.lua"].ignore = { "steel_ingot" }
files["technic/machines/MV/tool_workshop.lua"].ignore = { "pos" }
files["technic/machines/other/frames.lua"].ignore = { "item_texture", "item_type", "adj", "connected", "" }
files["technic/machines/register/battery_box.lua"].ignore = { "pos", "tube_upgrade" }
files["technic/machines/register/cables.lua"].ignore = { "name", "from_below", "p" }
files["technic/machines/register/common.lua"].ignore = { "result" }
files["technic/machines/register/generator.lua"].ignore = { "node" }
files["technic/machines/switching_station.lua"].ignore = { "pos1", "tier", "poshash" }
files["technic/radiation.lua"].ignore = { "LAVA_VISC" }
files["technic/tools/chainsaw.lua"].ignore = { "pos" }
files["technic/tools/mining_drill.lua"].ignore = { "mode" }
files["technic_chests/register.lua"].ignore = { "fs_helpers", "name", "locked_after_place" }
files["technic_cnc/cnc.lua"].ignore = { "multiplier" }
files["wrench/init.lua"].ignore = { "name", "stack" }

View File

@ -1,6 +1,9 @@
Technic
=======
[![Build status](https://github.com/minetest-mods/technic/workflows/Check%20&%20Release/badge.svg)](https://github.com/minetest-mods/technic/actions)
[![License](https://img.shields.io/badge/license-LGPLv2.0%2B-purple.svg)](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html)
Credits for contributing to the project (in alphabetical order):
* kpoppel
* Nekogloop

View File

@ -83,7 +83,7 @@ function technic.get_or_load_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)
local _, _ = vm:read_from_map(pos, pos)
return nil
end

View File

@ -455,7 +455,7 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", {
technic_run = run,
technic_on_disable = function(pos, node)
local timer = minetest.get_node_timer(pos)
timer:start(1)
timer:start(1)
end,
on_timer = function(pos, node)
local meta = minetest.get_meta(pos)

View File

@ -27,7 +27,7 @@ minetest.register_craftitem("technic:geothermal", {
local check_node_around = function(pos)
local node = minetest.get_node(pos)
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end
if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end
if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end
return 0
end

View File

@ -24,7 +24,6 @@ local run = function(pos, node)
local meta = minetest.get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local machine_name = S("%s Music Player"):format("LV")
local machine_node = "technic:music_player"
local demand = 150
local current_track = meta:get_int("current_track")

View File

@ -51,7 +51,7 @@ minetest.register_node("technic:solar_panel", {
technic_machine=1, technic_lv=1},
connect_sides = {"bottom"},
sounds = default.node_sound_wood_defaults(),
description = S("Small Solar %s Generator"):format("LV"),
description = S("Small Solar %s Generator"):format("LV"),
active = false,
drawtype = "nodebox",
paramtype = "light",

View File

@ -29,8 +29,8 @@ end
local run = function(pos, node)
local meta = minetest.get_meta(pos)
local water_flow = 0
local production_level = 0
local eu_supply = 0
local production_level
local eu_supply
local max_output = 4 * 45 -- keeping it around 180, little more than previous 150 :)
local positions = {

View File

@ -30,8 +30,8 @@ end
local run = function(pos, node)
local meta = minetest.get_meta(pos)
local water_flow = 0
local production_level = 0
local eu_supply = 0
local production_level
local eu_supply
local max_output = 40 * 45 -- Generates 1800EU/s
local positions = {

View File

@ -45,7 +45,6 @@ function technic_homedecor_node_is_owned(pos, placer)
end
end
local dirs1 = {20, 23, 22, 21}
local dirs2 = {9, 18, 7, 12}
local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_thing)
@ -58,7 +57,6 @@ local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_t
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local pname = minetest.get_node(under).name
local node = minetest.get_node(above)
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local wield_name = itemstack:get_name()
@ -159,7 +157,7 @@ minetest.register_node('technic:homedecor_glowlight_half_yellow_active', {
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
light_source = LIGHT_MAX,
light_source = minetest.LIGHT_MAX,
sounds = default.node_sound_wood_defaults(),
groups = { snappy = 3, not_in_creative_inventory=1},
@ -240,7 +238,7 @@ minetest.register_node('technic:homedecor_glowlight_quarter_yellow_active', {
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
light_source = LIGHT_MAX-1,
light_source = minetest.LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
groups = { snappy = 3, not_in_creative_inventory=1},
@ -322,7 +320,7 @@ minetest.register_node('technic:homedecor_glowlight_half_white_active', {
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
light_source = LIGHT_MAX,
light_source = minetest.LIGHT_MAX,
sounds = default.node_sound_wood_defaults(),
groups = { snappy = 3, not_in_creative_inventory=1},
@ -403,7 +401,7 @@ minetest.register_node('technic:homedecor_glowlight_quarter_white_active', {
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
light_source = LIGHT_MAX-1,
light_source = minetest.LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
groups = { snappy = 3, not_in_creative_inventory=1},
@ -484,7 +482,7 @@ minetest.register_node('technic:homedecor_glowlight_small_cube_yellow_active', {
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
light_source = LIGHT_MAX-1,
light_source = minetest.LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
groups = { snappy = 3, not_in_creative_inventory=1},
@ -565,7 +563,7 @@ minetest.register_node('technic:homedecor_glowlight_small_cube_white_active', {
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
light_source = LIGHT_MAX-1,
light_source = minetest.LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
groups = { snappy = 3, not_in_creative_inventory=1},

View File

@ -177,8 +177,6 @@ minetest.register_abm({
-- The supply radius
local rad = power_radius
local meta1 = nil
local pos1 = {}
local used_charge = 0
-- Index all nodes within supply range

View File

@ -39,7 +39,6 @@ local run = function(pos, node)
local inv = meta:get_inventory()
local eu_input = meta:get_int("MV_EU_input")
local machine_name = S("%s Tool Workshop"):format("MV")
local machine_node = "technic:tool_workshop"
-- Setup meta data if it does not exist.
if not eu_input then
@ -71,7 +70,7 @@ local run = function(pos, node)
meta:set_int("MV_EU_demand", 0)
return
end
if eu_input < workshop_demand[EU_upgrade+1] then
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= workshop_demand[EU_upgrade+1] then
@ -105,7 +104,7 @@ minetest.register_node("technic:tool_workshop", {
inv:set_size("src", 1)
inv:set_size("upgrade1", 1)
inv:set_size("upgrade2", 1)
end,
end,
can_dig = technic.machine_can_dig,
allow_metadata_inventory_put = technic.machine_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,

View File

@ -77,14 +77,12 @@ minetest.register_abm({
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if inv:get_size("src") == 1 then -- Old furnace -> convert it
inv:set_size("src", 2)
inv:set_stack("src", 2, inv:get_stack("src2", 1))
inv:set_size("src2", 0)
end
local recipe = nil
for i, name in pairs({
"fuel_totaltime",

View File

@ -1,7 +1,5 @@
local S = technic.getter
frames = {}
local infinite_stacks = minetest.settings:get_bool("creative_mode")
and minetest.get_modpath("unified_inventory") == nil
@ -100,7 +98,7 @@ end
local function add_table(table, toadd)
local i = 1
while true do
o = table[i]
local o = table[i]
if o == toadd then return end
if o == nil then break end
i = i + 1
@ -261,8 +259,8 @@ for zp = 0, 1 do
sunlight_propagates = true,
frame_connect_all = function(nodename)
l2 = {}
l1 = {
local l2 = {}
local l1 = {
{ x = -1, y = 0, z = 0 }, { x = 1, y = 0, z = 0 },
{ x = 0, y = -1, z = 0 }, { x = 0, y = 1, z = 0 },
{ x = 0, y = 0, z = -1 }, { x = 0, y = 0, z = 1 }
@ -311,7 +309,7 @@ for zp = 0, 1 do
local node = minetest.get_node(pos)
if node.name ~= "air" then
if is_supported_node(node.name) then
obj = minetest.add_entity(pos, "technic:frame_entity")
local obj = minetest.add_entity(pos, "technic:frame_entity")
obj:get_luaentity():set_node({ name = itemstack:get_name() })
end
else
@ -349,8 +347,8 @@ for zp = 0, 1 do
end
-- Run script hook
local _, callback
for _, callback in ipairs(minetest.registered_on_placenodes) do
local callback = nil
for _, _ in ipairs(minetest.registered_on_placenodes) do
-- Copy pos and node because callback can modify them
local pos_copy = { x = pos.x, y = pos.y, z = pos.z }
local newnode_copy = { name = def.name, param1 = 0, param2 = 0 }
@ -364,7 +362,7 @@ for zp = 0, 1 do
itemstack:take_item()
end
obj = minetest.add_entity(pos, "technic:frame_entity")
local obj = minetest.add_entity(pos, "technic:frame_entity")
obj:get_luaentity():set_node({ name = node.name })
return itemstack
@ -414,7 +412,7 @@ minetest.register_entity("technic:frame_entity", {
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
prop = {
local prop = {
is_visible = true,
textures = { node.name },
}
@ -589,7 +587,7 @@ local function connected(pos, c, adj)
end
local function get_connected_nodes(pos)
c = { pos }
local c = { pos }
local nodename = minetest.get_node(pos).name
if frames_pos[pos_to_string(pos)] then
nodename = frames_pos[pos_to_string(pos)]
@ -695,7 +693,7 @@ local function swap_template(pos, new)
local saved_node = meta:get_string("saved_node")
meta:set_string("saved_node", "")
technic.swap_node(pos, new)
local meta = minetest.get_meta(pos)
meta = minetest.get_meta(pos)
meta:set_string("saved_node", saved_node)
end
@ -857,7 +855,7 @@ minetest.register_node("technic:template_disabled", {
on_destruct = template_on_destruct,
after_dig_node = template_drops,
on_punch = function(pos, node, puncher)
local meta = minetest.get_meta(pos)
local _ = minetest.get_meta(pos)
swap_template(pos, "technic:template_connector")
end
})

View File

@ -40,7 +40,7 @@ local function inject_items (pos)
end
end
end
end
minetest.register_craft({

View File

@ -312,7 +312,6 @@ function technic.register_battery_box(data)
local charge = meta:get_int("internal_EU_charge")
local cpercent = math.floor(charge / max_charge * 100)
local inv = meta:get_inventory()
local node = minetest.get_node(pos)
meta:set_string("infotext", S("%s Battery Box"):format(tier))
meta:set_string("formspec", formspec..add_on_off_buttons(meta, ltier, cpercent))
meta:set_string("channel", ltier.."_battery_box"..minetest.pos_to_string(pos))
@ -335,7 +334,6 @@ function technic.register_battery_box(data)
after_dig_node = technic.machine_after_dig_node,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local nodename = minetest.get_node(pos).name
if fields.edit_channel then
minetest.show_formspec(sender:get_player_name(),
"technic:battery_box_edit_channel"..minetest.pos_to_string(pos),
@ -344,7 +342,7 @@ function technic.register_battery_box(data)
or fields["fs_helpers_cycling:0:split_dst_stacks"]
or fields["fs_helpers_cycling:1:split_src_stacks"]
or fields["fs_helpers_cycling:1:split_dst_stacks"] then
local meta = minetest.get_meta(pos)
meta = minetest.get_meta(pos)
if not pipeworks.may_configure(pos, sender) then return end
fs_helpers.on_receive_fields(pos, fields)
local EU_upgrade, tube_upgrade = 0, 0

View File

@ -65,7 +65,7 @@ function technic.send_items(pos, x_velocity, z_velocity, output_name)
if output_name == nil then
output_name = "dst"
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local i = 0
@ -84,7 +84,6 @@ function technic.send_items(pos, x_velocity, z_velocity, output_name)
end
end
function technic.smelt_item(meta, result, speed)
local inv = meta:get_inventory()
meta:set_int("cook_time", meta:get_int("cook_time") + 1)
@ -109,10 +108,9 @@ function technic.handle_machine_pipeworks(pos, tube_upgrade, send_function)
if send_function == nil then
send_function = technic.send_items
end
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local pos1 = vector.new(pos)
local x_velocity = 0
local z_velocity = 0

View File

@ -41,9 +41,9 @@ function technic.register_generator(data)
"image[4,1;1,1;default_furnace_fire_bg.png]"..
"list[current_player;main;0,5;8,4;]"..
"listring[]"
local desc = S("Fuel-Fired %s Generator"):format(tier)
local run = function(pos, node)
local meta = minetest.get_meta(pos)
local burn_time = meta:get_int("burn_time")
@ -162,7 +162,6 @@ function technic.register_generator(data)
fs_helpers.on_receive_fields(pos, fields)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local form = generator_formspec
local form_buttons = ""
if not string.find(node.name, ":lv_") then
form_buttons = fs_helpers.cycling_button(
@ -204,15 +203,15 @@ function technic.register_generator(data)
technic_run = run,
technic_on_disable = function(pos, node)
local timer = minetest.get_node_timer(pos)
timer:start(1)
end,
timer:start(1)
end,
on_timer = function(pos, node)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
-- Connected back?
if meta:get_int(tier.."_EU_timeout") > 0 then return false end
local burn_time = meta:get_int("burn_time") or 0
if burn_time <= 0 then

View File

@ -1,6 +1,5 @@
local S = technic.getter
local moretrees = minetest.get_modpath("moretrees")
local mesecons_materials = minetest.get_modpath("mesecons_materials")
local dye = minetest.get_modpath("dye")
-- sawdust, the finest wood/tree grinding

View File

@ -39,7 +39,7 @@ local function register_recipe(typename, data)
else
data.output = ItemStack(data.output):to_string()
end
local recipe = {time = data.time, input = {}, output = data.output}
local index = get_recipe_index(data.input)
if not index then
@ -49,7 +49,7 @@ local function register_recipe(typename, data)
for _, stack in ipairs(data.input) do
recipe.input[ItemStack(stack):get_name()] = ItemStack(stack):get_count()
end
technic.recipes[typename].recipes[index] = recipe
if have_ui and technic.recipes[typename].output_size == 1 then
unified_inventory.register_craft({

View File

@ -56,7 +56,6 @@ function technic.register_solar_array(data)
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
meta:set_int(tier.."_EU_supply", 0)
end,
technic_run = run,

View File

@ -249,12 +249,8 @@ minetest.register_abm({
action = function(pos, node, active_object_count, active_object_count_wider)
if not technic.powerctrl_state then return end
local meta = minetest.get_meta(pos)
local meta1 = nil
local meta1
local pos1 = {}
local PR_EU = 0 -- EUs from PR nodes
local BA_PR_EU = 0 -- EUs from BA nodes (discharching)
local BA_RE_EU = 0 -- EUs to BA nodes (charging)
local RE_EU = 0 -- EUs to RE nodes
local tier = ""
local PR_nodes

View File

@ -244,7 +244,6 @@ to be safe, and limits the range at which source/player interactions
need to be considered.
--]]
local abdomen_offset = 1
local cache_scaled_shielding = {}
local rad_dmg_cutoff = 0.2
local radiated_players = {}

View File

@ -99,7 +99,7 @@ minetest.register_globalstep(function(dtime)
if node and node.name == "air" then
minetest.set_node(rounded_pos, {name="technic:light"})
end
local node = minetest.get_node_or_nil(old_pos)
node = minetest.get_node_or_nil(old_pos)
if node and node.name == "technic:light" then
minetest.remove_node(old_pos)
end
@ -118,6 +118,6 @@ minetest.register_node("technic:light", {
walkable = false,
buildable_to = true,
sunlight_propagates = true,
light_source = LIGHT_MAX,
light_source = minetest.LIGHT_MAX,
pointable = false,
})

View File

@ -154,9 +154,9 @@ local function drill_dig_it(pos, player, mode)
if mode == 1 then
drill_dig_it0(pos, player)
end
if mode == 2 then -- 3 deep
dir = drill_dig_it1(player)
local dir = drill_dig_it1(player)
if dir == 0 then -- x+
drill_dig_it0(pos, player)
pos.x = pos.x + 1
@ -186,9 +186,9 @@ local function drill_dig_it(pos, player, mode)
drill_dig_it0 (pos,player)
end
end
if mode==3 then -- 3 wide
dir=drill_dig_it1(player)
local dir = drill_dig_it1(player)
if dir==0 or dir==1 then -- x
drill_dig_it0 (pos,player)
pos.z=pos.z+1
@ -204,7 +204,7 @@ local function drill_dig_it(pos, player, mode)
drill_dig_it0 (pos,player)
end
end
if mode==4 then -- 3 tall, selected in the middle
drill_dig_it0 (pos,player)
pos.y=pos.y-1
@ -227,7 +227,7 @@ local function drill_dig_it(pos, player, mode)
drill_dig_it4(pos,player)
end
end
minetest.sound_play("mining_drill", {pos = pos, gain = 1.0, max_hear_distance = 10,})
end
@ -240,6 +240,7 @@ end
local function mining_drill_mk2_setmode(user,itemstack)
local player_name=user:get_player_name()
local item=itemstack:to_table()
local mode = nil
local meta=minetest.deserialize(item["metadata"])
if meta==nil then
meta={}
@ -286,7 +287,6 @@ end
local function mining_drill_mk2_handler(itemstack, user, pointed_thing)
local keys = user:get_player_control()
local player_name = user:get_player_name()
local meta = minetest.deserialize(itemstack:get_metadata())
if not meta or not meta.mode or keys.sneak then
return mining_drill_mk2_setmode(user, itemstack)
@ -309,7 +309,6 @@ end
local function mining_drill_mk3_handler(itemstack, user, pointed_thing)
local keys = user:get_player_control()
local player_name = user:get_player_name()
local meta = minetest.deserialize(itemstack:get_metadata())
if not meta or not meta.mode or keys.sneak then
return mining_drill_mk3_setmode(user, itemstack)

View File

@ -44,7 +44,7 @@ minetest.register_tool("technic:vacuum", {
end
end
end
technic.set_RE_wear(itemstack, meta.charge, vacuum_max_charge)
itemstack:set_metadata(minetest.serialize(meta))
return itemstack

View File

@ -84,7 +84,6 @@ end
local function set_formspec(pos, data, page)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local formspec = data.base_formspec
formspec = formspec..fs_helpers.cycling_button(
meta,

View File

@ -72,7 +72,6 @@ else
end
end
local shape = {}
local onesize_products = {
slope = 2,
slope_edge = 1,

View File

@ -237,7 +237,7 @@ technic_cnc.programs = {
type = "fixed",
fixed = {
{ 4/16, -8/16, 4/16, 8/16, 8/16, 8/16 },
{ 0, -8/16, 0, 4/16, 8/16, 8/16 },
{ 0, -8/16, 0, 4/16, 8/16, 8/16 },
{ -4/16, -8/16, -4/16, 0, 8/16, 8/16 },
{ -8/16, -8/16, -8/16, -4/16, 8/16, 8/16 }
}
@ -257,7 +257,7 @@ technic_cnc.programs = {
}
}
},
}
-- Allow disabling certain programs for some node. Default is allowing all types for all nodes

View File

@ -15,12 +15,10 @@ Syntax:
inventory is always stored (Ex. active state for machines)
--]]
wrench.META_TYPE_INT = 0
wrench.META_TYPE_FLOAT = 1
wrench.META_TYPE_STRING = 2
local INT, STRING, FLOAT =
wrench.META_TYPE_INT,
local STRING, FLOAT =
wrench.META_TYPE_STRING,
wrench.META_TYPE_FLOAT