mirror of
https://github.com/MinetestForFun/minercantile.git
synced 2025-06-30 07:10:23 +02:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
00f3c26eb7 |
15
.luacheckrc
15
.luacheckrc
@ -1,15 +0,0 @@
|
|||||||
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
11
.travis.yml
@ -1,11 +0,0 @@
|
|||||||
language: generic
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- luarocks
|
|
||||||
before_install:
|
|
||||||
- luarocks install --local luacheck
|
|
||||||
script:
|
|
||||||
- $HOME/.luarocks/bin/luacheck .
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
16
change.lua
16
change.lua
@ -5,20 +5,8 @@ local coins_convert = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--if maptools then use maptools coins else use minercantile coins
|
--if not maptools then use use minercantile coins
|
||||||
if minetest.get_modpath("maptools") ~= nil then
|
if not minetest.get_modpath("maptools") then
|
||||||
minetest.override_item("maptools:copper_coin", {
|
|
||||||
inventory_image = "minercantile_copper_coin.png",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.override_item("maptools:silver_coin", {
|
|
||||||
inventory_image = "minercantile_silver_coin.png",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.override_item("maptools:gold_coin", {
|
|
||||||
inventory_image = "minercantile_gold_coin.png",
|
|
||||||
})
|
|
||||||
else
|
|
||||||
minetest.register_craftitem("minercantile:copper_coin", {
|
minetest.register_craftitem("minercantile:copper_coin", {
|
||||||
description = "Copper Coin",
|
description = "Copper Coin",
|
||||||
inventory_image = "minercantile_copper_coin.png",
|
inventory_image = "minercantile_copper_coin.png",
|
||||||
|
3
mod.conf
3
mod.conf
@ -1,3 +0,0 @@
|
|||||||
name = minercantile
|
|
||||||
depends = default
|
|
||||||
optional_depends = unified_inventory, maptools
|
|
10
readme.md
10
readme.md
@ -1,8 +1,6 @@
|
|||||||
# Miner Cantile
|
***MINERCANTILE***
|
||||||
|
|
||||||
[](https://travis-ci.org/MinetestForFun/minercantile)
|
A minetest trading mod by crabman, under the original idea of Cyberpangolin
|
||||||
|
|
||||||
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
|
||||||
@ -19,9 +17,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
|
local price = nil
|
||||||
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
|
local price = nil
|
||||||
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,6 +380,7 @@ 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]")
|
||||||
@ -465,6 +466,7 @@ 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]"}
|
||||||
@ -608,6 +610,7 @@ 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
|
||||||
@ -966,7 +969,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
|
||||||
amount = tonumber(amount)
|
local 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
|
||||||
@ -998,7 +1001,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
|
||||||
amount = tonumber(amount)
|
local 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, _ = io.open(minercantile.path_wallet..name, "r")
|
local file, err = 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