forked from mff/minercantile
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
70a485f793 | |||
29fe3ac467 | |||
c517460951 | |||
fd26a1e5b1 |
15
.luacheckrc
Normal file
15
.luacheckrc
Normal file
@ -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",
|
||||||
|
}
|
11
.travis.yml
Normal file
11
.travis.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
language: generic
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- luarocks
|
||||||
|
before_install:
|
||||||
|
- luarocks install --local luacheck
|
||||||
|
script:
|
||||||
|
- $HOME/.luarocks/bin/luacheck .
|
||||||
|
notifications:
|
||||||
|
email: false
|
3
mod.conf
Normal file
3
mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = minercantile
|
||||||
|
depends = default
|
||||||
|
optional_depends = unified_inventory, maptools
|
10
readme.md
10
readme.md
@ -1,6 +1,8 @@
|
|||||||
***MINERCANTILE***
|
# Miner Cantile
|
||||||
|
|
||||||
A minetest trading mod by crabman, under the original idea of Cyberpangolin
|
[](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
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -17,9 +19,9 @@ A minetest trading mod by crabman, under the original idea of Cyberpangolin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
PLEASE NOTE: THIS MOD (including this readme file) IS UNDER A HARD WORK AND NOT READY TO USE INGAME FOR NOW !
|
PLEASE NOTE: THIS MOD (including this readme file) IS UNDER A HARD WORK AND NOT READY TO USE INGAME FOR NOW!
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
This mod aims to make a big centralised store, under following conditions:
|
This mod aims to make a big centralised store, under following conditions:
|
||||||
- To have money, the player has to change the coins he finds naturally ingame at the bancomatic, and then it's stored into player's wallet. 10000 copper coin = 100 silver coins = 1 golden coin = 10000 coins in the wallet
|
- To have money, the player has to change the coins he finds naturally ingame at the bancomatic, and then it's stored into player's wallet. 10000 copper coin = 100 silver coins = 1 golden coin = 10000 coins in the wallet
|
||||||
|
11
shop.lua
11
shop.lua
@ -265,7 +265,7 @@ end
|
|||||||
|
|
||||||
-- sell fonction
|
-- sell fonction
|
||||||
function minercantile.shop.get_buy_price(shop_type, itname)
|
function minercantile.shop.get_buy_price(shop_type, itname)
|
||||||
local price = nil
|
local price
|
||||||
local money = minercantile.shop.get_money()
|
local money = minercantile.shop.get_money()
|
||||||
if not minercantile.stock.items[itname] then
|
if not minercantile.stock.items[itname] then
|
||||||
minercantile.stock.items[itname] = {nb=0}
|
minercantile.stock.items[itname] = {nb=0}
|
||||||
@ -288,7 +288,7 @@ end
|
|||||||
|
|
||||||
-- sell fonction
|
-- sell fonction
|
||||||
function minercantile.shop.get_sell_price(itname, wear)
|
function minercantile.shop.get_sell_price(itname, wear)
|
||||||
local price = nil
|
local price
|
||||||
local money = minercantile.shop.get_money()
|
local money = minercantile.shop.get_money()
|
||||||
if not minercantile.stock.items[itname] then
|
if not minercantile.stock.items[itname] then
|
||||||
minercantile.stock.items[itname] = {nb=0}
|
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)
|
local player = minetest.get_player_by_name(name)
|
||||||
if not player then return false end
|
if not player then return false end
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
local shop_money = minercantile.shop.get_money()
|
|
||||||
local player_money = minercantile.wallet.get_money(name)
|
local player_money = minercantile.wallet.get_money(name)
|
||||||
if player_money < 1 then
|
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]")
|
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 function get_formspec_buy_items(name)
|
||||||
local itname = shop_buy[name].itname
|
local itname = shop_buy[name].itname
|
||||||
local max = shop_buy[name].max
|
|
||||||
local nb = shop_buy[name].nb
|
local nb = shop_buy[name].nb
|
||||||
local price = shop_buy[name].price
|
local price = shop_buy[name].price
|
||||||
local formspec = {"size[8,6]bgcolor[#2A2A2A;]label[3.5,0;Buy Items]"}
|
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 item = shop_sell[name].item
|
||||||
local itname = item.name
|
local itname = item.name
|
||||||
local index = shop_sell[name].index
|
local index = shop_sell[name].index
|
||||||
local max = shop_sell[name].max
|
|
||||||
local nb = shop_sell[name].nb
|
local nb = shop_sell[name].nb
|
||||||
local price = minercantile.shop.get_sell_price(itname, item.wear)
|
local price = minercantile.shop.get_sell_price(itname, item.wear)
|
||||||
shop_sell[name].price = price
|
shop_sell[name].price = price
|
||||||
@ -969,7 +966,7 @@ minetest.register_chatcommand("shop_additem",{
|
|||||||
minetest.chat_send_player(name, "invalid param amount")
|
minetest.chat_send_player(name, "invalid param amount")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local amount = tonumber(amount)
|
amount = tonumber(amount)
|
||||||
if amount < 1 then
|
if amount < 1 then
|
||||||
minetest.chat_send_player(name, "invalid param amount")
|
minetest.chat_send_player(name, "invalid param amount")
|
||||||
return
|
return
|
||||||
@ -1001,7 +998,7 @@ minetest.register_chatcommand("shop_delitem",{
|
|||||||
minetest.chat_send_player(name, "invalid param amount")
|
minetest.chat_send_player(name, "invalid param amount")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local amount = tonumber(amount)
|
amount = tonumber(amount)
|
||||||
if amount < 1 then
|
if amount < 1 then
|
||||||
minetest.chat_send_player(name, "invalid param amount")
|
minetest.chat_send_player(name, "invalid param amount")
|
||||||
return
|
return
|
||||||
|
@ -5,7 +5,7 @@ function minercantile.wallet.load_wallet(name)
|
|||||||
if minercantile.wallets[name] == nil then
|
if minercantile.wallets[name] == nil then
|
||||||
minercantile.wallets[name] = {}
|
minercantile.wallets[name] = {}
|
||||||
end
|
end
|
||||||
local file, err = io.open(minercantile.path_wallet..name, "r")
|
local file, _ = io.open(minercantile.path_wallet..name, "r")
|
||||||
if file then
|
if file then
|
||||||
local data = minetest.deserialize(file:read("*all"))
|
local data = minetest.deserialize(file:read("*all"))
|
||||||
file:close()
|
file:close()
|
||||||
|
Reference in New Issue
Block a user