diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml new file mode 100644 index 0000000..5290e24 --- /dev/null +++ b/.github/workflows/luacheck.yml @@ -0,0 +1,11 @@ +on: [push, pull_request] +name: luacheck +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: lint + uses: Roang-zero1/factorio-mod-luacheck@master + with: + luacheckrc_url: "" diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..1d23b4a --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,21 @@ +unused = false + +globals = { + "currency", "barter", + "default" +} + +read_globals = { + -- Lua + string = {fields = {"split", "trim"}}, + table = {fields = {"copy", "getn"}}, + + -- Minetest + "minetest", + "PseudoRandom", "ItemStack", + "VoxelArea", "VoxelManip", + "Settings", "vector", + + -- Mods + "loot", "pipeworks" +} diff --git a/barter.lua b/barter.lua index 79b2124..86205b6 100644 --- a/barter.lua +++ b/barter.lua @@ -47,8 +47,8 @@ barter.chest.check_privilege = function(listname,playername,meta) end barter.chest.update_formspec = function(meta) - formspec = barter.chest.formspec.main - pl_formspec = function (n) + local formspec = barter.chest.formspec.main + local pl_formspec = function (n) if meta:get_int(n.."step")==0 then formspec = formspec .. barter.chest.formspec[n].start else @@ -65,9 +65,9 @@ barter.chest.update_formspec = function(meta) end barter.chest.give_inventory = function(inv,list,playername) - player = minetest.get_player_by_name(playername) + local player = minetest.get_player_by_name(playername) if player then - for k,v in ipairs(inv:get_list(list)) do + for _,v in ipairs(inv:get_list(list)) do if player:get_inventory():room_for_item("main",v) then player:get_inventory():add_item("main",v) else @@ -144,7 +144,7 @@ minetest.register_node("currency:barter", { on_receive_fields = function(pos, formname, fields, sender) local meta = minetest.get_meta(pos) barter.chest.start_timer(pos, meta) - pl_receive_fields = function(n) + local pl_receive_fields = function(n) if fields[n.."_start"] and meta:get_string(n) == "" then meta:set_string(n,sender:get_player_name()) end diff --git a/income.lua b/income.lua index 8f2354b..f701203 100644 --- a/income.lua +++ b/income.lua @@ -41,10 +41,10 @@ if income_enabled then if not player or player.is_fake_player then return end local name = player:get_player_name() - local income_count = players_income[name] - if income_count and income_count > 0 then + local ic = players_income[name] + if ic and ic > 0 then local inv = player:get_inventory() - inv:add_item("main", {name=income_item, count=income_count}) + inv:add_item("main", {name=income_item, count=ic}) players_income[name] = nil minetest.log("info", "[Currency] added basic income for "..name.." to inventory") end diff --git a/shop.lua b/shop.lua index 5af300e..627a906 100644 --- a/shop.lua +++ b/shop.lua @@ -61,7 +61,7 @@ end currency.shop.give_inventory = function(inv,list,playername) - player = minetest.get_player_by_name(playername) + local player = minetest.get_player_by_name(playername) if player then for k,v in ipairs(inv:get_list(list)) do player:get_inventory():add_item("main",v) @@ -238,7 +238,10 @@ minetest.register_node("currency:shop", { can_dig = function(pos, player) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - return inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives") + return inv:is_empty("stock") and + inv:is_empty("customers_gave") and + inv:is_empty("owner_wants") and + inv:is_empty("owner_gives") end }) @@ -305,7 +308,10 @@ minetest.register_node("currency:shop_empty", { can_dig = function(pos, player) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - return inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives") + return inv:is_empty("stock") and + inv:is_empty("customers_gave") and + inv:is_empty("owner_wants") and + inv:is_empty("owner_gives") end })