mirror of
https://github.com/mt-mods/currency.git
synced 2024-10-04 00:23:06 +02:00
add luacheck / fix some issues
This commit is contained in:
parent
664eec36e6
commit
9a9808703e
11
.github/workflows/luacheck.yml
vendored
Normal file
11
.github/workflows/luacheck.yml
vendored
Normal file
@ -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: ""
|
21
.luacheckrc
Normal file
21
.luacheckrc
Normal file
@ -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"
|
||||||
|
}
|
10
barter.lua
10
barter.lua
@ -47,8 +47,8 @@ barter.chest.check_privilege = function(listname,playername,meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
barter.chest.update_formspec = function(meta)
|
barter.chest.update_formspec = function(meta)
|
||||||
formspec = barter.chest.formspec.main
|
local formspec = barter.chest.formspec.main
|
||||||
pl_formspec = function (n)
|
local pl_formspec = function (n)
|
||||||
if meta:get_int(n.."step")==0 then
|
if meta:get_int(n.."step")==0 then
|
||||||
formspec = formspec .. barter.chest.formspec[n].start
|
formspec = formspec .. barter.chest.formspec[n].start
|
||||||
else
|
else
|
||||||
@ -65,9 +65,9 @@ barter.chest.update_formspec = function(meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
barter.chest.give_inventory = function(inv,list,playername)
|
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
|
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
|
if player:get_inventory():room_for_item("main",v) then
|
||||||
player:get_inventory():add_item("main",v)
|
player:get_inventory():add_item("main",v)
|
||||||
else
|
else
|
||||||
@ -144,7 +144,7 @@ minetest.register_node("currency:barter", {
|
|||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
barter.chest.start_timer(pos, meta)
|
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
|
if fields[n.."_start"] and meta:get_string(n) == "" then
|
||||||
meta:set_string(n,sender:get_player_name())
|
meta:set_string(n,sender:get_player_name())
|
||||||
end
|
end
|
||||||
|
@ -41,10 +41,10 @@ if income_enabled then
|
|||||||
if not player or player.is_fake_player then return end
|
if not player or player.is_fake_player then return end
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
local income_count = players_income[name]
|
local ic = players_income[name]
|
||||||
if income_count and income_count > 0 then
|
if ic and ic > 0 then
|
||||||
local inv = player:get_inventory()
|
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
|
players_income[name] = nil
|
||||||
minetest.log("info", "[Currency] added basic income for "..name.." to inventory")
|
minetest.log("info", "[Currency] added basic income for "..name.." to inventory")
|
||||||
end
|
end
|
||||||
|
12
shop.lua
12
shop.lua
@ -61,7 +61,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
currency.shop.give_inventory = function(inv,list,playername)
|
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
|
if player then
|
||||||
for k,v in ipairs(inv:get_list(list)) do
|
for k,v in ipairs(inv:get_list(list)) do
|
||||||
player:get_inventory():add_item("main",v)
|
player:get_inventory():add_item("main",v)
|
||||||
@ -238,7 +238,10 @@ minetest.register_node("currency:shop", {
|
|||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
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
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -305,7 +308,10 @@ minetest.register_node("currency:shop_empty", {
|
|||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
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
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user