From 7aff3b50bb1ed14a09eb00c3fa9aafb64937e267 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 25 Nov 2017 12:35:32 +0100 Subject: [PATCH] Remove bank, clean up dependencies --- README.txt | 8 +-- bank.lua | 109 ---------------------------- bank_currency.lua | 113 ------------------------------ bank_money.lua | 96 ------------------------- bank_money2.lua | 95 ------------------------- config.default.txt | 7 +- depends.txt | 7 +- init.lua | 15 ---- textures/bitchange_bank_front.png | Bin 909 -> 0 bytes textures/bitchange_bank_side.png | Bin 497 -> 0 bytes 10 files changed, 6 insertions(+), 444 deletions(-) delete mode 100644 bank.lua delete mode 100644 bank_currency.lua delete mode 100644 bank_money.lua delete mode 100644 bank_money2.lua delete mode 100644 textures/bitchange_bank_front.png delete mode 100644 textures/bitchange_bank_side.png diff --git a/README.txt b/README.txt index f48c058..6c2f62c 100644 --- a/README.txt +++ b/README.txt @@ -10,12 +10,10 @@ License: CC0 (for everything) Dependencies: default moreores (optional) - technic_worldgen (optional) - quartz (optional) pipeworks (optional) - money (optional) - money2 (optional) - currency (optional) + quartz (optional) + technic_worldgen (optional) + wrench (optional) Forum link: https://forum.minetest.net/viewtopic.php?id=7821 diff --git a/bank.lua b/bank.lua deleted file mode 100644 index c002b7b..0000000 --- a/bank.lua +++ /dev/null @@ -1,109 +0,0 @@ -bitchange.bank = {} -bitchange.bank.players = {} -bitchange.bank.file_path = "" -bitchange.bank.exchange_worth = 0 -bitchange.bank.changes_made = false - -minetest.after(1, function() - local file = io.open(bitchange.bank.file_path, "r") - if not file then - return - end - bitchange.bank.exchange_worth = tonumber(file:read("*l")) - io.close(file) -end) - -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 - -function bitchange.bank.save() - if not bitchange.bank.changes_made then - return - end - local file = io.open(bitchange.bank.file_path, "w") - file:write(tostring(bitchange.bank.exchange_worth)) - io.close(file) - bitchange.bank.changes_made = false -end - - -local ttime = 0 -minetest.register_globalstep(function(t) - ttime = ttime + t - if ttime < 240 then --every 4min' - return - end - bitchange.bank.save() - ttime = 0 -end) - -minetest.register_on_shutdown(function() - bitchange.bank.save() -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, not_in_creative_inventory=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 - bitchange.bank.players[player_name] = pos - if clicker:get_player_control().aux1 then - view = 2 - end - minetest.show_formspec(player_name, "bitchange:bank_formspec", bitchange.bank.get_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 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) - 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, - 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, -}) \ No newline at end of file diff --git a/bank_currency.lua b/bank_currency.lua deleted file mode 100644 index f405e71..0000000 --- a/bank_currency.lua +++ /dev/null @@ -1,113 +0,0 @@ --- Bank node for the mod: currency (by Dan Duncombe) - --- default worth in "money" for 10 MineCoins -bitchange.bank.exchange_worth = 8 - -function bitchange.bank.get_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(bitchange.bank.exchange_worth / 10, 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 and MineGeld 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 - return - end - local player_name = sender:get_player_name() - if fields.quit then - bitchange.bank.players[player_name] = nil - return - end - if bitchange.bank.exchange_worth < 1 then - bitchange.bank.exchange_worth = 1 - end - local pos = bitchange.bank.players[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 = false - - if fields.buy10 then - local new_worth = bitchange.bank.exchange_worth * 0.995 - geld_stack = geld_stack..math.floor(new_worth + 0.5) - if not player_inv:contains_item("main", coin_stack) then - err_msg = "You do not have the needed MineCoins." - end - if not 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 not 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 not 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 not err_msg == "" then - bitchange.bank.exchange_worth = new_worth - 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) - bitchange.bank.changes_made = true - err_msg = "Sold 10 MineCoins for "..math.floor(new_worth + 0.5).." MineGeld" - end - elseif fields.sell10 then - local price = math.floor(bitchange.bank.exchange_worth + 0.5) - geld_stack = geld_stack..price - 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 not 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 not 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 not 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 not 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) - bitchange.bank.exchange_worth = bitchange.bank.exchange_worth * 1.005 - bitchange.bank.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) diff --git a/bank_money.lua b/bank_money.lua deleted file mode 100644 index 8d33001..0000000 --- a/bank_money.lua +++ /dev/null @@ -1,96 +0,0 @@ --- Bank node for the mod: money (by kotolegokot) - --- default worth in "money" for one MineCoin -bitchange.bank.exchange_worth = 70.0 - -function bitchange.bank.get_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(bitchange.bank.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 - return - end - local player_name = sender:get_player_name() - if fields.quit then - bitchange.bank.players[player_name] = nil - return - end - if bitchange.bank.exchange_worth < 1 then - bitchange.bank.exchange_worth = 1 - end - local pos = bitchange.bank.players[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 = false - - if fields.buy10 then - local new_worth = bitchange.bank.exchange_worth / 1.0059 - if not player_inv:contains_item("main", coin_stack) then - err_msg = "You do not have the needed MineCoins." - end - if not 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 not err_msg == "" then - bitchange.bank.exchange_worth = bitchange.bank.exchange_worth / 1.0059 - local price = round(bitchange.bank.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) - bitchange.bank.changes_made = true - err_msg = "Sold 10 MineCoins for "..price.." money" - end - elseif fields.sell10 then - local price = round(bitchange.bank.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 not 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 not 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 not 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) - bitchange.bank.exchange_worth = bitchange.bank.exchange_worth * 1.006 - bitchange.bank.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) \ No newline at end of file diff --git a/bank_money2.lua b/bank_money2.lua deleted file mode 100644 index 0830a48..0000000 --- a/bank_money2.lua +++ /dev/null @@ -1,95 +0,0 @@ --- Bank node for the mod: money2 (by Bad Command) - --- default worth in "cr" for one MineCoin -bitchange.bank.exchange_worth = 70.0 - -function bitchange.bank.get_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(bitchange.bank.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 - return - end - local player_name = sender:get_player_name() - if fields.quit then - bitchange.bank.players[player_name] = nil - return - end - if bitchange.bank.exchange_worth < 1 then - bitchange.bank.exchange_worth = 1 - end - local pos = bitchange.bank.players[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 = false - - if fields.buy10 then - local new_worth = bitchange.bank.exchange_worth / 1.0059 - if not player_inv:contains_item("main", coin_stack) then - err_msg = "You do not have the needed MineCoins." - end - if not 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 not err_msg == "" then - bitchange.bank.exchange_worth = bitchange.bank.exchange_worth / 1.0059 - 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) - bitchange.bank.changes_made = true - err_msg = "Sold 10 MineCoins for "..price.." cr" - end - elseif fields.sell10 then - local price = round(bitchange.bank.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.." cr)" - end - if not 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 not 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 not err_msg == "" then - money.set(player_name, cur_money - price) - bank_inv:remove_item("coins", coin_stack) - player_inv:add_item("main", coin_stack) - bitchange.bank.exchange_worth = bitchange.bank.exchange_worth * 1.006 - bitchange.bank.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) \ No newline at end of file diff --git a/config.default.txt b/config.default.txt index 96d5367..ac4f499 100644 --- a/config.default.txt +++ b/config.default.txt @@ -9,11 +9,6 @@ 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 = false - -- Converting other ores to MineCoins -- Tin moreores -- Zinc technic_worldgen @@ -28,4 +23,4 @@ bitchange.warehouse_pipeworks = false -- Advanced generation settings -- Change in 'minecoins.lua', starting at line 101 -bitchange.enable_generation = false \ No newline at end of file +bitchange.enable_generation = false diff --git a/depends.txt b/depends.txt index 8eae95c..b59e233 100644 --- a/depends.txt +++ b/depends.txt @@ -1,9 +1,6 @@ default moreores? +pipeworks? +quartz? technic_worldgen? wrench? -quartz? -pipeworks? -money? -money2? -currency? \ No newline at end of file diff --git a/init.lua b/init.lua index 63e21fc..e095f8c 100644 --- a/init.lua +++ b/init.lua @@ -37,21 +37,6 @@ end if bitchange.enable_donationbox then dofile(bitchange.mod_path.."/donationbox.lua") end -if bitchange.enable_bank then - local loaded_bank = false - for i, v in ipairs({"money", "money2", "currency"}) do - if minetest.get_modpath(v) then - loaded_bank = v - break - end - end - if loaded_bank then - dofile(bitchange.mod_path.."/bank.lua") - bitchange.bank.file_path = world_path.."/bitchange_bank_"..loaded_bank - dofile(bitchange.mod_path.."/bank_"..loaded_bank..".lua") - minetest.log("action", "[BitChange] Bank loaded: "..loaded_bank) - end -end if not minetest.setting_getbool("creative_mode") and bitchange.initial_give > 0 then -- Giving initial money diff --git a/textures/bitchange_bank_front.png b/textures/bitchange_bank_front.png deleted file mode 100644 index 11282e5f43d6880ff96924db6271a9d8b5f3e4d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 909 zcmV;819JR{P)Px#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy32;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9a%BKeVQFr3 zE>1;MAa*k@H7+qQF!XYv0003IP)t-sEgb_mAOJlh07NJNOg0o?Issrh0$@7=U`8Hc zJOg1o1YtY{VLS$5JqBSu2x2`5Vm}FDKMG<&5o16KV?YaILlk307i2*VWJelgM;&BI zA7w%hWkV5VL=t606JzblWiy9kEs1C~iim`aYB!9GjE`+NkX8VbVHTEhJcLyQ*Z=?lvq?ljR5;6h zljl;yFc5@AwFwXiq4$K|yTA}iC;?%FhyY{s{ttrgbh14I!~V#~)~EH|Uc??-|LT#o z5)@Co@)ayw1>kmXvtm`QZtUJ9iL&BKApqbqXCJVA-gx`m4yh&(M8TV0$cNRHe}1j9I$Tksjpy>e5c=gGseE) z$A4+%47-?$sIzw+YR3#hX8@25wiGXp*?>ZvNjpi z#$6W`*Q9B)&{pv70WGV~Py^>56WbV)1#B6{0b1`>o+;`iIqaX7d5{=oy)=HTG9Y=G z42ED38a8dvGrg-%c7iwy8l1RTD);rEg5j}CH)7$3C4`NgD!lvVv45dj$D1FjT2AFf_C-L15RjOeSEA?V8lq5UtY@lcXkhTAXdzIQ zXn;?MYe7LlZB=O<5LK7g*VnhSwDk1!_#DYi2f9(%)5S4F<9uk)$=<^TJSt+FxNdN5 za*sI>rof`(U|>?O)NrGo(|YlZ{vVFFle6@0{M&bbo&0TM< ze^1Vxv6(wt3+K< gZ9M<|{=?VuJL_w2oIBc*3JgC6Pgg&ebxsLQ09=p2F8}}l