From 70a485f793d90647dd8e0802a003d3e5b77ab23b Mon Sep 17 00:00:00 2001 From: David Leal Date: Tue, 12 May 2020 19:32:23 -0500 Subject: [PATCH] Add Travis CI and LuaCheck (#5) --- .luacheckrc | 15 +++++++++++++++ .travis.yml | 11 +++++++++++ readme.md | 2 ++ shop.lua | 11 ++++------- wallets.lua | 2 +- 5 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 .luacheckrc create mode 100644 .travis.yml diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..8a099e9 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,15 @@ +unused_args = false +allow_defined_top = true +max_line_length = 999 + +globals = { + "minercantile", +} + +read_globals = { + string = {fields = {"split", "trim"}}, + table = {fields = {"copy", "getn"}}, + + "minetest", "ItemStack", + "default", "unified_inventory", +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4c59300 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: generic +addons: + apt: + packages: + - luarocks +before_install: + - luarocks install --local luacheck +script: +- $HOME/.luarocks/bin/luacheck . +notifications: + email: false diff --git a/readme.md b/readme.md index e782509..7bab561 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,7 @@ # Miner Cantile +[![Build Status](https://travis-ci.org/MinetestForFun/minercantile.svg)](https://travis-ci.org/MinetestForFun/minercantile) + A Minetest trading mod by crabman, under the original idea of Cyberpangolin. This program is free software: you can redistribute it and/or modify diff --git a/shop.lua b/shop.lua index 919e843..5e6f458 100644 --- a/shop.lua +++ b/shop.lua @@ -265,7 +265,7 @@ end -- sell fonction function minercantile.shop.get_buy_price(shop_type, itname) - local price = nil + local price local money = minercantile.shop.get_money() if not minercantile.stock.items[itname] then minercantile.stock.items[itname] = {nb=0} @@ -288,7 +288,7 @@ end -- sell fonction function minercantile.shop.get_sell_price(itname, wear) - local price = nil + local price local money = minercantile.shop.get_money() if not minercantile.stock.items[itname] then minercantile.stock.items[itname] = {nb=0} @@ -380,7 +380,6 @@ function minercantile.shop.buy(name, itname, nb, price) local player = minetest.get_player_by_name(name) if not player then return false end local player_inv = player:get_inventory() - local shop_money = minercantile.shop.get_money() local player_money = minercantile.wallet.get_money(name) if player_money < 1 then minetest.show_formspec(name, "minercantile:confirmed", "size[6,3]bgcolor[#2A2A2A;]label[2.6,0;Shop]label[1,1;Sorry, you have not enough money]button[1.3,2.1;1.5,1;return_buy;Return]button_exit[3.3,2.1;1.5,1;close;Close]") @@ -466,7 +465,6 @@ end local function get_formspec_buy_items(name) local itname = shop_buy[name].itname - local max = shop_buy[name].max local nb = shop_buy[name].nb local price = shop_buy[name].price local formspec = {"size[8,6]bgcolor[#2A2A2A;]label[3.5,0;Buy Items]"} @@ -610,7 +608,6 @@ local function get_formspec_sell_items(name) local item = shop_sell[name].item local itname = item.name local index = shop_sell[name].index - local max = shop_sell[name].max local nb = shop_sell[name].nb local price = minercantile.shop.get_sell_price(itname, item.wear) shop_sell[name].price = price @@ -969,7 +966,7 @@ minetest.register_chatcommand("shop_additem",{ minetest.chat_send_player(name, "invalid param amount") return end - local amount = tonumber(amount) + amount = tonumber(amount) if amount < 1 then minetest.chat_send_player(name, "invalid param amount") return @@ -1001,7 +998,7 @@ minetest.register_chatcommand("shop_delitem",{ minetest.chat_send_player(name, "invalid param amount") return end - local amount = tonumber(amount) + amount = tonumber(amount) if amount < 1 then minetest.chat_send_player(name, "invalid param amount") return diff --git a/wallets.lua b/wallets.lua index a80b183..c67ad0a 100644 --- a/wallets.lua +++ b/wallets.lua @@ -5,7 +5,7 @@ function minercantile.wallet.load_wallet(name) if minercantile.wallets[name] == nil then minercantile.wallets[name] = {} end - local file, err = io.open(minercantile.path_wallet..name, "r") + local file, _ = io.open(minercantile.path_wallet..name, "r") if file then local data = minetest.deserialize(file:read("*all")) file:close()