Upload
24
HELP_ME.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
==> How to enable ...
|
||||||
|
-> Open 'config.txt' with your editor and modify it
|
||||||
|
|
||||||
|
==> Add special access to nodes, how?
|
||||||
|
-> Exchange shop: open 'shop.lua' and edit the function 'has_exchange_shop_privilege',
|
||||||
|
return 'true' to grant access to the contents, return 'false' to disallow
|
||||||
|
-> Warehouse: same like exchange shop, this time 'warehouse.lua' and 'has_locked_chest_privilege'
|
||||||
|
|
||||||
|
==> Can I ...
|
||||||
|
-> Suggest things: Sure, I'm happy about (almost) every suggestion, just I'm pretty new, which
|
||||||
|
means I can't realize all of them
|
||||||
|
-> Report a fault: I hope this will not happen too much, post it at the topic in the MT forums
|
||||||
|
-> Edit the files: Yes sure, the license is 'WTFPL' but I'm always happy about credits :smile:
|
||||||
|
-> Delete this mod: Stupid question
|
||||||
|
-> Exchange textures: Yes, it's WFTPL! Maybe you need to ask the original creator of the images
|
||||||
|
|
||||||
|
==> Give me informations about the converting!
|
||||||
|
Burning:
|
||||||
|
1 Gold block -> 2 MineCoin block
|
||||||
|
2 MineCoin block -> 1 Gold block
|
||||||
|
1 Coin base -> 1 MineNinth
|
||||||
|
Crafting:
|
||||||
|
1 Zinc block -> 8 Coin base
|
||||||
|
1 Tin block -> 20 Coin base
|
218
bank_currency.lua
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
--Created by Krock for the BitChange mod
|
||||||
|
-- Bank node for the mod: currency (by Dan Duncombe)
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
local file_path = minetest.get_worldpath() .. "/bitchange_bank_currency"
|
||||||
|
local exchange_worth = 15 -- default worth in "money" for one MineCoin, change if not okay
|
||||||
|
local bank = {}
|
||||||
|
local changes_made = false
|
||||||
|
|
||||||
|
local fs_1 = io.open(file_path, "r")
|
||||||
|
if fs_1 then
|
||||||
|
exchange_worth = tonumber(fs_1:read("*l"))
|
||||||
|
io.close(fs_1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function round(num, idp)
|
||||||
|
if idp and idp>0 then
|
||||||
|
local mult = 10^idp
|
||||||
|
return math.floor(num * mult + 0.5) / mult
|
||||||
|
end
|
||||||
|
return math.floor(num + 0.5)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function save_exchange_rate()
|
||||||
|
local fs_2 = io.open(file_path, "w")
|
||||||
|
fs_2:write(tostring(exchange_worth))
|
||||||
|
io.close(fs_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ttime = 0
|
||||||
|
minetest.register_globalstep(function(t)
|
||||||
|
ttime = ttime + t
|
||||||
|
if ttime < 240 then --every 4min'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if(changes_made) then
|
||||||
|
save_exchange_rate()
|
||||||
|
end
|
||||||
|
ttime = 0
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
save_exchange_rate()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function has_bank_privilege(meta, player)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
return ((player_name == meta:get_string("owner")) or minetest.get_player_privs(player_name).server)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_bank_formspec(number, pos)
|
||||||
|
local formspec = ""
|
||||||
|
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||||
|
if(number == 1) then
|
||||||
|
-- customer
|
||||||
|
formspec = ("size[8,8]"..
|
||||||
|
"label[0,0;Bank]"..
|
||||||
|
"label[2,0;(View reserve with (E) + (Right click))]"..
|
||||||
|
"label[1,1;Current worth of a MineCoin:]"..
|
||||||
|
"label[3,1.5;~ "..round(exchange_worth, 2).." MineGeld]"..
|
||||||
|
"button[2,3;3,1;sell10;Buy 10 MineCoins]"..
|
||||||
|
"button[2,2;3,1;buy10;Sell 10 MineCoins]"..
|
||||||
|
"list[current_player;main;0,4;8,4;]")
|
||||||
|
elseif(number == 2) then
|
||||||
|
-- owner
|
||||||
|
formspec = ("size[8,9;]"..
|
||||||
|
"label[0,0;Bank]"..
|
||||||
|
"label[1,0.5;Current MineCoin reserve: (Editable by owner)]"..
|
||||||
|
"list["..name..";coins;0,1;8,3;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]")
|
||||||
|
end
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
|
if(formname == "bitchange:bank_formspec") then
|
||||||
|
local player_name = sender:get_player_name()
|
||||||
|
if(fields.quit) then
|
||||||
|
bank[player_name] = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if(exchange_worth < 1) then
|
||||||
|
exchange_worth = 1
|
||||||
|
end
|
||||||
|
local pos = bank[player_name]
|
||||||
|
local bank_inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
local player_inv = sender:get_inventory()
|
||||||
|
local coin_stack = "bitchange:minecoin 10"
|
||||||
|
local geld_stack = "currency:minegeld "
|
||||||
|
local err_msg = ""
|
||||||
|
if(fields.buy10) then
|
||||||
|
geld_stack = geld_stack..(round(exchange_worth * 0.995, 1) * 10)
|
||||||
|
if(not player_inv:contains_item("main", coin_stack)) then
|
||||||
|
err_msg = "You do not have the needed MineCoins."
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:room_for_item("coins", coin_stack)) then
|
||||||
|
err_msg = "This bank has no space to buy more MineCoins."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:contains_item("coins", geld_stack)) then
|
||||||
|
err_msg = "This bank has no MineGeld ready to sell."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not player_inv:room_for_item("main", geld_stack)) then
|
||||||
|
err_msg = "You do not have enough space in your inventory."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
exchange_worth = exchange_worth * 0.995
|
||||||
|
local price = round(exchange_worth - 0.01, 1) * 10
|
||||||
|
bank_inv:remove_item("coins", geld_stack)
|
||||||
|
player_inv:add_item("main", geld_stack)
|
||||||
|
player_inv:remove_item("main", coin_stack)
|
||||||
|
bank_inv:add_item("coins", coin_stack)
|
||||||
|
changes_made = true
|
||||||
|
err_msg = "Sold 10 MineCoins for "..price.." MineGeld"
|
||||||
|
end
|
||||||
|
elseif(fields.sell10) then
|
||||||
|
local price = round(exchange_worth, 1) * 10
|
||||||
|
geld_stack = geld_stack..(round(exchange_worth, 1) * 10)
|
||||||
|
if(not player_inv:contains_item("main", geld_stack)) then
|
||||||
|
err_msg = "You do not have the required money. ("..price.." x 1 MineGeld pieces)"
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:room_for_item("coins", geld_stack)) then
|
||||||
|
err_msg = "This bank has no space to buy more MineGeld."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:contains_item("coins", coin_stack)) then
|
||||||
|
err_msg = "This bank has no MineCoins ready to sell."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not player_inv:room_for_item("main", coin_stack)) then
|
||||||
|
err_msg = "You do not have enough space in your inventory."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
player_inv:remove_item("main", geld_stack)
|
||||||
|
bank_inv:add_item("coins", geld_stack)
|
||||||
|
bank_inv:remove_item("coins", coin_stack)
|
||||||
|
player_inv:add_item("main", coin_stack)
|
||||||
|
exchange_worth = exchange_worth * 1.005
|
||||||
|
changes_made = true
|
||||||
|
err_msg = "Bought 10 MineCoins for "..price.." MineGeld"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg ~= "") then
|
||||||
|
minetest.chat_send_player(player_name, "Bank: "..err_msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:bank", {
|
||||||
|
description = "Bank",
|
||||||
|
tiles = {"bitchange_bank_side.png", "bitchange_bank_side.png",
|
||||||
|
"bitchange_bank_side.png", "bitchange_bank_side.png",
|
||||||
|
"bitchange_bank_side.png", "bitchange_bank_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=1,level=1},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
|
meta:set_string("infotext", "Bank (owned by "..
|
||||||
|
meta:get_string("owner")..")")
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", "Bank (constructing)")
|
||||||
|
meta:set_string("formspec", "")
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("coins", 8*3)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(meta:get_string("owner") == player:get_player_name()) then
|
||||||
|
return meta:get_inventory():is_empty("coins")
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
|
local player_name = clicker:get_player_name()
|
||||||
|
local view = 1
|
||||||
|
bank[player_name] = pos
|
||||||
|
if(clicker:get_player_control().aux1) then
|
||||||
|
view = 2
|
||||||
|
end
|
||||||
|
minetest.show_formspec(player_name,"bitchange:bank_formspec",get_bank_formspec(view, pos))
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(has_bank_privilege(meta, player)) then
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_bank_privilege(meta, player)) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_bank_privilege(meta, player)) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
})
|
200
bank_money.lua
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
--Created by Krock for the BitChange mod
|
||||||
|
-- Bank node for the mod: money (by kotolegokot)
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
local file_path = minetest.get_worldpath() .. "/bitchange_bank_money"
|
||||||
|
local exchange_worth = 100.0 -- default worth in "money" for one MineCoin, change if not okay
|
||||||
|
local bank = {}
|
||||||
|
local changes_made = false
|
||||||
|
|
||||||
|
local fs_1 = io.open(file_path, "r")
|
||||||
|
if fs_1 then
|
||||||
|
exchange_worth = tonumber(fs_1:read("*l"))
|
||||||
|
io.close(fs_1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function round(num, idp)
|
||||||
|
if idp and idp>0 then
|
||||||
|
local mult = 10^idp
|
||||||
|
return math.floor(num * mult + 0.5) / mult
|
||||||
|
end
|
||||||
|
return math.floor(num + 0.5)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function save_exchange_rate()
|
||||||
|
local fs_2 = io.open(file_path, "w")
|
||||||
|
fs_2:write(tostring(exchange_worth))
|
||||||
|
io.close(fs_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ttime = 0
|
||||||
|
minetest.register_globalstep(function(t)
|
||||||
|
ttime = ttime + t
|
||||||
|
if ttime < 240 then --every 4min'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if(changes_made) then
|
||||||
|
save_exchange_rate()
|
||||||
|
end
|
||||||
|
ttime = 0
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
save_exchange_rate()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function has_bank_privilege(meta, player)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
return ((player_name == meta:get_string("owner")) or minetest.get_player_privs(player_name).server)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_bank_formspec(number, pos)
|
||||||
|
local formspec = ""
|
||||||
|
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||||
|
if(number == 1) then
|
||||||
|
-- customer
|
||||||
|
formspec = ("size[8,8]"..
|
||||||
|
"label[0,0;Bank]"..
|
||||||
|
"label[2,0;(View reserve with (E) + (Right click))]"..
|
||||||
|
"label[1,1;Current worth of a MineCoin:]"..
|
||||||
|
"label[3,1.5;~ "..round(exchange_worth, 4).." money]"..
|
||||||
|
"button[2,3;3,1;sell10;Buy 10 MineCoins]"..
|
||||||
|
"button[2,2;3,1;buy10;Sell 10 MineCoins]"..
|
||||||
|
"list[current_player;main;0,4;8,4;]")
|
||||||
|
elseif(number == 2) then
|
||||||
|
-- owner
|
||||||
|
formspec = ("size[8,9;]"..
|
||||||
|
"label[0,0;Bank]"..
|
||||||
|
"label[1,0.5;Current MineCoin reserve: (Editable by owner)]"..
|
||||||
|
"list["..name..";coins;0,1;8,3;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]")
|
||||||
|
end
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
|
if(formname == "bitchange:bank_formspec") then
|
||||||
|
local player_name = sender:get_player_name()
|
||||||
|
if(fields.quit) then
|
||||||
|
bank[player_name] = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if(exchange_worth < 1) then
|
||||||
|
exchange_worth = 1
|
||||||
|
end
|
||||||
|
local pos = bank[player_name]
|
||||||
|
local bank_inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
local player_inv = sender:get_inventory()
|
||||||
|
local coin_stack = "bitchange:minecoin 10"
|
||||||
|
local err_msg = ""
|
||||||
|
if(fields.buy10) then
|
||||||
|
if(not player_inv:contains_item("main", coin_stack)) then
|
||||||
|
err_msg = "You do not have the needed MineCoins."
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:room_for_item("coins", coin_stack)) then
|
||||||
|
err_msg = "This bank has no space to buy more MineCoins."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
exchange_worth = exchange_worth * 0.995
|
||||||
|
local price = round(exchange_worth - 0.1, 1) * 10
|
||||||
|
local cur_money = money.get_money(player_name)
|
||||||
|
money.set_money(player_name, cur_money + price)
|
||||||
|
player_inv:remove_item("main", coin_stack)
|
||||||
|
bank_inv:add_item("coins", coin_stack)
|
||||||
|
changes_made = true
|
||||||
|
err_msg = "Sold 10 MineCoins for "..price.." money"
|
||||||
|
end
|
||||||
|
elseif(fields.sell10) then
|
||||||
|
local price = round(exchange_worth, 1) * 10
|
||||||
|
local cur_money = money.get_money(player_name)
|
||||||
|
if(cur_money < price) then
|
||||||
|
err_msg = "You do not have the required money. ("..price.." money)"
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:contains_item("coins", coin_stack)) then
|
||||||
|
err_msg = "This bank has no MineCoins ready to sell."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not player_inv:room_for_item("main", coin_stack)) then
|
||||||
|
err_msg = "You do not have enough space in your inventory."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
money.set_money(player_name, cur_money - price)
|
||||||
|
bank_inv:remove_item("coins", coin_stack)
|
||||||
|
player_inv:add_item("main", coin_stack)
|
||||||
|
exchange_worth = exchange_worth * 1.005
|
||||||
|
changes_made = true
|
||||||
|
err_msg = "Bought 10 MineCoins for "..price.." money"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg ~= "") then
|
||||||
|
minetest.chat_send_player(player_name, "Bank: "..err_msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:bank", {
|
||||||
|
description = "Bank",
|
||||||
|
tiles = {"bitchange_bank_side.png", "bitchange_bank_side.png",
|
||||||
|
"bitchange_bank_side.png", "bitchange_bank_side.png",
|
||||||
|
"bitchange_bank_side.png", "bitchange_bank_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=1,level=1},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
|
meta:set_string("infotext", "Bank (owned by "..
|
||||||
|
meta:get_string("owner")..")")
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", "Bank (constructing)")
|
||||||
|
meta:set_string("formspec", "")
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("coins", 8*3)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(meta:get_string("owner") == player:get_player_name()) then
|
||||||
|
return meta:get_inventory():is_empty("coins")
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
|
local player_name = clicker:get_player_name()
|
||||||
|
local view = 1
|
||||||
|
bank[player_name] = pos
|
||||||
|
if(clicker:get_player_control().aux1) then
|
||||||
|
view = 2
|
||||||
|
end
|
||||||
|
minetest.show_formspec(player_name,"bitchange:bank_formspec",get_bank_formspec(view, pos))
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(has_bank_privilege(meta, player)) then
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_bank_privilege(meta, player)) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_bank_privilege(meta, player)) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
})
|
200
bank_money2.lua
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
--Created by Krock for the BitChange mod
|
||||||
|
-- Bank node for the mod: money2 (by Bad Command)
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
local file_path = minetest.get_worldpath() .. "/bitchange_bank_money2"
|
||||||
|
local exchange_worth = 100.0 -- default worth in "cr" for one MineCoin, change if not okay
|
||||||
|
local bank = {}
|
||||||
|
local changes_made = false
|
||||||
|
|
||||||
|
local fs_1 = io.open(file_path, "r")
|
||||||
|
if fs_1 then
|
||||||
|
exchange_worth = tonumber(fs_1:read("*l"))
|
||||||
|
io.close(fs_1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function round(num, idp)
|
||||||
|
if idp and idp>0 then
|
||||||
|
local mult = 10^idp
|
||||||
|
return math.floor(num * mult + 0.5) / mult
|
||||||
|
end
|
||||||
|
return math.floor(num + 0.5)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function save_exchange_rate()
|
||||||
|
local fs_2 = io.open(file_path, "w")
|
||||||
|
fs_2:write(tostring(exchange_worth))
|
||||||
|
io.close(fs_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ttime = 0
|
||||||
|
minetest.register_globalstep(function(t)
|
||||||
|
ttime = ttime + t
|
||||||
|
if ttime < 240 then --every 4min'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if(changes_made) then
|
||||||
|
save_exchange_rate()
|
||||||
|
end
|
||||||
|
ttime = 0
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
save_exchange_rate()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function has_bank_privilege(meta, player)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
return ((player_name == meta:get_string("owner")) or minetest.get_player_privs(player_name).server)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_bank_formspec(number, pos)
|
||||||
|
local formspec = ""
|
||||||
|
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||||
|
if(number == 1) then
|
||||||
|
-- customer
|
||||||
|
formspec = ("size[8,8]"..
|
||||||
|
"label[0,0;Bank]"..
|
||||||
|
"label[2,0;(View reserve with (E) + (Right click))]"..
|
||||||
|
"label[1,1;Current worth of a MineCoin:]"..
|
||||||
|
"label[3,1.5;~ "..round(exchange_worth, 4).." cr]"..
|
||||||
|
"button[2,3;3,1;sell10;Buy 10 MineCoins]"..
|
||||||
|
"button[2,2;3,1;buy10;Sell 10 MineCoins]"..
|
||||||
|
"list[current_player;main;0,4;8,4;]")
|
||||||
|
elseif(number == 2) then
|
||||||
|
-- owner
|
||||||
|
formspec = ("size[8,9;]"..
|
||||||
|
"label[0,0;Bank]"..
|
||||||
|
"label[1,0.5;Current MineCoin reserve: (Editable by owner)]"..
|
||||||
|
"list["..name..";coins;0,1;8,3;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]")
|
||||||
|
end
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
|
if(formname == "bitchange:bank_formspec") then
|
||||||
|
local player_name = sender:get_player_name()
|
||||||
|
if(fields.quit) then
|
||||||
|
bank[player_name] = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if(exchange_worth < 1) then
|
||||||
|
exchange_worth = 1
|
||||||
|
end
|
||||||
|
local pos = bank[player_name]
|
||||||
|
local bank_inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
local player_inv = sender:get_inventory()
|
||||||
|
local coin_stack = "bitchange:minecoin 10"
|
||||||
|
local err_msg = ""
|
||||||
|
if(fields.buy10) then
|
||||||
|
if(not player_inv:contains_item("main", coin_stack)) then
|
||||||
|
err_msg = "You do not have the needed MineCoins."
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:room_for_item("coins", coin_stack)) then
|
||||||
|
err_msg = "This bank has no space to buy more MineCoins."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
exchange_worth = exchange_worth * 0.995
|
||||||
|
local price = round(exchange_worth - 0.1, 1) * 10
|
||||||
|
local cur_money = money.get(player_name, amount)
|
||||||
|
money.set(player_name, cur_money + price)
|
||||||
|
player_inv:remove_item("main", coin_stack)
|
||||||
|
bank_inv:add_item("coins", coin_stack)
|
||||||
|
changes_made = true
|
||||||
|
err_msg = "Sold 10 MineCoins for "..price.." cr"
|
||||||
|
end
|
||||||
|
elseif(fields.sell10) then
|
||||||
|
local price = round(exchange_worth, 1) * 10
|
||||||
|
local cur_money = money.get(player_name)
|
||||||
|
if(cur_money < price) then
|
||||||
|
err_msg = "You do not have the required money. ("..price.." cr)"
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not bank_inv:contains_item("coins", coin_stack)) then
|
||||||
|
err_msg = "This bank has no MineCoins ready to sell."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
if(not player_inv:room_for_item("main", coin_stack)) then
|
||||||
|
err_msg = "You do not have enough space in your inventory."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then
|
||||||
|
money.set(player_name, cur_money - price)
|
||||||
|
bank_inv:remove_item("coins", coin_stack)
|
||||||
|
player_inv:add_item("main", coin_stack)
|
||||||
|
exchange_worth = exchange_worth * 1.005
|
||||||
|
changes_made = true
|
||||||
|
err_msg = "Bought 10 MineCoins for "..price.." cr"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg ~= "") then
|
||||||
|
minetest.chat_send_player(player_name, "Bank: "..err_msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:bank", {
|
||||||
|
description = "Bank",
|
||||||
|
tiles = {"bitchange_bank_side.png", "bitchange_bank_side.png",
|
||||||
|
"bitchange_bank_side.png", "bitchange_bank_side.png",
|
||||||
|
"bitchange_bank_side.png", "bitchange_bank_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=1,level=1},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
|
meta:set_string("infotext", "Bank (owned by "..
|
||||||
|
meta:get_string("owner")..")")
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", "Bank (constructing)")
|
||||||
|
meta:set_string("formspec", "")
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("coins", 8*3)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(meta:get_string("owner") == player:get_player_name()) then
|
||||||
|
return meta:get_inventory():is_empty("coins")
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
|
local player_name = clicker:get_player_name()
|
||||||
|
local view = 1
|
||||||
|
bank[player_name] = pos
|
||||||
|
if(clicker:get_player_control().aux1) then
|
||||||
|
view = 2
|
||||||
|
end
|
||||||
|
minetest.show_formspec(player_name,"bitchange:bank_formspec",get_bank_formspec(view, pos))
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(has_bank_privilege(meta, player)) then
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_bank_privilege(meta, player)) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_bank_privilege(meta, player)) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
})
|
27
config.default.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-- General configuration - BitChange
|
||||||
|
-- Created by Krock
|
||||||
|
|
||||||
|
bitchange_initial_give = 2
|
||||||
|
-- Enable/Disable whole nodes
|
||||||
|
bitchange_enable_exchangeshop = true
|
||||||
|
bitchange_enable_moneychanger = true
|
||||||
|
bitchange_enable_warehouse = false
|
||||||
|
|
||||||
|
-- Set this variable to the modname of the other currency mod.
|
||||||
|
-- Let it empty if no other currency is installed.
|
||||||
|
-- Supported: money (by kotolegokot), money2 (by Bad Command), currency (by Dan Duncombe)
|
||||||
|
bitchange_bank_type = ""
|
||||||
|
|
||||||
|
-- Tin converting/generation
|
||||||
|
bitchange_use_moreores_tin = false -- Activate using
|
||||||
|
bitchange_need_generate_tin = false -- Generate only if needed
|
||||||
|
-- Zinc converting/generation
|
||||||
|
bitchange_use_technic_zinc = false -- Activate using
|
||||||
|
bitchange_need_generate_zinc = false -- Generate only if needed
|
||||||
|
|
||||||
|
-- Pipeworks support
|
||||||
|
bitchange_exchangeshop_pipeworks = false
|
||||||
|
bitchange_warehouse_pipeworks = false
|
||||||
|
|
||||||
|
-- Advanced generation settings
|
||||||
|
-- Change in 'minecoins.lua', starting at line 101
|
7
depends.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
default
|
||||||
|
moreores?
|
||||||
|
technic?
|
||||||
|
pipeworks?
|
||||||
|
money?
|
||||||
|
money2?
|
||||||
|
currency?
|
32
init.lua
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
--Created by Krock for the BitChange mod
|
||||||
|
local mod_path = minetest.get_modpath("bitchange")
|
||||||
|
|
||||||
|
dofile(mod_path.."/config.txt")
|
||||||
|
dofile(mod_path.."/minecoins.lua")
|
||||||
|
if(bitchange_use_moreores_tin or bitchange_use_technic_zinc or bitchange_use_gold) then
|
||||||
|
dofile(mod_path.."/moreores.lua")
|
||||||
|
end
|
||||||
|
if(bitchange_enable_exchangeshop) then
|
||||||
|
dofile(mod_path.."/shop.lua")
|
||||||
|
end
|
||||||
|
if(bitchange_enable_moneychanger) then
|
||||||
|
dofile(mod_path.."/moneychanger.lua")
|
||||||
|
end
|
||||||
|
if(bitchange_enable_warehouse) then
|
||||||
|
dofile(mod_path.."/warehouse.lua")
|
||||||
|
end
|
||||||
|
if(bitchange_bank_type ~= "") then
|
||||||
|
if(minetest.get_modpath(bitchange_bank_type) ~= nil) then
|
||||||
|
dofile(mod_path.."/bank_"..bitchange_bank_type..".lua")
|
||||||
|
else
|
||||||
|
print("[BitChange] Bank: Type or mod not found or enabled: "..bitchange_bank_type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if(not minetest.setting_getbool("creative_mode") and bitchange_initial_give > 0) then
|
||||||
|
-- Giving initial money
|
||||||
|
minetest.register_on_newplayer(function(player)
|
||||||
|
player:get_inventory():add_item("main", "bitchange:mineninth "..bitchange_initial_give)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
print("[BitChange] Loaded.")
|
133
minecoins.lua
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
--bitcoins by MilesDyson@DistroGeeks.com
|
||||||
|
--Modified by Krock
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
-- Node definitions
|
||||||
|
minetest.register_node("bitchange:minecoin_in_ground", {
|
||||||
|
description = "MineCoin Ore",
|
||||||
|
tile_images = { "default_stone.png^bitchange_minecoin_in_ground.png" },
|
||||||
|
is_ground_content = true,
|
||||||
|
groups = {cracky=2},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drop = 'bitchange:minecoin',
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:mineninth_in_ground", {
|
||||||
|
description = "MineNinth Ore",
|
||||||
|
tile_images = { "default_stone.png^bitchange_mineninth_in_ground.png" },
|
||||||
|
is_ground_content = true,
|
||||||
|
groups = {cracky=3},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drop = 'bitchange:coinbase',
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:minecoinblock", {
|
||||||
|
description = "MineCoin Block",
|
||||||
|
tile_images = { "bitchange_minecoinblock.png" },
|
||||||
|
is_ground_content = true,
|
||||||
|
groups = {cracky=2},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
stack_max = 30000,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("bitchange:minecoin", {
|
||||||
|
description = "MineCoin",
|
||||||
|
inventory_image = "bitchange_minecoin.png",
|
||||||
|
stack_max = 30000,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("bitchange:mineninth", {
|
||||||
|
description = "MineNinth",
|
||||||
|
inventory_image = "bitchange_mineninth.png",
|
||||||
|
stack_max = 30000,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("bitchange:coinbase", {
|
||||||
|
description = "Coin base",
|
||||||
|
inventory_image = "bitchange_coinbase.png",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Crafting
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'bitchange:minecoinblock',
|
||||||
|
recipe = {
|
||||||
|
{'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'},
|
||||||
|
{'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'},
|
||||||
|
{'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'bitchange:minecoin 9',
|
||||||
|
recipe = {
|
||||||
|
{'bitchange:minecoinblock'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'bitchange:minecoin',
|
||||||
|
recipe = {
|
||||||
|
{'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'},
|
||||||
|
{'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'},
|
||||||
|
{'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'bitchange:mineninth 9',
|
||||||
|
recipe = {
|
||||||
|
{'bitchange:minecoin'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Cooking
|
||||||
|
minetest.register_craft({
|
||||||
|
type = 'cooking',
|
||||||
|
recipe = "bitchange:coinbase",
|
||||||
|
output = "bitchange:mineninth",
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = 'cooking',
|
||||||
|
recipe = "default:goldblock",
|
||||||
|
output = "bitchange:minecoinblock 2",
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type = 'cooking',
|
||||||
|
recipe = "bitchange:minecoinblock",
|
||||||
|
output = "default:gold_ingot 4",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Generation
|
||||||
|
minetest.register_ore({
|
||||||
|
ore_type = "scatter",
|
||||||
|
ore = "bitchange:minecoin_in_ground",
|
||||||
|
wherein = "default:stone",
|
||||||
|
clust_scarcity = 15*15*15,
|
||||||
|
clust_num_ores = 3,
|
||||||
|
clust_size = 7,
|
||||||
|
height_max = -512,
|
||||||
|
height_min = -18000,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_ore({
|
||||||
|
ore_type = "scatter",
|
||||||
|
ore = "bitchange:mineninth_in_ground",
|
||||||
|
wherein = "default:stone",
|
||||||
|
clust_scarcity = 12*12*12,
|
||||||
|
clust_num_ores = 5,
|
||||||
|
clust_size = 8,
|
||||||
|
height_max = -256,
|
||||||
|
height_min = -511,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_ore({
|
||||||
|
ore_type = "scatter",
|
||||||
|
ore = "bitchange:mineninth_in_ground",
|
||||||
|
wherein = "default:stone",
|
||||||
|
clust_scarcity = 13*13*13,
|
||||||
|
clust_num_ores = 3,
|
||||||
|
clust_size = 7,
|
||||||
|
height_max = 28000,
|
||||||
|
height_min = -255,
|
||||||
|
})
|
193
moneychanger.lua
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
--Created by Krock for the BitChange mod
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
moneychanger = {}
|
||||||
|
moneychanger.constructing = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", "size[8,7]" ..
|
||||||
|
"list[current_name;source;0,1;1,1;]" ..
|
||||||
|
"label[0,0;Input money]" ..
|
||||||
|
"list[current_name;output;2,1;2,1;]" ..
|
||||||
|
"label[2,0;Possible converts]" ..
|
||||||
|
"list[current_name;rest;5,1;1,1;]" ..
|
||||||
|
"label[5,0;Remaining money]" ..
|
||||||
|
"list[current_player;main;0,3;8,4;]")
|
||||||
|
end
|
||||||
|
moneychanger.update_fields = function(pos, listname, index, stack, take)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local stack_inv = inv:get_stack(listname, index)
|
||||||
|
local stack_rest = inv:get_stack("rest", 1)
|
||||||
|
local stack_name = stack:get_name()
|
||||||
|
local stack_src = inv:get_stack("source", 1)
|
||||||
|
local stack_src_name = stack_src:get_name()
|
||||||
|
local stack_real_count = 0
|
||||||
|
local canMove = false
|
||||||
|
if(take) then
|
||||||
|
stack_real_count = stack_inv:get_count() - stack:get_count()
|
||||||
|
else
|
||||||
|
if(stack_inv:get_name() ~= "") then
|
||||||
|
stack_real_count = stack_inv:get_count() + stack:get_count()
|
||||||
|
else
|
||||||
|
stack_real_count = stack:get_count()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if(listname == "source" and (stack_rest:get_count() == 0 or take)) then
|
||||||
|
inv:set_list("output", { "", "" })
|
||||||
|
if(stack_real_count > 0) then
|
||||||
|
if(stack_name == "bitchange:minecoinblock") then
|
||||||
|
inv:set_list("output", { "bitchange:minecoin "..(stack_real_count*9), "" })
|
||||||
|
elseif(stack_name == "bitchange:minecoin") then
|
||||||
|
inv:set_list("output", { "bitchange:mineninth "..math.min(stack_real_count*9, 30000), "bitchange:minecoinblock "..math.floor(stack_real_count/9) })
|
||||||
|
else
|
||||||
|
inv:set_list("output", { "bitchange:minecoin "..math.min(math.floor(stack_real_count/9), 30000), "" })
|
||||||
|
end
|
||||||
|
canMove = true
|
||||||
|
elseif(stack_real_count == 0 and stack_src:get_count() > 0) then
|
||||||
|
canMove = true
|
||||||
|
end
|
||||||
|
elseif(listname == "output" and stack_rest:get_count() == 0) then
|
||||||
|
if(stack_src:get_count() < 1) then
|
||||||
|
if(stack:get_count() > 0) then
|
||||||
|
canMove = true
|
||||||
|
end
|
||||||
|
inv:set_list("source", { "" })
|
||||||
|
else
|
||||||
|
if(stack_src_name ~= "") then
|
||||||
|
if(stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin") then
|
||||||
|
local amount_left = (stack_src:get_count() - (stack:get_count()*9))
|
||||||
|
if(amount_left > 0) then
|
||||||
|
inv:set_list("source", { stack_src_name.." "..amount_left })
|
||||||
|
else
|
||||||
|
inv:set_list("source", { "" })
|
||||||
|
end
|
||||||
|
if(index == 1) then
|
||||||
|
inv:set_stack("output", 2, "")
|
||||||
|
else
|
||||||
|
inv:set_stack("output", 1, "")
|
||||||
|
end
|
||||||
|
canMove = true
|
||||||
|
elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:mineninth") then
|
||||||
|
local amount_left = (stack_src:get_count() - (stack:get_count()*9))
|
||||||
|
if(amount_left > 0) then
|
||||||
|
inv:set_list("source", { stack_src_name.." "..amount_left })
|
||||||
|
else
|
||||||
|
inv:set_list("source", { "" })
|
||||||
|
end
|
||||||
|
canMove = true
|
||||||
|
elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:minecoinblock") then
|
||||||
|
local amount_left = stack_src:get_count() - (stack:get_count()/9)
|
||||||
|
local rest_count = (amount_left - math.floor(amount_left))*9
|
||||||
|
if(amount_left > -1) then
|
||||||
|
inv:set_list("source", { stack_src_name.." "..math.floor(amount_left) })
|
||||||
|
if(rest_count > 0) then
|
||||||
|
inv:set_list("rest", { stack_name.." "..rest_count })
|
||||||
|
else
|
||||||
|
inv:set_list("rest", { "" })
|
||||||
|
end
|
||||||
|
if(index == 1) then
|
||||||
|
inv:set_stack("output", 2, "")
|
||||||
|
else
|
||||||
|
inv:set_stack("output", 1, "")
|
||||||
|
end
|
||||||
|
inv:set_stack("output", index, stack_name.." "..stack:get_count())
|
||||||
|
canMove = true
|
||||||
|
end
|
||||||
|
elseif(stack_name == "bitchange:mineninth" and stack_src_name == "bitchange:minecoin") then
|
||||||
|
local amount_left = stack_src:get_count() - (stack:get_count()/9)
|
||||||
|
local rest_count = (amount_left - math.floor(amount_left))*9
|
||||||
|
if(amount_left > -1) then
|
||||||
|
inv:set_list("source", { stack_src_name.." "..math.floor(amount_left) })
|
||||||
|
if(rest_count > 0) then
|
||||||
|
inv:set_list("rest", { stack_name.." "..rest_count })
|
||||||
|
else
|
||||||
|
inv:set_list("rest", { "" })
|
||||||
|
end
|
||||||
|
if(index == 1) then
|
||||||
|
inv:set_stack("output", 2, "")
|
||||||
|
else
|
||||||
|
inv:set_stack("output", 1, "")
|
||||||
|
end
|
||||||
|
inv:set_stack("output", index, stack_name.." "..stack:get_count())
|
||||||
|
canMove = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif(listname == "rest") then
|
||||||
|
canMove = true
|
||||||
|
end
|
||||||
|
if(canMove) then
|
||||||
|
return stack:get_count()
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:moneychanger", {
|
||||||
|
description = "Moneychanger",
|
||||||
|
tiles = {"bitchange_moneychanger_top.png", "bitchange_moneychanger_top.png", "bitchange_moneychanger_side.png",
|
||||||
|
"bitchange_moneychanger_side.png", "bitchange_moneychanger_top.png", "bitchange_moneychanger_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
on_construct = function(pos)
|
||||||
|
return moneychanger.constructing(pos);
|
||||||
|
end,
|
||||||
|
after_place_node = function(pos, placer, itemstack)
|
||||||
|
local owner = placer:get_player_name()
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", "Moneychanger (owned by "..owner..")")
|
||||||
|
meta:set_string("owner",owner)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("source", 1)
|
||||||
|
inv:set_size("rest", 1)
|
||||||
|
inv:set_size("output", 2)
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(player:get_player_name() ~= meta:get_string("owner")) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
if(listname == "source") then
|
||||||
|
local stack_name = stack:get_name()
|
||||||
|
if(stack_name == "bitchange:mineninth" or stack_name == "bitchange:minecoin" or stack_name == "bitchange:minecoinblock") then
|
||||||
|
return moneychanger.update_fields(pos, listname, index, stack, false)
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(player:get_player_name() == meta:get_string("owner") or minetest.get_player_privs(name)["server"]) then
|
||||||
|
return moneychanger.update_fields(pos, listname, index, stack, true)
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if(player:get_player_name() ~= meta:get_string("owner") and not minetest.get_player_privs(name)["server"]) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'bitchange:moneychanger',
|
||||||
|
recipe = {
|
||||||
|
{'default:stone', 'bitchange:mineninth', 'default:stone'},
|
||||||
|
{'default:steel_ingot', 'bitchange:minecoin', 'default:steel_ingot'},
|
||||||
|
{'default:stone', 'default:stone', 'default:stone'}
|
||||||
|
}
|
||||||
|
})
|
126
moreores.lua
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
--Created by Krock
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
if (bitchange_use_moreores_tin) then
|
||||||
|
if(bitchange_need_generate_tin) then
|
||||||
|
minetest.register_node(":moreores:mineral_tin", {
|
||||||
|
description = "Tin Ore",
|
||||||
|
tiles = {"default_stone.png^moreores_mineral_tin.png"},
|
||||||
|
groups = {cracky=3},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drop = 'craft "moreores:tin_lump" 1'
|
||||||
|
})
|
||||||
|
minetest.register_node(":moreores:tin_block", {
|
||||||
|
description = "Tin Block",
|
||||||
|
tiles = { "moreores_tin_block.png" },
|
||||||
|
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2},
|
||||||
|
sounds = default.node_sound_stone_defaults()
|
||||||
|
})
|
||||||
|
minetest.register_ore({
|
||||||
|
ore_type = "scatter",
|
||||||
|
ore = "moreores:mineral_tin",
|
||||||
|
wherein = "default:stone",
|
||||||
|
clust_scarcity = 7*7*7,
|
||||||
|
clust_num_ores = 3,
|
||||||
|
clust_size = 7,
|
||||||
|
height_min = -31000,
|
||||||
|
height_max = 8,
|
||||||
|
})
|
||||||
|
minetest.register_craftitem(":moreores:tin_lump", {
|
||||||
|
description = "Tin Lump",
|
||||||
|
inventory_image = "moreores_tin_lump.png",
|
||||||
|
})
|
||||||
|
minetest.register_craftitem(":moreores:tin_ingot", {
|
||||||
|
description = "Tin Ingot",
|
||||||
|
inventory_image = "moreores_tin_ingot.png",
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "moreores:tin_block",
|
||||||
|
recipe = {
|
||||||
|
{"moreores:tin_ingot", "moreores:tin_ingot", "moreores:tin_ingot"},
|
||||||
|
{"moreores:tin_ingot", "moreores:tin_ingot", "moreores:tin_ingot"},
|
||||||
|
{"moreores:tin_ingot", "moreores:tin_ingot", "moreores:tin_ingot"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "moreores:tin_ingot 9",
|
||||||
|
recipe = { { "moreores:tin_block" } }
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type = 'cooking',
|
||||||
|
recipe = "moreores:tin_lump",
|
||||||
|
output = "moreores:tin_ingot",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "bitchange:coinbase 18",
|
||||||
|
recipe = {
|
||||||
|
{"moreores:tin_block", "default:pick_diamond"},
|
||||||
|
{"moreores:tin_block", ""}
|
||||||
|
},
|
||||||
|
replacements = { {"default:pick_diamond", "default:pick_diamond"} },
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if (bitchange_use_technic_zinc) then
|
||||||
|
if (bitchange_need_generate_zinc) then
|
||||||
|
minetest.register_node(":technic:mineral_zinc", {
|
||||||
|
description = "Zinc Ore",
|
||||||
|
tile_images = { "default_stone.png^technic_mineral_zinc.png" },
|
||||||
|
is_ground_content = true,
|
||||||
|
groups = {cracky=3},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drop = 'craft "technic:zinc_lump" 1',
|
||||||
|
})
|
||||||
|
minetest.register_node(":technic:zinc_block", {
|
||||||
|
description = "Zinc Block",
|
||||||
|
tiles = { "technic_zinc_block.png" },
|
||||||
|
is_ground_content = true,
|
||||||
|
groups = {cracky=1, level=2},
|
||||||
|
sounds = default.node_sound_stone_defaults()
|
||||||
|
})
|
||||||
|
minetest.register_ore({
|
||||||
|
ore_type = "scatter",
|
||||||
|
ore = "technic:mineral_zinc",
|
||||||
|
wherein = "default:stone",
|
||||||
|
clust_scarcity = 9*9*9,
|
||||||
|
clust_num_ores = 4,
|
||||||
|
clust_size = 3,
|
||||||
|
height_min = -31000,
|
||||||
|
height_max = 2,
|
||||||
|
})
|
||||||
|
minetest.register_craftitem(":technic:zinc_lump", {
|
||||||
|
description = "Zinc Lump",
|
||||||
|
inventory_image = "technic_zinc_lump.png",
|
||||||
|
})
|
||||||
|
minetest.register_craftitem(":technic:zinc_ingot", {
|
||||||
|
description = "Zinc Ingot",
|
||||||
|
inventory_image = "technic_zinc_ingot.png",
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "technic:zinc_block",
|
||||||
|
recipe = {
|
||||||
|
{"technic:zinc_ingot", "technic:zinc_ingot", "technic:zinc_ingot"},
|
||||||
|
{"technic:zinc_ingot", "technic:zinc_ingot", "technic:zinc_ingot"},
|
||||||
|
{"technic:zinc_ingot", "technic:zinc_ingot", "technic:zinc_ingot"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "technic:zinc_block 9",
|
||||||
|
recipe = { { "technic:zinc_block" } }
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
type = 'cooking',
|
||||||
|
recipe = "technic:zinc_lump",
|
||||||
|
output = "technic:zinc_ingot",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "bitchange:coinbase 8",
|
||||||
|
recipe = {
|
||||||
|
{"technic:zinc_block", "default:pick_diamond"},
|
||||||
|
{"technic:zinc_block", ""}
|
||||||
|
},
|
||||||
|
replacements = { {"default:pick_diamond", "default:pick_diamond"} },
|
||||||
|
})
|
||||||
|
end
|
314
shop.lua
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
--Created by Krock for the BitChange mod
|
||||||
|
--Parts of codes, images and ideas from Dan Duncombe's exchange shop
|
||||||
|
-- https://forum.minetest.net/viewtopic.php?id=7002
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
local exchange_shop = {}
|
||||||
|
|
||||||
|
local function has_exchange_shop_privilege(meta, player)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
return ((player_name == meta:get_string("owner")) or minetest.get_player_privs(player_name).server)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_exchange_shop_formspec(number,pos,title)
|
||||||
|
local formspec = ""
|
||||||
|
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||||
|
if(number == 1) then
|
||||||
|
-- customer
|
||||||
|
formspec = ("size[8,9;]"..
|
||||||
|
"label[0,0;Exchange shop]"..
|
||||||
|
"label[1,0.5;Owner needs:]"..
|
||||||
|
"list["..name..";cust_ow;1,1;2,2;]"..
|
||||||
|
"button[3,2.5;2,1;exchange;Exchange]"..
|
||||||
|
"label[5,0.5;Owner gives:]"..
|
||||||
|
"list["..name..";cust_og;5,1;2,2;]"..
|
||||||
|
"label[1,3.5;Ejected items:]"..
|
||||||
|
"list["..name..";cust_ej;3,3.5;4,1;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]")
|
||||||
|
elseif(number == 2 or number == 3) then
|
||||||
|
-- owner
|
||||||
|
formspec = ("size[11,10;]"..
|
||||||
|
"label[0,0;Exchange shop]"..
|
||||||
|
"field[2.5,0.5;3,0.2;title;;"..title.."]"..
|
||||||
|
"label[0,0.7;You need:]"..
|
||||||
|
"list["..name..";cust_ow;0,1.2;2,2;]"..
|
||||||
|
"label[3,0.7;You give:]"..
|
||||||
|
"list["..name..";cust_og;3,1.2;2,2;]"..
|
||||||
|
"label[1,3.5;Ejected items:]"..
|
||||||
|
"list["..name..";custm_ej;0,4;4,1;]"..
|
||||||
|
"label[6,0;You are viewing:]")
|
||||||
|
if(number == 2) then
|
||||||
|
formspec = (formspec.."button[8.5,0;2.5,1;vstock;Customers stock]"..
|
||||||
|
"list["..name..";custm;6,1;5,4;]")
|
||||||
|
else
|
||||||
|
formspec = (formspec.."button[8.5,0;2.5,1;vcustm;Your stock]"..
|
||||||
|
"list["..name..";stock;6,1;5,4;]")
|
||||||
|
end
|
||||||
|
formspec = (formspec..
|
||||||
|
"label[1,5;Use (E) + (Right click) for customer interface]"..
|
||||||
|
"list[current_player;main;1,6;8,4;]")
|
||||||
|
end
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_exchange_shop_tube_config(mode)
|
||||||
|
if(bitchange_exchangeshop_pipeworks) then
|
||||||
|
if(mode == 1) then
|
||||||
|
return {choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1}
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:add_item("stock",stack)
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:room_for_item("stock",stack)
|
||||||
|
end,
|
||||||
|
input_inventory="custm",
|
||||||
|
connect_sides = {left=1, right=1, back=1, top=1, bottom=1}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if(mode == 1) then
|
||||||
|
return {choppy=2,oddly_breakable_by_hand=2}
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
connect_sides = {}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
|
if (formname == "bitchange:shop_formspec") then
|
||||||
|
local player_name = sender:get_player_name()
|
||||||
|
local pos = exchange_shop[player_name]
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local title = meta:get_string("title") or ""
|
||||||
|
|
||||||
|
if(fields.exchange) then
|
||||||
|
local player_inv = sender:get_inventory()
|
||||||
|
local shop_inv = meta:get_inventory()
|
||||||
|
local err_msg = ""
|
||||||
|
local cust_ow = shop_inv:get_list("cust_ow")
|
||||||
|
local cust_og = shop_inv:get_list("cust_og")
|
||||||
|
local cust_ow_legal = true
|
||||||
|
local cust_og_legal = true
|
||||||
|
--?shop configured well
|
||||||
|
for i1, item1 in pairs(cust_ow) do
|
||||||
|
for i2, item2 in pairs(cust_ow) do
|
||||||
|
if (item1:get_name() == item2:get_name() and i1 ~= i2 and item1:get_name() ~= "") then
|
||||||
|
cust_ow_legal = false
|
||||||
|
--break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not cust_ow_legal) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not cust_ow_legal) then
|
||||||
|
err_msg = "The 'Owner needs' field can not contain multiple times the same items, contact the shop owner."
|
||||||
|
end
|
||||||
|
if(err_msg == "") then --?shop configured well
|
||||||
|
for i1, item1 in pairs(cust_og) do
|
||||||
|
for i2, item2 in pairs(cust_og) do
|
||||||
|
if (item1:get_name() == item2:get_name() and i1 ~= i2 and item1:get_name() ~= "") then
|
||||||
|
cust_og_legal = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not cust_og_legal) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not cust_og_legal) then
|
||||||
|
err_msg = "The 'Owner gives' field can not contain multiple times the same items, contact the shop owner."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then --?player has space
|
||||||
|
local player_has_space = true
|
||||||
|
for i, item in pairs(cust_og) do
|
||||||
|
if (not player_inv:room_for_item("main",item)) then
|
||||||
|
player_has_space = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not player_has_space) then
|
||||||
|
err_msg = "You do not have the space in your inventory."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then --?player has items
|
||||||
|
local player_has_items = true
|
||||||
|
for i, item in pairs(cust_ow) do
|
||||||
|
if (not player_inv:contains_item("main",item)) then
|
||||||
|
player_has_items = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not player_has_items) then
|
||||||
|
err_msg = "You do not have the needed items."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then --?shop has space
|
||||||
|
local shop_has_space = true
|
||||||
|
for i, item in pairs(cust_ow) do
|
||||||
|
if (not shop_inv:room_for_item("custm",item)) then
|
||||||
|
shop_has_space = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not shop_has_space) then
|
||||||
|
err_msg = "Exchange shop: The stock in the shop is full."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then --?shop has items
|
||||||
|
local shop_has_items = true
|
||||||
|
for i, item in pairs(cust_og) do
|
||||||
|
if (not shop_inv:contains_item("stock",item)) then
|
||||||
|
shop_has_items = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not shop_has_items) then
|
||||||
|
err_msg = "The shop is empty and can not give you anything."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then --?exchange
|
||||||
|
local fully_exchanged = true
|
||||||
|
for i, item in pairs(cust_ow) do
|
||||||
|
player_inv:remove_item("main", item) --player inv. to stock else to eject fields
|
||||||
|
if (shop_inv:room_for_item("custm",item)) then
|
||||||
|
shop_inv:add_item("custm", item)
|
||||||
|
else
|
||||||
|
shop_inv:add_item("custm_ej", item)
|
||||||
|
fully_exchanged = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i, item in pairs(cust_og) do
|
||||||
|
shop_inv:remove_item("stock", item) --stock to player inv. else to eject fields
|
||||||
|
if (player_inv:room_for_item("main",item)) then
|
||||||
|
player_inv:add_item("main", item)
|
||||||
|
else
|
||||||
|
shop_inv:add_item("cust_ej", item)
|
||||||
|
fully_exchanged = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not fully_exchanged) then
|
||||||
|
err_msg = "Fatal error! Stocks are overflowing somewhere!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg ~= "") then
|
||||||
|
minetest.chat_send_player(player_name, "Exchange shop: "..err_msg)
|
||||||
|
end
|
||||||
|
elseif(fields.vstock and has_exchange_shop_privilege(meta, sender) and not fields.quit) then
|
||||||
|
minetest.show_formspec(sender:get_player_name(),"bitchange:shop_formspec",get_exchange_shop_formspec(3, pos, title))
|
||||||
|
elseif(fields.vcustm and has_exchange_shop_privilege(meta, sender) and not fields.quit) then
|
||||||
|
minetest.show_formspec(sender:get_player_name(),"bitchange:shop_formspec",get_exchange_shop_formspec(2, pos, title))
|
||||||
|
elseif(fields.quit and has_exchange_shop_privilege(meta, sender)) then
|
||||||
|
if(fields.title and title ~= fields.title) then
|
||||||
|
if(fields.title ~= "") then
|
||||||
|
meta:set_string("infotext", "Exchange shop \""..fields.title.."\" (owned by "..
|
||||||
|
meta:get_string("owner")..")")
|
||||||
|
else
|
||||||
|
meta:set_string("infotext", "Exchange shop (owned by "..
|
||||||
|
meta:get_string("owner")..")")
|
||||||
|
end
|
||||||
|
meta:set_string("title", fields.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:shop", {
|
||||||
|
description = "Shop",
|
||||||
|
tiles = {"bitchange_shop_top.png", "bitchange_shop_top.png",
|
||||||
|
"bitchange_shop_side.png", "bitchange_shop_side.png",
|
||||||
|
"bitchange_shop_side.png", "bitchange_shop_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = get_exchange_shop_tube_config(1),
|
||||||
|
tube = get_exchange_shop_tube_config(2),
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
|
meta:set_string("infotext", "Exchange shop (owned by "..
|
||||||
|
meta:get_string("owner")..")")
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", "Exchange shop (constructing)")
|
||||||
|
meta:set_string("formspec", "")
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("stock", 5*4) -- needed stock for exchanges
|
||||||
|
inv:set_size("custm", 5*4) -- stock of the customers exchanges
|
||||||
|
inv:set_size("custm_ej", 4) -- ejected items if shop has no inventory room
|
||||||
|
inv:set_size("cust_ow", 2*2) -- owner wants
|
||||||
|
inv:set_size("cust_og", 2*2) -- owner gives
|
||||||
|
inv:set_size("cust_ej", 4) -- ejected items if player has no inventory room
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if(inv:is_empty("stock") and inv:is_empty("custm") and inv:is_empty("custm_ej") and inv:is_empty("cust_ow") and inv:is_empty("cust_og") and inv:is_empty("cust_ej")) then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "Can not dig exchange shop, one or multiple stocks are in use.")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local player_name = clicker:get_player_name()
|
||||||
|
local view = 0
|
||||||
|
exchange_shop[player_name] = pos
|
||||||
|
if player_name == meta:get_string("owner") then
|
||||||
|
if(clicker:get_player_control().aux1) then
|
||||||
|
view = 1
|
||||||
|
else
|
||||||
|
view = 2
|
||||||
|
end
|
||||||
|
else
|
||||||
|
view = 1
|
||||||
|
end
|
||||||
|
minetest.show_formspec(player_name,"bitchange:shop_formspec",get_exchange_shop_formspec(view, pos, meta:get_string("title")))
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (not has_exchange_shop_privilege(meta, player)) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_exchange_shop_privilege(meta, player) and (listname ~= "cust_ej") and (listname ~= "custm_ej")) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if (has_exchange_shop_privilege(meta, player) or (listname == "cust_ej")) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'bitchange:shop',
|
||||||
|
recipe = {
|
||||||
|
{'default:sign_wall'},
|
||||||
|
{'default:chest_locked'},
|
||||||
|
}
|
||||||
|
})
|
BIN
textures/16px/bitchange_bank_front.png
Normal file
After Width: | Height: | Size: 522 B |
BIN
textures/16px/bitchange_bank_side.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
textures/16px/bitchange_minecoin.png
Normal file
After Width: | Height: | Size: 363 B |
BIN
textures/16px/bitchange_mineninth.png
Normal file
After Width: | Height: | Size: 334 B |
BIN
textures/16px/bitchange_moneychanger_front.png
Normal file
After Width: | Height: | Size: 456 B |
BIN
textures/16px/bitchange_moneychanger_side.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
textures/16px/bitchange_moneychanger_top.png
Normal file
After Width: | Height: | Size: 361 B |
BIN
textures/16px/bitchange_shop_front.png
Normal file
After Width: | Height: | Size: 822 B |
BIN
textures/16px/bitchange_shop_side.png
Normal file
After Width: | Height: | Size: 755 B |
BIN
textures/16px/bitchange_shop_top.png
Normal file
After Width: | Height: | Size: 734 B |
BIN
textures/16px/bitchange_warehouse_front.png
Normal file
After Width: | Height: | Size: 485 B |
BIN
textures/16px/bitchange_warehouse_side.png
Normal file
After Width: | Height: | Size: 444 B |
BIN
textures/16px/bitchange_warehouse_top.png
Normal file
After Width: | Height: | Size: 441 B |
BIN
textures/bitchange_bank_front.png
Normal file
After Width: | Height: | Size: 988 B |
BIN
textures/bitchange_bank_side.png
Normal file
After Width: | Height: | Size: 619 B |
BIN
textures/bitchange_coinbase.png
Normal file
After Width: | Height: | Size: 482 B |
BIN
textures/bitchange_minecoin.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
textures/bitchange_minecoin_in_ground.png
Normal file
After Width: | Height: | Size: 366 B |
BIN
textures/bitchange_minecoinblock.png
Normal file
After Width: | Height: | Size: 404 B |
BIN
textures/bitchange_mineninth.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
textures/bitchange_mineninth_in_ground.png
Normal file
After Width: | Height: | Size: 364 B |
BIN
textures/bitchange_moneychanger_front.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/bitchange_moneychanger_side.png
Normal file
After Width: | Height: | Size: 320 B |
BIN
textures/bitchange_moneychanger_top.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/bitchange_shop_front.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
textures/bitchange_shop_side.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
textures/bitchange_shop_top.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
textures/bitchange_warehouse_front.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
textures/bitchange_warehouse_side.png
Normal file
After Width: | Height: | Size: 957 B |
BIN
textures/bitchange_warehouse_top.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
textures/moreores_mineral_tin.png
Normal file
After Width: | Height: | Size: 254 B |
BIN
textures/moreores_tin_block.png
Normal file
After Width: | Height: | Size: 269 B |
BIN
textures/moreores_tin_ingot.png
Normal file
After Width: | Height: | Size: 361 B |
BIN
textures/moreores_tin_lump.png
Normal file
After Width: | Height: | Size: 361 B |
BIN
textures/technic_mineral_zinc.png
Normal file
After Width: | Height: | Size: 891 B |
BIN
textures/technic_zinc_block.png
Normal file
After Width: | Height: | Size: 681 B |
BIN
textures/technic_zinc_ingot.png
Normal file
After Width: | Height: | Size: 317 B |
BIN
textures/technic_zinc_lump.png
Normal file
After Width: | Height: | Size: 308 B |
73
version.txt
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
======>- Version 1.6.6 -<======
|
||||||
|
- default config 'config.default.txt'
|
||||||
|
- generation adjustments (coins are alot cheaper now)
|
||||||
|
- recommended: enable converting of gold
|
||||||
|
- new item: "Coin base" to burn into a MineNinth
|
||||||
|
- changed some codes in the converting
|
||||||
|
* 'HELP_ME.txt' for more information
|
||||||
|
|
||||||
|
======>- Version 1.6.5u1 -<======
|
||||||
|
- read more in 'config.txt' how to configure it
|
||||||
|
- added currency support for bank
|
||||||
|
- added money2 support for bank
|
||||||
|
|
||||||
|
======>- Version 1.6.5 -<======
|
||||||
|
- initial money
|
||||||
|
- 32px textures updated
|
||||||
|
- money exchange rate optimized (needs a bugtest)
|
||||||
|
- added a bank (depends on money mod)
|
||||||
|
|
||||||
|
======>- Version 1.6.2 -<======
|
||||||
|
- some graphic edits
|
||||||
|
- editable exchange shop title
|
||||||
|
|
||||||
|
======>- Version 1.6.0 -<======
|
||||||
|
- 32px textures
|
||||||
|
- fixed money changer bug
|
||||||
|
- some generation rarity changes
|
||||||
|
- mineninths now digable below -32
|
||||||
|
|
||||||
|
======>- Version 1.5.5 -<======
|
||||||
|
- added converting gold into MineCoins
|
||||||
|
- MineNinths now also can be found under -64m
|
||||||
|
- putted together 'crafting.lua' and 'minecoins.lua'
|
||||||
|
- added 'config.txt'
|
||||||
|
- some fixes
|
||||||
|
|
||||||
|
======>- Version 1.5.0 -<======
|
||||||
|
- added 'HELP_ME.txt', name sais all
|
||||||
|
- pipework support for the exchange shop
|
||||||
|
- pipework support for the warehouse
|
||||||
|
|
||||||
|
======>- Version 1.4.0 -<======
|
||||||
|
- built shop.lua from scratch
|
||||||
|
- added warehouse.lua for people which have troubles with the space
|
||||||
|
* enable the warehouse in init.lua
|
||||||
|
|
||||||
|
======>- Version 1.3.0 -<======
|
||||||
|
- fixes in moneychanger.lua
|
||||||
|
- added moneychanger.lua (might still contain fails)
|
||||||
|
|
||||||
|
======>- Version 1.2.0 -<======
|
||||||
|
- changed some textures
|
||||||
|
- serval bigfixes
|
||||||
|
- added converting moreores:tin to MineCoin Ninths
|
||||||
|
- added converting technic:zink to MineCoin Ninths
|
||||||
|
- added generation of zink and tin
|
||||||
|
* enable the support for zinc and/or zinc in moreores.lua
|
||||||
|
|
||||||
|
======>- Version 1.1.0 -<======
|
||||||
|
- modifed parts of generation
|
||||||
|
- renamed Bitcoins to MineCoins
|
||||||
|
- destroyed all existing "Bitcoins" by setting them a new name
|
||||||
|
- about 30 letters of new codes
|
||||||
|
|
||||||
|
======>- Version 1.0.0 -<======
|
||||||
|
- first release
|
||||||
|
- exteneded stack limit for bitcoins to 30'000
|
||||||
|
- bigger stocks in the exchange shop
|
||||||
|
- ore generation added/replaced
|
||||||
|
- Bitninth added
|
||||||
|
- copied "Currency and Economy" from: https://forum.minetest.net/viewtopic.php?pid=106971#p106971
|
||||||
|
- copied "Bitcoins" mod from: https://forum.minetest.net/viewtopic.php?pid=119354#p119354
|
||||||
|
===============================
|
148
warehouse.lua
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
--Created by Krock for the BitChange mod
|
||||||
|
-- Something like a chest...experimental, have fun!
|
||||||
|
--License: WTFPL
|
||||||
|
|
||||||
|
function has_locked_chest_privilege(meta, player)
|
||||||
|
return (player:get_player_name() == meta:get_string("owner"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_warehouse_tube_config(mode)
|
||||||
|
if(bitchange_warehouse_pipeworks) then
|
||||||
|
if(mode == 1) then
|
||||||
|
return {cracky=1, level=2, tubedevice=1, tubedevice_receiver=1}
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if(inv:room_for_item("main",stack)) then
|
||||||
|
return inv:add_item("main",stack)
|
||||||
|
else
|
||||||
|
return inv:add_item("main2",stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if(inv:room_for_item("main",stack)) then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return inv:room_for_item("main2",stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
input_inventory="main",
|
||||||
|
connect_sides = {left=1, right=1, back=1, top=1, bottom=1}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if(mode == 1) then
|
||||||
|
return {cracky=1, level=2}
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
connect_sides = {}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("bitchange:warehouse", {
|
||||||
|
description = "Warehouse (Locked)",
|
||||||
|
tiles = {"bitchange_warehouse_top.png",
|
||||||
|
"bitchange_warehouse_top.png",
|
||||||
|
"bitchange_warehouse_side.png",
|
||||||
|
"bitchange_warehouse_side.png",
|
||||||
|
"bitchange_warehouse_side.png",
|
||||||
|
"bitchange_warehouse_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = get_warehouse_tube_config(1),
|
||||||
|
tube = get_warehouse_tube_config(2),
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = {name="default_hard_footstep", gain=1.0},
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
|
meta:set_string("infotext", "Warehouse (owned by "..
|
||||||
|
meta:get_string("owner")..")")
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", "size[12,10;]"..
|
||||||
|
"label[0,0;Warehouse]"..
|
||||||
|
"label[2,0;Layer:]"..
|
||||||
|
"button[3,0;1,1;inv_lv2;1]"..
|
||||||
|
"label[4,0;Workspace:]"..
|
||||||
|
"list[current_name;worksp;6,0;5,1;]"..
|
||||||
|
"list[current_name;main;0,1;12,4;]"..
|
||||||
|
"list[current_player;main;2,6;8,4;]")
|
||||||
|
meta:set_string("infotext", "Warehouse (constructing)")
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("main", 12*4)
|
||||||
|
inv:set_size("worksp", 5*1)
|
||||||
|
inv:set_size("main2", 12*4)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:is_empty("main") and inv:is_empty("main2") and inv:is_empty("worksp")
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if(fields.inv_lv1) then
|
||||||
|
meta:set_string("formspec", "size[12,10;]"..
|
||||||
|
"label[0,0;Warehouse]"..
|
||||||
|
"label[2,0;Layer:]"..
|
||||||
|
"button[3,0;1,1;inv_lv2;1]"..
|
||||||
|
"label[4,0;Workspace:]"..
|
||||||
|
"list[current_name;worksp;6,0;5,1;]"..
|
||||||
|
"list[current_name;main;0,1;12,4;]"..
|
||||||
|
"list[current_player;main;2,6;8,4;]")
|
||||||
|
end
|
||||||
|
if(fields.inv_lv2) then
|
||||||
|
meta:set_string("formspec", "size[12,10;]"..
|
||||||
|
"label[0,0;Warehouse]"..
|
||||||
|
"label[2,0;Layer:]"..
|
||||||
|
"button[3,0;1,1;inv_lv1;2]"..
|
||||||
|
"label[4,0;Workspace:]"..
|
||||||
|
"list[current_name;worksp;6,0;5,1;]"..
|
||||||
|
"list[current_name;main2;0,1;12,4;]"..
|
||||||
|
"list[current_player;main;2,6;8,4;]")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'bitchange:warehouse',
|
||||||
|
recipe = {
|
||||||
|
{'default:chest_locked', 'bitchange:minecoinblock', 'default:chest_locked'},
|
||||||
|
{'default:chest_locked', 'default:mese', 'default:chest_locked'},
|
||||||
|
{'default:chest_locked', 'default:chest_locked', 'default:chest_locked'}
|
||||||
|
}
|
||||||
|
})
|