mirror of
https://github.com/theFox6/microexpansion.git
synced 2024-11-25 08:33:43 +01:00
added luacheck
This commit is contained in:
parent
98cf73e57a
commit
2455b73e53
26
.luacheck_health
Normal file
26
.luacheck_health
Normal file
@ -0,0 +1,26 @@
|
||||
allow_defined_top = true
|
||||
|
||||
read_globals = {
|
||||
"default",
|
||||
"dump",
|
||||
"ItemStack",
|
||||
"PseudoRandom",
|
||||
"stairsplus",
|
||||
"intllib",
|
||||
"Settings",
|
||||
math = { fields = {"sign"} },
|
||||
"minetest",
|
||||
"vector",
|
||||
"VoxelArea",
|
||||
"VoxelManip",
|
||||
}
|
||||
|
||||
ignore = {
|
||||
"211",
|
||||
"212",
|
||||
"213",
|
||||
"611",
|
||||
"612",
|
||||
"621",
|
||||
"631"
|
||||
}
|
11
.luacheckrc
Normal file
11
.luacheckrc
Normal file
@ -0,0 +1,11 @@
|
||||
allow_defined_top = true
|
||||
|
||||
read_globals = {
|
||||
"minetest", "default",
|
||||
"dump", "vector",
|
||||
"VoxelManip", "VoxelArea",
|
||||
"ItemStack", "PseudoRandom",
|
||||
"stairsplus", "intllib",
|
||||
"Settings",
|
||||
math = { fields = {"sign"} }
|
||||
}
|
23
.travis.yml
Normal file
23
.travis.yml
Normal file
@ -0,0 +1,23 @@
|
||||
language: generic
|
||||
sudo: false
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- luarocks
|
||||
before_install:
|
||||
- luarocks install --local luacheck
|
||||
env:
|
||||
- CONFIG=.luacheck_health
|
||||
- CONFIG=.luacheckrc
|
||||
matrix:
|
||||
allow_failures:
|
||||
- name: "beauty check"
|
||||
env: CONFIG=.luacheckrc
|
||||
exclude:
|
||||
- name: "health check"
|
||||
env: CONFIG=.luacheck_health
|
||||
script:
|
||||
- $HOME/.luarocks/bin/luacheck --config $CONFIG .
|
||||
notifications:
|
||||
email:
|
||||
on_failure: change
|
2
api.lua
2
api.lua
@ -156,7 +156,7 @@ function microexpansion.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)
|
||||
vm:read_from_map(pos, pos)
|
||||
return minetest.get_node(pos)
|
||||
end
|
||||
|
||||
|
2
development/luacheck.sh
Normal file
2
development/luacheck.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#! /bin/bash
|
||||
~/src/luarocks-3.0.3/lua_modules/bin/luacheck .. --exclude-files=.
|
1
init.lua
1
init.lua
@ -5,7 +5,6 @@ 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
|
||||
microexpansion.gui_bg = "bgcolor[#080808BB;true]background[5,5;1,1;gui_formbg.png;true]"
|
||||
|
@ -3,13 +3,13 @@
|
||||
local me = microexpansion
|
||||
local network = me.network
|
||||
|
||||
local function update_ctrl(pos,node)
|
||||
local network = me.get_network(pos)
|
||||
if network == nil then
|
||||
local function update_ctrl(pos)
|
||||
local cnetwork = me.get_network(pos)
|
||||
if cnetwork == nil then
|
||||
minetest.log("error","no network for ctrl at pos "..minetest.pos_to_string(pos))
|
||||
return
|
||||
end
|
||||
local size = network:get_item_capacity()
|
||||
local size = cnetwork:get_item_capacity()
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", me.int_to_stacks(size))
|
||||
@ -97,8 +97,7 @@ me.register_node("ctrl", {
|
||||
meta:set_string("infotext", "Network Controller (owned by "..name..")")
|
||||
meta:set_string("owner", name)
|
||||
end,
|
||||
on_destruct = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
on_destruct = function(pos)
|
||||
local net,idx = me.get_network(pos)
|
||||
if net then
|
||||
net.controller_pos = nil
|
||||
@ -110,7 +109,7 @@ me.register_node("ctrl", {
|
||||
after_dig_node = function(pos)
|
||||
me.update_connected_machines(pos)
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local inside_stack = inv:get_stack(listname, index)
|
||||
local stack_name = stack:get_name()
|
||||
@ -126,22 +125,22 @@ me.register_node("ctrl", {
|
||||
local slots, items = 0, 0
|
||||
-- Get amount of items in drive
|
||||
for i = 1, max_slots do
|
||||
local stack = inv:get_stack("main", i)
|
||||
if stack:get_name() ~= "" then
|
||||
local dstack = inv:get_stack("main", i)
|
||||
if dstack:get_name() ~= "" then
|
||||
slots = slots + 1
|
||||
local num = stack:get_count()
|
||||
local num = dstack:get_count()
|
||||
if num == 0 then num = 1 end
|
||||
items = items + num
|
||||
end
|
||||
end
|
||||
return math.max(math.min(stack:get_count(),max_items-items),0)
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
on_metadata_inventory_put = function(pos, listname, _, stack)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
inv:remove_item(listname, stack)
|
||||
me.insert_item(stack, inv, listname)
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
allow_metadata_inventory_take = function(_, _, _, stack)
|
||||
return math.min(stack:get_count(),stack:get_stack_max())
|
||||
end,
|
||||
machine = {
|
||||
|
@ -43,14 +43,14 @@ function network.adjacent_connected_nodes(pos, include_ctrl)
|
||||
|
||||
local nodes = {}
|
||||
|
||||
for _,pos in pairs(adjacent) do
|
||||
if network.can_connect(pos) then
|
||||
for _,apos in pairs(adjacent) do
|
||||
if network.can_connect(apos) then
|
||||
if include_ctrl == false then
|
||||
if not microexpansion.get_node(pos).name == "microexpansion:ctrl" then
|
||||
table.insert(nodes, pos)
|
||||
if not microexpansion.get_node(apos).name == "microexpansion:ctrl" then
|
||||
table.insert(nodes, apos)
|
||||
end
|
||||
else
|
||||
table.insert(nodes, pos)
|
||||
table.insert(nodes, apos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2,11 +2,9 @@
|
||||
|
||||
local me = microexpansion
|
||||
|
||||
local networks = me.networks
|
||||
local path = microexpansion.get_module_path("power")
|
||||
|
||||
me.power = {}
|
||||
local power = me.power
|
||||
|
||||
-- Load Resources
|
||||
|
||||
|
@ -56,7 +56,7 @@ function microexpansion.move_inv(inv1, inv2)
|
||||
local fname, tname = inv1.name, inv2.name
|
||||
|
||||
--FIXME only as many as allowed in a drive
|
||||
for i,v in ipairs(finv:get_list(fname) or {}) do
|
||||
for _,v in ipairs(finv:get_list(fname) or {}) do
|
||||
if tinv and tinv:room_for_item(tname, v) then
|
||||
local leftover = tinv:add_item( tname, v )
|
||||
finv:remove_item(fname, v)
|
||||
|
@ -54,19 +54,19 @@ microexpansion.register_node("drive", {
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 10)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
can_dig = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
allow_metadata_inventory_put = function(_, _, _, stack)
|
||||
if minetest.get_item_group(stack:get_name(), "microexpansion_cell") ~= 0 then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
on_metadata_inventory_put = function(pos, _, _, stack)
|
||||
me.update_connected_machines(pos)
|
||||
local network,cp = me.get_connected_network(pos)
|
||||
if network == nil then
|
||||
@ -94,7 +94,7 @@ microexpansion.register_node("drive", {
|
||||
return stack:get_count()
|
||||
end
|
||||
local ctrl_meta = minetest.get_meta(cp)
|
||||
local ctrl_inv = ctrl_meta:get_inventory()
|
||||
local ctrl_inv = ctrl_meta:get_inventory()
|
||||
local cells = {}
|
||||
for i = 1, own_inv:get_size("main") do
|
||||
local cell = own_inv:get_stack("main", i)
|
||||
@ -151,7 +151,7 @@ microexpansion.register_node("drive", {
|
||||
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
on_metadata_inventory_take = function(pos, _, _, stack)
|
||||
local network,cp = me.get_connected_network(pos)
|
||||
if network == nil then
|
||||
return
|
||||
@ -163,9 +163,9 @@ microexpansion.register_node("drive", {
|
||||
me.update_connected_machines(pos)
|
||||
return
|
||||
end
|
||||
for _,stack in pairs(items) do
|
||||
for _,ostack in pairs(items) do
|
||||
--this returns 99 (max count) even if it removes more
|
||||
ctrl_inv:remove_item("main", stack)
|
||||
ctrl_inv:remove_item("main", ostack)
|
||||
end
|
||||
print(stack:to_string())
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
local me = microexpansion
|
||||
|
||||
-- [me chest] Get formspec
|
||||
local function chest_formspec(pos, start_id, listname, page_max, query)
|
||||
local function chest_formspec(pos, start_id, listname, page_max, q)
|
||||
local list
|
||||
local page_number = ""
|
||||
local buttons = ""
|
||||
local query = query or ""
|
||||
local query = q or ""
|
||||
local net,cp = me.get_connected_network(pos)
|
||||
|
||||
if cp then
|
||||
@ -64,7 +64,6 @@ end
|
||||
local function update_chest(pos)
|
||||
local network = me.get_connected_network(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if network == nil then
|
||||
meta:set_int("page", 1)
|
||||
meta:set_string("formspec", chest_formspec(pos, 1))
|
||||
@ -72,7 +71,7 @@ local function update_chest(pos)
|
||||
end
|
||||
local size = network:get_item_capacity()
|
||||
local page_max = me.int_to_pagenum(size) + 1
|
||||
|
||||
|
||||
meta:set_string("inv_name", "main")
|
||||
meta:set_string("formspec", chest_formspec(pos, 1, "main", page_max))
|
||||
end
|
||||
@ -104,15 +103,15 @@ microexpansion.register_node("term", {
|
||||
update_chest(pos)
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
on_metadata_inventory_take = function(pos, listname, _, stack)
|
||||
if listname == "search" then
|
||||
local _,cp = me.get_connected_network(pos)
|
||||
local inv = minetest.get_meta(cp):get_inventory()
|
||||
inv:remove_item("main", stack)
|
||||
end
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local network,cp = me.get_connected_network(pos)
|
||||
on_receive_fields = function(pos, _, fields, sender)
|
||||
local _,cp = me.get_connected_network(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local page = meta:get_int("page")
|
||||
local inv_name = meta:get_string("inv_name")
|
||||
|
Loading…
Reference in New Issue
Block a user