From eec023f449efebb08d2ea038e8712dec54d78689 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sun, 23 Feb 2014 17:33:26 +0100 Subject: [PATCH] Donation box, a better saving, serval updates --- bank_currency.lua | 6 ++-- config.default.txt | 1 + donationbox.lua | 78 ++++++++++++++++++++++++++++++++++++++++++++++ init.lua | 5 ++- minecoins.lua | 17 ++++++++-- moneychanger.lua | 5 +++ shop.lua | 3 ++ toolrepair.lua | 2 +- version.txt | 5 +++ 9 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 donationbox.lua diff --git a/bank_currency.lua b/bank_currency.lua index 0364a5c..64adea8 100644 --- a/bank_currency.lua +++ b/bank_currency.lua @@ -3,7 +3,7 @@ --License: WTFPL local file_path = minetest.get_worldpath() .. "/bitchange_bank_currency" -local exchange_worth = 12 -- default worth in "money" for 10 MineCoins, change if not okay +local exchange_worth = 8 -- default worth in "money" for 10 MineCoins, change if not okay local bank = {} local changes_made = false @@ -60,7 +60,7 @@ local function get_bank_formspec(number, pos) -- owner formspec = ("size[8,9;]".. "label[0,0;Bank]".. - "label[1,0.5;Current MineCoin and MineGelt reserve: (Editable by owner)]".. + "label[1,0.5;Current MineCoin and MineGeld reserve: (Editable by owner)]".. "list["..name..";coins;0,1;8,3;]".. "list[current_player;main;0,5;8,4;]") end @@ -210,4 +210,4 @@ minetest.register_node("bitchange:bank", { end return 0 end, -}) +}) \ No newline at end of file diff --git a/config.default.txt b/config.default.txt index 9c45169..0e4c79a 100644 --- a/config.default.txt +++ b/config.default.txt @@ -7,6 +7,7 @@ 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 diff --git a/donationbox.lua b/donationbox.lua new file mode 100644 index 0000000..7ce24c8 --- /dev/null +++ b/donationbox.lua @@ -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'} + } +}) \ No newline at end of file diff --git a/init.lua b/init.lua index 42fa05f..721eaea 100644 --- a/init.lua +++ b/init.lua @@ -40,6 +40,9 @@ end if(bitchange_enable_toolrepair) then dofile(mod_path.."/toolrepair.lua") end +if(bitchange_enable_donationbox) then + dofile(mod_path.."/donationbox.lua") +end if(bitchange_enable_bank) then local loaded_bank = "" if(minetest.get_modpath("money") ~= nil) then @@ -67,7 +70,7 @@ end -- Privs minetest.register_privilege("bitchange", "Can access to owned nodes of the bitchange mod") function bitchange_has_access(owner, player_name) - return (player_name == owner or minetest.get_player_privs(player_name).server or minetest.get_player_privs(player_name).bitchange) + return (player_name == owner or owner == "" or minetest.get_player_privs(player_name).server or minetest.get_player_privs(player_name).bitchange) end print("[BitChange] Loaded.") diff --git a/minecoins.lua b/minecoins.lua index afcada7..adc6022 100644 --- a/minecoins.lua +++ b/minecoins.lua @@ -9,7 +9,13 @@ minetest.register_node("bitchange:minecoin_in_ground", { is_ground_content = true, groups = {cracky=2}, sounds = default.node_sound_stone_defaults(), - drop = 'bitchange:minecoin', + drop = { + max_items = 2, + items = { + {items = {"bitchange:minecoin"}, rarity = 2 }, + {items = {"bitchange:minecoin 3"} } + } + }, }) minetest.register_node("bitchange:mineninth_in_ground", { @@ -18,7 +24,14 @@ minetest.register_node("bitchange:mineninth_in_ground", { is_ground_content = true, groups = {cracky=3}, sounds = default.node_sound_stone_defaults(), - drop = 'bitchange:coinbase', + drop = { + max_items = 3, + items = { + {items = {"bitchange:coinbase"}, rarity = 5 }, + {items = {"bitchange:coinbase 2"}, rarity = 3 }, + {items = {"bitchange:coinbase 6"} } + } + }, }) minetest.register_node("bitchange:minecoinblock", { diff --git a/moneychanger.lua b/moneychanger.lua index 0c76da0..9e91f57 100644 --- a/moneychanger.lua +++ b/moneychanger.lua @@ -155,6 +155,11 @@ minetest.register_node("bitchange:moneychanger", { end if(listname == "source") then local stack_name = stack:get_name() + local inv = meta:get_inventory() + local inv_stack = inv:get_stack(listname, index) + if(inv_stack:get_name() ~= "") then + return 0 + end 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 diff --git a/shop.lua b/shop.lua index 1aeea9c..5ef0115 100644 --- a/shop.lua +++ b/shop.lua @@ -90,6 +90,9 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) local meta = minetest.get_meta(pos) local title = meta:get_string("title") or "" local shop_owner = meta:get_string("owner") + if(fields.quit) then + exchange_shop[player_name] = nil + end if(fields.exchange) then local player_inv = sender:get_inventory() diff --git a/toolrepair.lua b/toolrepair.lua index 7284b2f..82533bc 100644 --- a/toolrepair.lua +++ b/toolrepair.lua @@ -24,7 +24,7 @@ local function set_infotext(meta, mode) local formspec = "size[8,9]".. - "label[1,1;Damaged tool:]]".. + "label[1,1;Damaged tool:]".. "list[current_name;src;3.5,1;1,1;]".. "label[3.4,2;\\["..text2.."\\]]".. "label[1.5,3;MineNinth:]]".. diff --git a/version.txt b/version.txt index f9d526a..21027b4 100644 --- a/version.txt +++ b/version.txt @@ -1,3 +1,8 @@ +======>- Version 1.7.0 -<====== +- donation box +- more money in money-ores +- possible cheating fixes + ======>- Version 1.6.9 -<====== - optional quartz converting support - some other little changes (also in the configuration)