Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
849f8f8cd7 | |||
f8441dad81 | |||
733ce6f46a | |||
7cf127aa9d | |||
498dadfee6 | |||
07af87559e | |||
98a2dc8572 | |||
b39a6017d4 | |||
99dbde247e | |||
e7798768d4 | |||
7aff3b50bb | |||
3f029c82d6 | |||
0fbda6a40f | |||
bf68097a75 | |||
3814d994db | |||
6f9cc0081a | |||
70f31b7631 | |||
b52f70c09d | |||
b49ba5dc14 | |||
498d97a8bc | |||
db64a14cdc | |||
e7425e19e9 | |||
307f7fb823 | |||
3befc29ac8 | |||
e28d5e58bd | |||
84f1b0f330 | |||
20fcf0a0a0 | |||
5761f2d9fe | |||
45931b8718 | |||
808593bfba | |||
32011311b6 | |||
eec023f449 | |||
f846f5624c | |||
525a89c653 | |||
1adddcd492 | |||
fecfaaf975 | |||
2d36903ffe | |||
c0f291ecf3 | |||
78f27c4bd9 | |||
422d29d765 | |||
acff3661d3 | |||
1a68fcbdc8 |
24
HELP_ME.txt
@ -1,24 +0,0 @@
|
||||
==> 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
|
15
README.md
@ -1,15 +0,0 @@
|
||||
Bitchange
|
||||
=========
|
||||
|
||||
A currency mod for Minetest.
|
||||
|
||||
When you use this mod the first time, then get sure to copy the "config.default.txt" to "config.txt".
|
||||
|
||||
Read more at the forums topic and 'HELP_ME.txt' for more information.
|
||||
|
||||
Forum link: https://forum.minetest.net/viewtopic.php?id=7821
|
||||
|
||||
License: WTFPL *
|
||||
|
||||
|
||||
(*) Everything except the textures of moreores and technic
|
20
README.txt
Normal file
@ -0,0 +1,20 @@
|
||||
BitChange
|
||||
=========
|
||||
|
||||
This mod adds the currency "MineCoin" to your Minetest world.
|
||||
To change a setting, edit the file 'bitchange_config.txt' in your world directory.
|
||||
Copy and paste 'config.default.txt' if the file does not exist yet.
|
||||
|
||||
License: CC0 (for everything)
|
||||
|
||||
Dependencies:
|
||||
default
|
||||
moreores (optional)
|
||||
pipeworks (optional)
|
||||
quartz (optional)
|
||||
technic_worldgen (optional)
|
||||
wrench (optional)
|
||||
|
||||
Forum link: https://forum.minetest.net/viewtopic.php?id=7821
|
||||
|
||||
Requires Minetest 0.4.14 (stable) or newer.
|
@ -1,218 +0,0 @@
|
||||
--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
@ -1,200 +0,0 @@
|
||||
--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 / 1.0059
|
||||
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.006
|
||||
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
@ -1,200 +0,0 @@
|
||||
--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 / 1.0059
|
||||
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.006
|
||||
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,
|
||||
})
|
@ -1,27 +1,26 @@
|
||||
-- General configuration - BitChange
|
||||
-- Created by Krock
|
||||
-- General configuration for the BitChange mod
|
||||
-- Do NOT modify "config.default.txt"! Instead, edit "bitchange_config.txt"
|
||||
-- inside your world's directory. Start the world once to generate the file.
|
||||
|
||||
bitchange_initial_give = 2
|
||||
bitchange.initial_give = 10
|
||||
-- Enable/Disable whole nodes
|
||||
bitchange_enable_exchangeshop = true
|
||||
bitchange_enable_moneychanger = true
|
||||
bitchange_enable_warehouse = false
|
||||
bitchange.enable_exchangeshop = true
|
||||
bitchange.enable_moneychanger = true
|
||||
bitchange.enable_warehouse = false
|
||||
bitchange.enable_toolrepair = true
|
||||
bitchange.enable_donationbox = true
|
||||
|
||||
-- Set this variable to false if you have a supported currency enabled
|
||||
-- and if you want to disable the exchanging/converting point - the bank
|
||||
-- Supported: money (by kotolegokot), money2 (by Bad Command), currency (by Dan Duncombe)
|
||||
bitchange_enable_bank = true
|
||||
-- Enable/Disable Converting Currency Via Crafting
|
||||
bitchange.craft_convert_currency = false
|
||||
|
||||
-- Tin converting/generation
|
||||
bitchange_use_moreores_tin = false -- Activate support
|
||||
bitchange_need_generate_tin = false -- Generate if needed
|
||||
-- Zinc converting/generation
|
||||
bitchange_use_technic_zinc = false -- Activate support
|
||||
bitchange_need_generate_zinc = false -- Generate if needed
|
||||
-- Converting other ores to MineCoins
|
||||
-- Tin default
|
||||
-- Zinc technic_worldgen
|
||||
-- Quartz quartz
|
||||
bitchange.use_technic_zinc = false
|
||||
bitchange.use_quartz = false
|
||||
bitchange.use_default_tin = true
|
||||
|
||||
-- Pipeworks support
|
||||
bitchange_exchangeshop_pipeworks = false
|
||||
bitchange_warehouse_pipeworks = false
|
||||
|
||||
-- Advanced generation settings
|
||||
-- Change in 'minecoins.lua', starting at line 101
|
||||
bitchange.exchangeshop_pipeworks = false
|
||||
bitchange.warehouse_pipeworks = false
|
||||
|
@ -1,7 +0,0 @@
|
||||
default
|
||||
moreores?
|
||||
technic?
|
||||
pipeworks?
|
||||
money?
|
||||
money2?
|
||||
currency?
|
78
donationbox.lua
Normal file
@ -0,0 +1,78 @@
|
||||
--Created by Krock for the BitChange mod
|
||||
--License: WTFPL
|
||||
|
||||
minetest.register_node("bitchange:donationbox", {
|
||||
description = "Donation box",
|
||||
tiles = {"default_wood.png"},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.25,-0.5,-0.4375,0.25,-0.375,0.425}, --NodeBox1
|
||||
{0.25,-0.5,-0.4375,0.425,0.25,0.425}, --NodeBox2
|
||||
{-0.4375,-0.5,-0.4375,-0.25,0.25,0.425}, --NodeBox3
|
||||
{-0.3125,-0.5,-0.4375,0.25,0.0625,-0.25}, --NodeBox4
|
||||
{-0.25,-0.5,0.25,0.25,0.25,0.425}, --NodeBox5
|
||||
{-0.5,0.25,-0.5,0.5,0.375,0.5}, --NodeBox6
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.4,-0.5,-0.4,0.4,0.35,0.4},
|
||||
},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Donation box (constructing)")
|
||||
meta:set_string("owner", "")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 4*2)
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local owner = placer:get_player_name()
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", "size[8,8;]"..
|
||||
"label[2,0;Donation box (owned by "..owner..")]"..
|
||||
"list[current_name;main;2,1;4,2;]"..
|
||||
"list[current_player;main;0,4;8,4;]")
|
||||
meta:set_string("infotext", "Donation box (owned by "..owner..")")
|
||||
meta:set_string("owner", owner)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("main") then
|
||||
return false
|
||||
elseif bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
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)
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bitchange:donationbox",
|
||||
recipe = {
|
||||
{"default:wood", "", "default:wood"},
|
||||
{"default:wood", "bitchange:minecoin", "default:wood"},
|
||||
{"default:wood", "default:wood", "default:wood"}
|
||||
}
|
||||
})
|
82
init.lua
@ -1,41 +1,57 @@
|
||||
--Created by Krock for the BitChange mod
|
||||
local mod_path = minetest.get_modpath("bitchange")
|
||||
bitchange = {}
|
||||
bitchange.mod_path = minetest.get_modpath("bitchange")
|
||||
local world_path = minetest.get_worldpath()
|
||||
|
||||
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_enable_bank) then
|
||||
local loaded_bank = ""
|
||||
if(minetest.get_modpath("money") ~= nil) then
|
||||
loaded_bank = "money"
|
||||
dofile(mod_path.."/bank_"..loaded_bank..".lua")
|
||||
elseif(minetest.get_modpath("money2") ~= nil) then
|
||||
loaded_bank = "money2"
|
||||
dofile(mod_path.."/bank_"..loaded_bank..".lua")
|
||||
elseif(minetest.get_modpath("currency") ~= nil) then
|
||||
loaded_bank = "currency"
|
||||
dofile(mod_path.."/bank_"..loaded_bank..".lua")
|
||||
end
|
||||
if(loaded_bank ~= "") then
|
||||
print("[BitChange] Bank loaded: "..loaded_bank)
|
||||
dofile(bitchange.mod_path.."/config.default.txt")
|
||||
-- Copied from moretrees mod
|
||||
if not io.open(world_path.."/bitchange_config.txt", "r") then
|
||||
io.input(bitchange.mod_path.."/config.default.txt")
|
||||
io.output(world_path.."/bitchange_config.txt")
|
||||
|
||||
while true do
|
||||
local block = io.read(256) -- 256B at once
|
||||
if not block then
|
||||
io.close()
|
||||
break
|
||||
end
|
||||
io.write(block)
|
||||
end
|
||||
else
|
||||
dofile(world_path.."/bitchange_config.txt")
|
||||
end
|
||||
|
||||
if(not minetest.setting_getbool("creative_mode") and bitchange_initial_give > 0) then
|
||||
dofile(bitchange.mod_path.."/minecoins.lua")
|
||||
dofile(bitchange.mod_path.."/moreores.lua")
|
||||
if bitchange.enable_exchangeshop then
|
||||
dofile(bitchange.mod_path.."/shop.lua")
|
||||
end
|
||||
if bitchange.enable_moneychanger then
|
||||
dofile(bitchange.mod_path.."/moneychanger.lua")
|
||||
end
|
||||
if bitchange.enable_warehouse then
|
||||
dofile(bitchange.mod_path.."/warehouse.lua")
|
||||
end
|
||||
if bitchange.enable_toolrepair then
|
||||
dofile(bitchange.mod_path.."/toolrepair.lua")
|
||||
end
|
||||
if bitchange.enable_donationbox then
|
||||
dofile(bitchange.mod_path.."/donationbox.lua")
|
||||
end
|
||||
|
||||
if not minetest.settings:get_bool("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)
|
||||
player:get_inventory():add_item("main", "bitchange:mineninth "..bitchange.initial_give)
|
||||
end)
|
||||
end
|
||||
print("[BitChange] Loaded.")
|
||||
|
||||
-- Privs
|
||||
function bitchange.has_access(owner, player_name)
|
||||
if player_name == owner or owner == "" then
|
||||
return true
|
||||
end
|
||||
local privs = minetest.get_player_privs(player_name)
|
||||
return privs.server or privs.protection_bypass
|
||||
end
|
||||
|
||||
minetest.log("action", "[BitChange] Loaded.")
|
||||
|
161
minecoins.lua
@ -1,133 +1,96 @@
|
||||
--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,
|
||||
tiles = { "bitchange_minecoinblock.png" },
|
||||
groups = {cracky=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
stack_max = 30000,
|
||||
stack_max = 30000,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bitchange:minecoin", {
|
||||
description = "MineCoin",
|
||||
inventory_image = "bitchange_minecoin.png",
|
||||
stack_max = 30000,
|
||||
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",
|
||||
stack_max = 30000,
|
||||
})
|
||||
|
||||
-- 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'},
|
||||
}
|
||||
})
|
||||
if bitchange.craft_convert_currency and minetest.get_modpath("maptools") then
|
||||
minetest.register_craft(
|
||||
{
|
||||
output = "bitchange:mineninth",
|
||||
recipe = {
|
||||
{"maptools:gold_coin", "maptools:gold_coin", "maptools:gold_coin"},
|
||||
{"maptools:gold_coin", "maptools:gold_coin", "maptools:gold_coin"},
|
||||
{"maptools:gold_coin", "maptools:gold_coin", "maptools:gold_coin"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bitchange:minecoin 9',
|
||||
recipe = {
|
||||
{'bitchange:minecoinblock'},
|
||||
}
|
||||
})
|
||||
minetest.register_craft(
|
||||
{
|
||||
output = "maptools:gold_coin 9",
|
||||
recipe = {{"bitchange:mineninth"}}
|
||||
})
|
||||
|
||||
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 = "maptools:gold_coin",
|
||||
recipe = {
|
||||
{"maptools:silver_coin", "maptools:silver_coin", "maptools:silver_coin"},
|
||||
{"maptools:silver_coin", "maptools:silver_coin", "maptools:silver_coin"},
|
||||
{"maptools:silver_coin", "maptools:silver_coin", "maptools:silver_coin"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bitchange:mineninth 9',
|
||||
recipe = {
|
||||
{'bitchange:minecoin'},
|
||||
}
|
||||
})
|
||||
minetest.register_craft(
|
||||
{
|
||||
output = "maptools:silver_coin 9",
|
||||
recipe = {{"maptools:gold_coin"}}
|
||||
})
|
||||
|
||||
minetest.register_craft(
|
||||
{
|
||||
output = "maptools:silver_coin",
|
||||
recipe = {
|
||||
{"maptools:copper_coin", "maptools:copper_coin", "maptools:copper_coin"},
|
||||
{"maptools:copper_coin", "maptools:copper_coin", "maptools:copper_coin"},
|
||||
{"maptools:copper_coin", "maptools:copper_coin", "maptools:copper_coin"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft(
|
||||
{
|
||||
output = "maptools:copper_coin 9",
|
||||
recipe = {{"maptools:silver_coin"}}
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
-- Cooking
|
||||
minetest.register_craft({
|
||||
type = 'cooking',
|
||||
recipe = "bitchange:coinbase",
|
||||
output = "bitchange:mineninth",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = 'cooking',
|
||||
type = "cooking",
|
||||
recipe = "default:goldblock",
|
||||
output = "bitchange:minecoinblock 2",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = 'cooking',
|
||||
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,
|
||||
})
|
||||
-- Legacy
|
||||
if bitchange.enable_generation then
|
||||
minetest.log("warning", "[bitchange] Ores will not be generated any more. Remove the setting " ..
|
||||
"'enable_generation' from your bitchange configuration to suppress this warning.")
|
||||
end
|
||||
|
||||
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_alias("bitchange:minecoin_in_ground", "default:stone_with_gold")
|
||||
minetest.register_alias("bitchange:mineninth_in_ground", "default:stone_with_tin")
|
||||
|
||||
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,
|
||||
})
|
||||
minetest.register_alias("bitchange:coinbase", "bitchange:mineninth")
|
||||
|
5
mod.conf
Normal file
@ -0,0 +1,5 @@
|
||||
name = bitchange
|
||||
title = Bitchange
|
||||
description = This mod adds the currency "MineCoin" to your Minetest world.
|
||||
depends = default
|
||||
optional_depends = pipeworks,quartz,technic_worldgen,wrench,maptools
|
116
moneychanger.lua
@ -22,107 +22,88 @@ moneychanger.update_fields = function(pos, listname, index, stack, take)
|
||||
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
|
||||
|
||||
if take then
|
||||
stack_real_count = stack_inv:get_count() - stack:get_count()
|
||||
else
|
||||
if(stack_inv:get_name() ~= "") then
|
||||
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
|
||||
if listname == "rest" then
|
||||
return stack:get_count()
|
||||
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
|
||||
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
|
||||
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
|
||||
return stack:get_count()
|
||||
elseif stack_real_count == 0 and stack_src:get_count() > 0 then
|
||||
return stack:get_count()
|
||||
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
|
||||
elseif listname == "output" and stack_rest:get_count() == 0 then
|
||||
if stack_src:get_count() < 1 then
|
||||
if stack:get_count() > 0 then
|
||||
return stack:get_count()
|
||||
end
|
||||
inv:set_list("source", { "" })
|
||||
else
|
||||
if(stack_src_name ~= "") then
|
||||
if(stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin") then
|
||||
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
|
||||
if amount_left > 0 then
|
||||
inv:set_list("source", { stack_src_name.." "..amount_left })
|
||||
else
|
||||
inv:set_list("source", { "" })
|
||||
end
|
||||
if(index == 1) then
|
||||
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
|
||||
return stack:get_count()
|
||||
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
|
||||
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
|
||||
return stack:get_count()
|
||||
elseif (stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:minecoinblock") or
|
||||
(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
|
||||
if amount_left > -1 then
|
||||
inv:set_list("source", { stack_src_name.." "..math.floor(amount_left) })
|
||||
if(rest_count > 0) then
|
||||
if rest_count > 0 then
|
||||
inv:set_list("rest", { stack_name.." "..rest_count })
|
||||
else
|
||||
inv:set_list("rest", { "" })
|
||||
end
|
||||
if(index == 1) then
|
||||
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
|
||||
return stack:get_count()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif(listname == "rest") then
|
||||
canMove = true
|
||||
end
|
||||
if(canMove) then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
minetest.register_node("bitchange:moneychanger", {
|
||||
@ -151,35 +132,38 @@ minetest.register_node("bitchange:moneychanger", {
|
||||
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
|
||||
if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
if(listname == "source") then
|
||||
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
|
||||
local inv = meta:get_inventory()
|
||||
local inv_stack = inv:get_stack(listname, index)
|
||||
if inv_stack:get_name() ~= "" then
|
||||
return 0
|
||||
end
|
||||
else
|
||||
return 0
|
||||
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)
|
||||
end
|
||||
end
|
||||
return 0
|
||||
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
|
||||
if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return moneychanger.update_fields(pos, listname, index, stack, true)
|
||||
else
|
||||
return 0
|
||||
end
|
||||
return 0
|
||||
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
|
||||
if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest")
|
||||
end
|
||||
return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest")
|
||||
return 0
|
||||
end
|
||||
})
|
||||
|
||||
@ -187,7 +171,7 @@ minetest.register_craft({
|
||||
output = 'bitchange:moneychanger',
|
||||
recipe = {
|
||||
{'default:stone', 'bitchange:mineninth', 'default:stone'},
|
||||
{'default:steel_ingot', 'bitchange:minecoin', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'bitchange:minecoinblock', 'default:steel_ingot'},
|
||||
{'default:stone', 'default:stone', 'default:stone'}
|
||||
}
|
||||
})
|
132
moreores.lua
@ -1,126 +1,22 @@
|
||||
--Created by Krock
|
||||
--License: WTFPL
|
||||
-- Conversion of other ores to money
|
||||
|
||||
if (bitchange_use_moreores_tin) then
|
||||
if(bitchange_need_generate_tin and not minetest.get_modpath("moreores")) 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
|
||||
if bitchange.use_technic_zinc and minetest.get_modpath("technic_worldgen") then
|
||||
minetest.register_craft({
|
||||
output = "bitchange:coinbase 18",
|
||||
recipe = {
|
||||
{"moreores:tin_block", "default:pick_diamond"},
|
||||
{"moreores:tin_block", ""}
|
||||
},
|
||||
replacements = { {"default:pick_diamond", "default:pick_diamond"} },
|
||||
type = "cooking",
|
||||
output = "bitchange:mineninth 8",
|
||||
recipe = "technic:zinc_block",
|
||||
})
|
||||
end
|
||||
|
||||
if (bitchange_use_technic_zinc) then
|
||||
if (bitchange_need_generate_zinc and not minetest.get_modpath("technic_worldgen")) 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
|
||||
if bitchange.use_moreores_tin then
|
||||
bitchange.use_default_tin = true
|
||||
minetest.log("warning", "[bitchange] Loaded deprecated setting 'use_default_tin'")
|
||||
end
|
||||
|
||||
if bitchange.use_default_tin then
|
||||
minetest.register_craft({
|
||||
output = "bitchange:coinbase 8",
|
||||
recipe = {
|
||||
{"technic:zinc_block", "default:pick_diamond"},
|
||||
{"technic:zinc_block", ""}
|
||||
},
|
||||
replacements = { {"default:pick_diamond", "default:pick_diamond"} },
|
||||
type = "cooking",
|
||||
output = "bitchange:mineninth 18",
|
||||
recipe = "default:tinblock"
|
||||
})
|
||||
end
|
610
shop.lua
@ -1,241 +1,374 @@
|
||||
--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
|
||||
--[[
|
||||
Exchange Shop [bitchange]
|
||||
|
||||
This code is based on the idea of Dan Duncombe's exchange shop
|
||||
https://web.archive.org/web/20160403113102/https://forum.minetest.net/viewtopic.php?id=7002
|
||||
You do not need the entire bitchange mod to use this code.
|
||||
Make sure you've got all textures to use it in a separate mod.
|
||||
|
||||
License: WTFPL
|
||||
]]
|
||||
|
||||
|
||||
if not bitchange then
|
||||
-- Default values, if bitchange wasn't found.
|
||||
bitchange = {}
|
||||
bitchange.exchangeshop_pipeworks = true
|
||||
|
||||
function bitchange.has_access(owner, player_name)
|
||||
if player_name == owner or owner == "" then
|
||||
return true
|
||||
end
|
||||
local privs = minetest.get_player_privs(player_name)
|
||||
return privs.server or privs.protection_bypass
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
-- Tool wear aware replacement for contains_item.
|
||||
local function list_contains_item(inv, listname, stack)
|
||||
local count = stack:get_count()
|
||||
if count == 0 then
|
||||
return true
|
||||
end
|
||||
|
||||
local list = inv:get_list(listname)
|
||||
local name = stack:get_name()
|
||||
local wear = stack:get_wear()
|
||||
for _, list_stack in pairs(list) do
|
||||
if list_stack:get_name() == name and
|
||||
list_stack:get_wear() <= wear then
|
||||
if list_stack:get_count() >= count then
|
||||
return true
|
||||
else
|
||||
count = count - list_stack:get_count()
|
||||
end
|
||||
end
|
||||
end
|
||||
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;]")
|
||||
-- Tool wear aware replacement for remove_item.
|
||||
local function list_remove_item(inv, listname, stack)
|
||||
local wanted = stack:get_count()
|
||||
if wanted == 0 then
|
||||
return stack
|
||||
end
|
||||
return formspec
|
||||
|
||||
local list = inv:get_list(listname)
|
||||
local name = stack:get_name()
|
||||
local wear = stack:get_wear()
|
||||
local remaining = wanted
|
||||
local removed_wear = 0
|
||||
|
||||
for index, list_stack in pairs(list) do
|
||||
if list_stack:get_name() == name and
|
||||
list_stack:get_wear() <= wear then
|
||||
local taken_stack = list_stack:take_item(remaining)
|
||||
inv:set_stack(listname, index, list_stack)
|
||||
|
||||
removed_wear = math.max(removed_wear, taken_stack:get_wear())
|
||||
remaining = remaining - taken_stack:get_count()
|
||||
if remaining == 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Todo: Also remove kebab
|
||||
local removed_stack = ItemStack(name)
|
||||
removed_stack:set_count(wanted - remaining)
|
||||
removed_stack:set_wear(removed_wear)
|
||||
return removed_stack
|
||||
end
|
||||
|
||||
local function get_exchange_shop_formspec(mode, pos, title)
|
||||
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||
|
||||
if mode == "customer" then
|
||||
-- customer
|
||||
return (
|
||||
"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.4;2,1;exchange;Exchange]"..
|
||||
"label[5,0.5;Owner gives:]"..
|
||||
"list["..name..";cust_og;5,1;2,2;]"..
|
||||
"label[0.7,3.5;Ejected items:]"..
|
||||
"label[0.7,3.8;(Remove me!)]"..
|
||||
"list["..name..";cust_ej;3,3.5;4,1;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring["..name..";custm_ej]"..
|
||||
"listring[current_player;main]"
|
||||
)
|
||||
end
|
||||
if mode == "owner_custm"
|
||||
or mode == "owner_stock" then
|
||||
-- owner
|
||||
local formspec = (
|
||||
"size[11,10;]"..
|
||||
"label[0.3,0.1;Title:]"..
|
||||
"field[1.5,0.5;3,0.5;title;;"..title.."]"..
|
||||
"field_close_on_enter[title;false]"..
|
||||
"button[4.1,0.2;1,0.5;set_title;Set]"..
|
||||
"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[0,3.5;Ejected items: (Remove me!)]"..
|
||||
"list["..name..";custm_ej;0,4;4,1;]"..
|
||||
"label[6,0;You are viewing:]"..
|
||||
"label[6,0.3;(Click to switch)]"..
|
||||
"listring["..name..";custm_ej]"..
|
||||
"listring[current_player;main]"
|
||||
)
|
||||
if mode == "owner_custm" then
|
||||
formspec = (formspec..
|
||||
"button[8.5,0.2;2.5,0.5;vstock;Customers stock]"..
|
||||
"list["..name..";custm;6,1;5,4;]"..
|
||||
"listring["..name..";custm]"..
|
||||
"listring[current_player;main]")
|
||||
else
|
||||
formspec = (formspec..
|
||||
"button[8.5,0.2;2.5,0.5;vcustm;Your stock]"..
|
||||
"list["..name..";stock;6,1;5,4;]"..
|
||||
"listring["..name..";stock]"..
|
||||
"listring[current_player;main]")
|
||||
end
|
||||
return (formspec..
|
||||
"label[1,5;Use (E) + (Right click) for customer interface]"..
|
||||
"list[current_player;main;1,6;8,4;]")
|
||||
end
|
||||
return ""
|
||||
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
|
||||
if mode == "groups" then
|
||||
if bitchange.exchangeshop_pipeworks then
|
||||
return {choppy=2, oddly_breakable_by_hand=2,
|
||||
tubedevice=1, tubedevice_receiver=1}
|
||||
end
|
||||
return {choppy=2, oddly_breakable_by_hand=2}
|
||||
end
|
||||
if mode == "tube" then
|
||||
if bitchange.exchangeshop_pipeworks then
|
||||
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)
|
||||
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)
|
||||
return inv:room_for_item("stock", stack)
|
||||
end,
|
||||
input_inventory="custm",
|
||||
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
|
||||
return {
|
||||
insert_object = function()
|
||||
return false
|
||||
end,
|
||||
can_insert = function()
|
||||
return false
|
||||
end,
|
||||
connect_sides = {}
|
||||
}
|
||||
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 formname ~= "bitchange:shop_formspec" then
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
local player_name = sender:get_player_name()
|
||||
local pos = exchange_shop[player_name]
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
|
||||
if fields.quit then
|
||||
exchange_shop[player_name] = nil
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local title = meta:get_string("title")
|
||||
local shop_owner = meta:get_string("owner")
|
||||
|
||||
if fields.title and bitchange.has_access(shop_owner, player_name) then
|
||||
-- Limit title length
|
||||
fields.title = fields.title:sub(1, 80)
|
||||
if title ~= fields.title then
|
||||
if fields.title ~= "" then
|
||||
meta:set_string("infotext", "'" .. fields.title
|
||||
.. "' (owned by " .. shop_owner .. ")")
|
||||
else
|
||||
meta:set_string("infotext", "Exchange shop (owned by "
|
||||
.. shop_owner ..")")
|
||||
end
|
||||
meta:set_string("title", minetest.formspec_escape(fields.title))
|
||||
end
|
||||
end
|
||||
|
||||
if fields.exchange then
|
||||
local shop_inv = meta:get_inventory()
|
||||
if shop_inv:is_empty("cust_ow")
|
||||
and shop_inv:is_empty("cust_og") then
|
||||
return
|
||||
end
|
||||
if not shop_inv:is_empty("cust_ej")
|
||||
or not shop_inv:is_empty("custm_ej") then
|
||||
minetest.chat_send_player(player_name,
|
||||
"One or multiple ejection fields are filled. "..
|
||||
"Please empty them or contact the shop owner.")
|
||||
return
|
||||
end
|
||||
local player_inv = sender:get_inventory()
|
||||
local err_msg = ""
|
||||
local cust_ow = shop_inv:get_list("cust_ow")
|
||||
local cust_og = shop_inv:get_list("cust_og")
|
||||
|
||||
-- Check validness of stack "owner wants"
|
||||
local cust_ow_ok = true
|
||||
for i1, item1 in pairs(cust_ow) do
|
||||
local name1 = item1:get_name()
|
||||
for i2, item2 in pairs(cust_ow) do
|
||||
if name1 == "" then
|
||||
break
|
||||
end
|
||||
if(not cust_ow_legal) then
|
||||
if i1 ~= i2 and name1 == item2:get_name() then
|
||||
cust_ow_ok = false
|
||||
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)
|
||||
if not cust_ow_ok then
|
||||
err_msg = "The field 'Owner needs' can not contain multiple "..
|
||||
"times the same items. Please contact the shop owner."
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Check validness of stack "owner gives"
|
||||
if err_msg == "" then
|
||||
local cust_og_ok = true
|
||||
for i1, item1 in pairs(cust_og) do
|
||||
local name1 = item1:get_name()
|
||||
for i2, item2 in pairs(cust_og) do
|
||||
if name1 == "" then
|
||||
break
|
||||
end
|
||||
if i1 ~= i2 and name1 == item2:get_name() then
|
||||
cust_og_ok = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if not cust_og_ok then
|
||||
err_msg = "The field 'Owner gives' can not contain multiple "..
|
||||
"times the same items. Please contact the shop owner."
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check for space in the shop
|
||||
if err_msg == "" then
|
||||
for i, item in pairs(cust_ow) do
|
||||
if not shop_inv:room_for_item("custm", item) then
|
||||
err_msg = "The stock in this shop is full. "..
|
||||
"Please contact the shop owner."
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check availability of the shop's items
|
||||
if err_msg == "" then
|
||||
for i, item in pairs(cust_og) do
|
||||
if not list_contains_item(shop_inv, "stock", item) then
|
||||
err_msg = "This shop is sold out."
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check for space in the player's inventory
|
||||
if err_msg == "" then
|
||||
for i, item in pairs(cust_og) do
|
||||
if not player_inv:room_for_item("main", item) then
|
||||
err_msg = "You do not have enough space in your inventory."
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check availability of the player's items
|
||||
if err_msg == "" then
|
||||
for i, item in pairs(cust_ow) do
|
||||
if not list_contains_item(player_inv, "main", item) then
|
||||
err_msg = "You do not have the required items."
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Do the exchange!
|
||||
if err_msg == "" then
|
||||
local fully_exchanged = true
|
||||
for i, item in pairs(cust_ow) do
|
||||
local stack = list_remove_item(player_inv, "main", item)
|
||||
if shop_inv:room_for_item("custm", stack) then
|
||||
shop_inv:add_item("custm", stack)
|
||||
else
|
||||
-- Move to ejection field
|
||||
shop_inv:add_item("custm_ej", stack)
|
||||
fully_exchanged = false
|
||||
end
|
||||
end
|
||||
for i, item in pairs(cust_og) do
|
||||
local stack = list_remove_item(shop_inv, "stock", item)
|
||||
if player_inv:room_for_item("main", stack) then
|
||||
player_inv:add_item("main", stack)
|
||||
else
|
||||
-- Move to ejection field
|
||||
shop_inv:add_item("cust_ej", stack)
|
||||
fully_exchanged = false
|
||||
end
|
||||
end
|
||||
if not fully_exchanged then
|
||||
err_msg = "Warning! Stacks are overflowing somewhere!"
|
||||
end
|
||||
end
|
||||
|
||||
-- Throw error message
|
||||
if err_msg ~= "" then
|
||||
minetest.chat_send_player(player_name, "Exchange shop: "..err_msg)
|
||||
end
|
||||
elseif bitchange.has_access(shop_owner, player_name) then
|
||||
local mode
|
||||
if fields.vcustm then
|
||||
mode = "owner_custm"
|
||||
elseif fields.vstock then
|
||||
mode = "owner_stock"
|
||||
else
|
||||
return
|
||||
end
|
||||
minetest.show_formspec(player_name, "bitchange:shop_formspec",
|
||||
get_exchange_shop_formspec(mode, pos, title))
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_node("bitchange:shop", {
|
||||
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),
|
||||
groups = get_exchange_shop_tube_config("groups"),
|
||||
tube = get_exchange_shop_tube_config("tube"),
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -259,46 +392,59 @@ minetest.register_node("bitchange:shop", {
|
||||
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
|
||||
if inv:is_empty("stock") and inv:is_empty("custm")
|
||||
and inv:is_empty("cust_ow") and inv:is_empty("custm_ej")
|
||||
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
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
"Cannot dig exchange shop: one or multiple stocks are in use.")
|
||||
return false
|
||||
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
|
||||
|
||||
local mode = "customer"
|
||||
if bitchange.has_access(meta:get_string("owner"), player_name) and
|
||||
not clicker:get_player_control().aux1 then
|
||||
mode = "owner_custm"
|
||||
end
|
||||
minetest.show_formspec(player_name,"bitchange:shop_formspec",get_exchange_shop_formspec(view, pos, meta:get_string("title")))
|
||||
exchange_shop[player_name] = pos
|
||||
minetest.show_formspec(player_name, "bitchange:shop_formspec",
|
||||
get_exchange_shop_formspec(mode, 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
|
||||
if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return count
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if player:get_player_name() == ":pipeworks" then
|
||||
return stack:get_count()
|
||||
end
|
||||
if listname == "custm" then
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
"Exchange shop: Please press 'Customers stock' and insert your items there.")
|
||||
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
|
||||
if bitchange.has_access(meta:get_string("owner"), player:get_player_name())
|
||||
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)
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if player:get_player_name() == ":pipeworks" then
|
||||
return stack:get_count()
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
if (has_exchange_shop_privilege(meta, player) or (listname == "cust_ej")) then
|
||||
if bitchange.has_access(meta:get_string("owner"), player:get_player_name())
|
||||
or listname == "cust_ej" then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
@ -306,9 +452,27 @@ minetest.register_node("bitchange:shop", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bitchange:shop',
|
||||
output = "bitchange:shop",
|
||||
recipe = {
|
||||
{'default:sign_wall'},
|
||||
{'default:chest_locked'},
|
||||
{"default:sign_wall"},
|
||||
{"default:chest_locked"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
exchange_shop[player_name] = nil
|
||||
end)
|
||||
|
||||
if minetest.get_modpath("wrench") and wrench then
|
||||
local STRING = wrench.META_TYPE_STRING
|
||||
wrench:register_node("bitchange:shop", {
|
||||
lists = {"stock", "custm", "custm_ej", "cust_ow", "cust_og", "cust_ej"},
|
||||
metas = {
|
||||
owner = STRING,
|
||||
infotext = STRING,
|
||||
title = STRING,
|
||||
},
|
||||
owned = true
|
||||
})
|
||||
end
|
||||
|
Before Width: | Height: | Size: 522 B |
Before Width: | Height: | Size: 343 B |
Before Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 334 B |
Before Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 822 B |
Before Width: | Height: | Size: 755 B |
Before Width: | Height: | Size: 734 B |
Before Width: | Height: | Size: 485 B |
Before Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 441 B |
Before Width: | Height: | Size: 988 B |
Before Width: | Height: | Size: 619 B |
Before Width: | Height: | Size: 482 B |
Before Width: | Height: | Size: 1003 B After Width: | Height: | Size: 760 B |
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 1006 B After Width: | Height: | Size: 745 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 764 B |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 738 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 672 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 652 B |
BIN
textures/bitchange_toolrepair_bottom.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
textures/bitchange_toolrepair_side.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/bitchange_toolrepair_top.png
Normal file
After Width: | Height: | Size: 765 B |
Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 957 B After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 891 B |
Before Width: | Height: | Size: 681 B |
Before Width: | Height: | Size: 317 B |
Before Width: | Height: | Size: 308 B |
140
toolrepair.lua
Normal file
@ -0,0 +1,140 @@
|
||||
--Created by Krock for the BitChange mod
|
||||
--License: WTFPL
|
||||
|
||||
local function set_infotext(meta, mode)
|
||||
if mode == meta:get_int("state") then
|
||||
return
|
||||
end
|
||||
local owner = meta:get_string("owner")
|
||||
local text = "Tool Repair "
|
||||
local text2 = "[Inactive]"
|
||||
if mode == 0 then
|
||||
text = text.."(constructing)"
|
||||
elseif mode == 1 then
|
||||
text2 = "Inactive"
|
||||
elseif mode == 2 then
|
||||
text2 = "Active"
|
||||
end
|
||||
if mode ~= 0 then
|
||||
text = text.."["..text2.."] (owned by "..owner..")"
|
||||
end
|
||||
|
||||
meta:set_int("state", mode)
|
||||
meta:set_string("infotext", text)
|
||||
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"label[1,1;Damaged tool:]"..
|
||||
"list[current_name;src;3.5,1;1,1;]"..
|
||||
"label[3.4,2;\\["..text2.."\\]]"..
|
||||
"label[1.5,3;MineNinth:]]"..
|
||||
"list[current_name;fuel;3.5,3;1,1;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
||||
|
||||
minetest.register_node("bitchange:toolrepair", {
|
||||
description = "Tool Repair",
|
||||
tiles = {"bitchange_toolrepair_top.png", "bitchange_toolrepair_bottom.png",
|
||||
"bitchange_toolrepair_side.png", "bitchange_toolrepair_side.png",
|
||||
"bitchange_toolrepair_side.png", "bitchange_toolrepair_side.png"},
|
||||
groups = {cracky=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_int("state", 0)
|
||||
set_infotext(meta, 1)
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", "")
|
||||
set_infotext(meta, 0)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("fuel", 1)
|
||||
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 == "src" then
|
||||
if(stack:get_wear() > 0
|
||||
and stack:get_wear() < 65535
|
||||
and stack:get_name() ~= "technic:water_can"
|
||||
and stack:get_name() ~= "technic:lava_can") then
|
||||
return 1
|
||||
end
|
||||
elseif listname == "fuel" then
|
||||
if stack:get_name() == "bitchange:mineninth" then
|
||||
return stack:get_count()
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return inv:is_empty("src") and inv:is_empty("fuel")
|
||||
end
|
||||
return 0
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bitchange:toolrepair",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:stick", "default:steel_ingot"},
|
||||
{"default:jungletree", "default:mese_crystal", "default:jungletree"},
|
||||
{"default:jungletree", "bitchange:minecoinblock", "default:jungletree"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"bitchange:toolrepair"},
|
||||
interval = 5,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local src = inv:get_stack("src", 1)
|
||||
local wear = src:get_wear()
|
||||
local repair = -1400
|
||||
|
||||
if(src:is_empty()
|
||||
or wear == 0
|
||||
or wear == 65535
|
||||
or src:get_name() == "technic:water_can"
|
||||
or src:get_name() == "technic:lava_can") then
|
||||
set_infotext(meta, 1)
|
||||
return
|
||||
end
|
||||
local fuel = inv:get_stack("fuel", 1)
|
||||
if(fuel:is_empty() or fuel:get_name() ~= "bitchange:mineninth") then
|
||||
set_infotext(meta, 1)
|
||||
return
|
||||
end
|
||||
|
||||
if(wear + repair < 0) then
|
||||
src:add_wear(repair + wear)
|
||||
else
|
||||
src:add_wear(repair)
|
||||
end
|
||||
inv:set_stack("src", 1, src)
|
||||
set_infotext(meta, 2)
|
||||
inv:remove_item("fuel", "bitchange:mineninth 1")
|
||||
end
|
||||
})
|
73
version.txt
@ -1,73 +0,0 @@
|
||||
======>- 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
|
||||
===============================
|
@ -2,12 +2,8 @@
|
||||
-- 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(bitchange.warehouse_pipeworks) then
|
||||
if(mode == 1) then
|
||||
return {cracky=1, level=2, tubedevice=1, tubedevice_receiver=1}
|
||||
else
|
||||
@ -15,22 +11,22 @@ function get_warehouse_tube_config(mode)
|
||||
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)
|
||||
if inv:room_for_item("main", stack) then
|
||||
return inv:add_item("main", stack)
|
||||
else
|
||||
return inv:add_item("main2",stack)
|
||||
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
|
||||
if inv:room_for_item("main", stack) then
|
||||
return true
|
||||
else
|
||||
return inv:room_for_item("main2",stack)
|
||||
return inv:room_for_item("main2", stack)
|
||||
end
|
||||
end,
|
||||
input_inventory="main",
|
||||
input_inventory = "main",
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1}
|
||||
}
|
||||
end
|
||||
@ -94,28 +90,31 @@ minetest.register_node("bitchange:warehouse", {
|
||||
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
|
||||
if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
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
|
||||
if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
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
|
||||
if not bitchange.has_access(meta:get_string("owner"), player:get_player_name()) 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
|
||||
if not bitchange.has_access(meta:get_string("owner"), sender:get_player_name()) then
|
||||
return
|
||||
end
|
||||
if fields.inv_lv1 then
|
||||
meta:set_string("formspec", "size[12,10;]"..
|
||||
"label[0,0;Warehouse]"..
|
||||
"label[2,0;Layer:]"..
|
||||
@ -125,7 +124,7 @@ minetest.register_node("bitchange:warehouse", {
|
||||
"list[current_name;main;0,1;12,4;]"..
|
||||
"list[current_player;main;2,6;8,4;]")
|
||||
end
|
||||
if(fields.inv_lv2) then
|
||||
if fields.inv_lv2 then
|
||||
meta:set_string("formspec", "size[12,10;]"..
|
||||
"label[0,0;Warehouse]"..
|
||||
"label[2,0;Layer:]"..
|
||||
@ -139,10 +138,10 @@ minetest.register_node("bitchange:warehouse", {
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bitchange:warehouse',
|
||||
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'}
|
||||
{"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"}
|
||||
}
|
||||
})
|