1
0
mirror of https://github.com/SmallJoker/bitchange.git synced 2025-06-28 22:46:01 +02:00

42 Commits

Author SHA1 Message Date
849f8f8cd7 Delete depends.txt, update mod.conf 2022-07-08 18:57:14 +02:00
f8441dad81 Merge remote-tracking branch 'upstream/master' 2021-03-12 12:14:32 +01:00
733ce6f46a Fix deprecated call to Minetest settings (#15) 2021-03-04 08:17:30 +01:00
7cf127aa9d Merge branch 'github' 2021-03-03 22:57:00 +01:00
498dadfee6 Fix deprecated call to Minetest settings 2021-03-03 22:56:10 +01:00
07af87559e ajoute conversion monnaie bitchange <-> maptools 2019-12-30 16:44:19 +01:00
98a2dc8572 Refactoring, enable tin by default, remove ore generation (#14)
Remove Ore Generation
Disable Crafting Currency By Default
Make All Currency Smelted From Ore
Enable Tin Smelting By Default
2019-01-02 23:56:46 +01:00
b39a6017d4 Add backwards-compatiblity, tidy config.default.txt 2018-12-29 14:47:17 +01:00
99dbde247e Add default tin conversion (#13) 2018-12-29 14:37:53 +01:00
e7798768d4 Restrict title edit access to owner, fixes #11 2017-12-04 20:33:36 +01:00
7aff3b50bb Remove bank, clean up dependencies 2017-11-25 12:35:32 +01:00
3f029c82d6 No ore generation by default, remove Coin base
Shop: limit title length to 80 characters
Do not list ore nodes in creative inventory
10 MineNinths for a new player on start (previously 2)
Replace bitchange privilege with protection_bypass
Revert to classic 16px shop texture & run OptiPNG
2017-11-25 11:46:32 +01:00
0fbda6a40f Shop: Improve code readability
Make the entire code portable to other, custom mods
Correct register_on_dieplayer to register_on_leaveplayer
Do not close shop formspec when setting the title using enter
2017-08-07 16:57:45 +02:00
bf68097a75 Shop: Avoid unhandled leftovers from ItemStack:add_item
Pre-fix if https://github.com/minetest/minetest/pull/5774 gets merged somewhen
Thanks to @nybble41 for providing this code
2017-06-03 19:35:18 +02:00
Foz
3814d994db Fix handling of empty stacks and item accumulation
Fixes SmallJoker/bitchange#9
2017-02-17 19:17:10 +01:00
Foz
6f9cc0081a Prevent shops from trading tools deceptively
This limits the tools a shop will accept or give to those whose wear is less
than or equal to the tool shown in the Owner needs or Owner gives lists. This
protects both owners and customers from unfair trades. Owners are protected
from receiving worn out tools when a new tool is placed in the needs list.
Customers are protected from receiving worn out tools when a new one is placed
in the give list.
2017-01-31 19:51:35 +01:00
70f31b7631 Shop: Clean up code, fix item repair cheat 2016-12-09 19:20:19 +01:00
b52f70c09d "deprecated" Warning removal and code cleanup
substitute deprecated tile_images and height_min/max with the new ones
2016-11-09 19:14:11 +01:00
b49ba5dc14 Shop: Allow server admins to open the owner formspec of shops
Clean up the position entry on leave
Add wrench support
2016-10-16 09:17:33 +02:00
498d97a8bc shop: Add listring 2016-04-18 20:37:50 +02:00
db64a14cdc Quick fix
To stop crashing with nil instead of pos.
2016-04-02 12:24:18 +01:00
e7425e19e9 Extend README.md, rename to README.txt 2015-10-09 09:11:20 +02:00
307f7fb823 Add noise and sharpen the textures 2015-10-09 08:56:22 +02:00
3befc29ac8 Typo in init.lua line 61 2015-05-16 10:00:46 +02:00
e28d5e58bd Kill them all 2015-04-16 15:09:16 +02:00
84f1b0f330 💥 Break old settings
- Rename bitchange_ -> bitchange.
- Better coding style
- Run OptiPNG
2015-04-16 15:06:22 +02:00
20fcf0a0a0 HAAAANDS 2014-11-29 18:44:38 +01:00
5761f2d9fe Delete 16px textures, clean up bank and variable names 2014-10-01 13:41:22 +02:00
45931b8718 It needed an update - there's it. 2014-05-07 16:28:01 +02:00
808593bfba Formspec cleanup 2014-04-10 11:22:43 +02:00
32011311b6 Do not save 2014-04-08 15:12:32 +02:00
eec023f449 Donation box, a better saving, serval updates 2014-02-23 17:33:46 +01:00
f846f5624c Add new configuration loading 2014-02-07 13:35:02 +01:00
525a89c653 Little update 2014-02-07 13:33:59 +01:00
1adddcd492 Freeminer support 2014-02-06 20:42:01 +01:00
fecfaaf975 Updatez 2014-02-06 20:40:41 +01:00
2d36903ffe Small bugfix 2014-01-23 20:51:45 +01:00
c0f291ecf3 Money converting updates 2014-01-23 18:59:45 +01:00
78f27c4bd9 Cheaper repair 2014-01-19 09:54:44 +01:00
422d29d765 How to use tool repair 2014-01-18 18:33:58 +01:00
acff3661d3 Changes etc 2014-01-18 15:39:01 +01:00
1a68fcbdc8 Cleanups, new node
Added tool repair node to .. repair tools with money
2014-01-18 11:40:06 +01:00
57 changed files with 850 additions and 1323 deletions

View File

@ -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

View File

@ -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
View 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.

View File

@ -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,
})

View File

@ -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,
})

View File

@ -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,
})

View File

@ -1,27 +1,26 @@
-- General configuration - BitChange -- General configuration for the BitChange mod
-- Created by Krock -- 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 -- Enable/Disable whole nodes
bitchange_enable_exchangeshop = true bitchange.enable_exchangeshop = true
bitchange_enable_moneychanger = true bitchange.enable_moneychanger = true
bitchange_enable_warehouse = false bitchange.enable_warehouse = false
bitchange.enable_toolrepair = true
bitchange.enable_donationbox = true
-- Set this variable to false if you have a supported currency enabled -- Enable/Disable Converting Currency Via Crafting
-- and if you want to disable the exchanging/converting point - the bank bitchange.craft_convert_currency = false
-- Supported: money (by kotolegokot), money2 (by Bad Command), currency (by Dan Duncombe)
bitchange_enable_bank = true
-- Tin converting/generation -- Converting other ores to MineCoins
bitchange_use_moreores_tin = false -- Activate support -- Tin default
bitchange_need_generate_tin = false -- Generate if needed -- Zinc technic_worldgen
-- Zinc converting/generation -- Quartz quartz
bitchange_use_technic_zinc = false -- Activate support bitchange.use_technic_zinc = false
bitchange_need_generate_zinc = false -- Generate if needed bitchange.use_quartz = false
bitchange.use_default_tin = true
-- Pipeworks support -- Pipeworks support
bitchange_exchangeshop_pipeworks = false bitchange.exchangeshop_pipeworks = false
bitchange_warehouse_pipeworks = false bitchange.warehouse_pipeworks = false
-- Advanced generation settings
-- Change in 'minecoins.lua', starting at line 101

View File

@ -1,7 +0,0 @@
default
moreores?
technic?
pipeworks?
money?
money2?
currency?

78
donationbox.lua Normal file
View 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"}
}
})

View File

@ -1,41 +1,57 @@
--Created by Krock for the BitChange mod bitchange = {}
local mod_path = minetest.get_modpath("bitchange") bitchange.mod_path = minetest.get_modpath("bitchange")
local world_path = minetest.get_worldpath()
dofile(mod_path.."/config.txt") dofile(bitchange.mod_path.."/config.default.txt")
dofile(mod_path.."/minecoins.lua") -- Copied from moretrees mod
if(bitchange_use_moreores_tin or bitchange_use_technic_zinc or bitchange_use_gold) then if not io.open(world_path.."/bitchange_config.txt", "r") then
dofile(mod_path.."/moreores.lua") io.input(bitchange.mod_path.."/config.default.txt")
end io.output(world_path.."/bitchange_config.txt")
if(bitchange_enable_exchangeshop) then
dofile(mod_path.."/shop.lua") while true do
end local block = io.read(256) -- 256B at once
if(bitchange_enable_moneychanger) then if not block then
dofile(mod_path.."/moneychanger.lua") io.close()
end break
if(bitchange_enable_warehouse) then end
dofile(mod_path.."/warehouse.lua") io.write(block)
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)
end end
else
dofile(world_path.."/bitchange_config.txt")
end 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 -- Giving initial money
minetest.register_on_newplayer(function(player) 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)
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.")

View File

@ -1,133 +1,96 @@
--bitcoins by MilesDyson@DistroGeeks.com
--Modified by Krock
--License: WTFPL
-- Node definitions -- 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", { minetest.register_node("bitchange:minecoinblock", {
description = "MineCoin Block", description = "MineCoin Block",
tile_images = { "bitchange_minecoinblock.png" }, tiles = { "bitchange_minecoinblock.png" },
is_ground_content = true,
groups = {cracky=2}, groups = {cracky=2},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
stack_max = 30000, stack_max = 30000,
}) })
minetest.register_craftitem("bitchange:minecoin", { minetest.register_craftitem("bitchange:minecoin", {
description = "MineCoin", description = "MineCoin",
inventory_image = "bitchange_minecoin.png", inventory_image = "bitchange_minecoin.png",
stack_max = 30000, stack_max = 30000,
}) })
minetest.register_craftitem("bitchange:mineninth", { minetest.register_craftitem("bitchange:mineninth", {
description = "MineNinth", description = "MineNinth",
inventory_image = "bitchange_mineninth.png", inventory_image = "bitchange_mineninth.png",
stack_max = 30000, stack_max = 30000,
})
minetest.register_craftitem("bitchange:coinbase", {
description = "Coin base",
inventory_image = "bitchange_coinbase.png",
}) })
-- Crafting -- Crafting
minetest.register_craft({ if bitchange.craft_convert_currency and minetest.get_modpath("maptools") then
output = 'bitchange:minecoinblock', minetest.register_craft(
recipe = { {
{'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'}, output = "bitchange:mineninth",
{'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'}, recipe = {
{'bitchange:minecoin', 'bitchange:minecoin', 'bitchange:minecoin'}, {"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({ minetest.register_craft(
output = 'bitchange:minecoin 9', {
recipe = { output = "maptools:gold_coin 9",
{'bitchange:minecoinblock'}, recipe = {{"bitchange:mineninth"}}
} })
})
minetest.register_craft({ minetest.register_craft(
output = 'bitchange:minecoin', {
recipe = { output = "maptools:gold_coin",
{'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'}, recipe = {
{'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'}, {"maptools:silver_coin", "maptools:silver_coin", "maptools:silver_coin"},
{'bitchange:mineninth', 'bitchange:mineninth', 'bitchange:mineninth'}, {"maptools:silver_coin", "maptools:silver_coin", "maptools:silver_coin"},
} {"maptools:silver_coin", "maptools:silver_coin", "maptools:silver_coin"},
}) }
})
minetest.register_craft({ minetest.register_craft(
output = 'bitchange:mineninth 9', {
recipe = { output = "maptools:silver_coin 9",
{'bitchange:minecoin'}, 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 -- Cooking
minetest.register_craft({ minetest.register_craft({
type = 'cooking', type = "cooking",
recipe = "bitchange:coinbase",
output = "bitchange:mineninth",
})
minetest.register_craft({
type = 'cooking',
recipe = "default:goldblock", recipe = "default:goldblock",
output = "bitchange:minecoinblock 2", output = "bitchange:minecoinblock 2",
}) })
minetest.register_craft({ minetest.register_craft({
type = 'cooking', type = "cooking",
recipe = "bitchange:minecoinblock", recipe = "bitchange:minecoinblock",
output = "default:gold_ingot 4", output = "default:gold_ingot 4",
}) })
-- Generation -- Legacy
minetest.register_ore({ if bitchange.enable_generation then
ore_type = "scatter", minetest.log("warning", "[bitchange] Ores will not be generated any more. Remove the setting " ..
ore = "bitchange:minecoin_in_ground", "'enable_generation' from your bitchange configuration to suppress this warning.")
wherein = "default:stone", end
clust_scarcity = 15*15*15,
clust_num_ores = 3,
clust_size = 7,
height_max = -512,
height_min = -18000,
})
minetest.register_ore({ minetest.register_alias("bitchange:minecoin_in_ground", "default:stone_with_gold")
ore_type = "scatter", minetest.register_alias("bitchange:mineninth_in_ground", "default:stone_with_tin")
ore = "bitchange:mineninth_in_ground",
wherein = "default:stone",
clust_scarcity = 12*12*12,
clust_num_ores = 5,
clust_size = 8,
height_max = -256,
height_min = -511,
})
minetest.register_ore({ minetest.register_alias("bitchange:coinbase", "bitchange:mineninth")
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,
})

5
mod.conf Normal file
View 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

View File

@ -22,107 +22,88 @@ moneychanger.update_fields = function(pos, listname, index, stack, take)
local stack_src = inv:get_stack("source", 1) local stack_src = inv:get_stack("source", 1)
local stack_src_name = stack_src:get_name() local stack_src_name = stack_src:get_name()
local stack_real_count = 0 local stack_real_count = 0
local canMove = false
if(take) then if take then
stack_real_count = stack_inv:get_count() - stack:get_count() stack_real_count = stack_inv:get_count() - stack:get_count()
else else
if(stack_inv:get_name() ~= "") then if stack_inv:get_name() ~= "" then
stack_real_count = stack_inv:get_count() + stack:get_count() stack_real_count = stack_inv:get_count() + stack:get_count()
else else
stack_real_count = stack:get_count() stack_real_count = stack:get_count()
end end
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", { "", "" }) inv:set_list("output", { "", "" })
if(stack_real_count > 0) then if stack_real_count > 0 then
if(stack_name == "bitchange:minecoinblock") then if stack_name == "bitchange:minecoinblock" then
inv:set_list("output", { "bitchange:minecoin "..(stack_real_count*9), "" }) 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) }) inv:set_list("output", { "bitchange:mineninth "..math.min(stack_real_count*9, 30000), "bitchange:minecoinblock "..math.floor(stack_real_count/9) })
else else
inv:set_list("output", { "bitchange:minecoin "..math.min(math.floor(stack_real_count/9), 30000), "" }) inv:set_list("output", { "bitchange:minecoin "..math.min(math.floor(stack_real_count/9), 30000), "" })
end end
canMove = true return stack:get_count()
elseif(stack_real_count == 0 and stack_src:get_count() > 0) then elseif stack_real_count == 0 and stack_src:get_count() > 0 then
canMove = true return stack:get_count()
end end
elseif(listname == "output" and stack_rest:get_count() == 0) then elseif listname == "output" and stack_rest:get_count() == 0 then
if(stack_src:get_count() < 1) then if stack_src:get_count() < 1 then
if(stack:get_count() > 0) then if stack:get_count() > 0 then
canMove = true return stack:get_count()
end end
inv:set_list("source", { "" }) inv:set_list("source", { "" })
else else
if(stack_src_name ~= "") then if stack_src_name ~= "" then
if(stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin") then if stack_name == "bitchange:minecoinblock" and stack_src_name == "bitchange:minecoin" then
local amount_left = (stack_src:get_count() - (stack:get_count()*9)) 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 }) inv:set_list("source", { stack_src_name.." "..amount_left })
else else
inv:set_list("source", { "" }) inv:set_list("source", { "" })
end end
if(index == 1) then if index == 1 then
inv:set_stack("output", 2, "") inv:set_stack("output", 2, "")
else else
inv:set_stack("output", 1, "") inv:set_stack("output", 1, "")
end end
canMove = true return stack:get_count()
elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:mineninth") then elseif stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:mineninth" then
local amount_left = (stack_src:get_count() - (stack:get_count()*9)) 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 }) inv:set_list("source", { stack_src_name.." "..amount_left })
else else
inv:set_list("source", { "" }) inv:set_list("source", { "" })
end end
canMove = true return stack:get_count()
elseif(stack_name == "bitchange:minecoin" and stack_src_name == "bitchange:minecoinblock") then 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 amount_left = stack_src:get_count() - (stack:get_count()/9)
local rest_count = (amount_left - math.floor(amount_left))*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) }) 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 }) inv:set_list("rest", { stack_name.." "..rest_count })
else else
inv:set_list("rest", { "" }) inv:set_list("rest", { "" })
end end
if(index == 1) then if index == 1 then
inv:set_stack("output", 2, "") inv:set_stack("output", 2, "")
else else
inv:set_stack("output", 1, "") inv:set_stack("output", 1, "")
end end
inv:set_stack("output", index, stack_name.." "..stack:get_count()) inv:set_stack("output", index, stack_name.." "..stack:get_count())
canMove = true return stack:get_count()
end
elseif(stack_name == "bitchange:mineninth" and stack_src_name == "bitchange:minecoin") then
local amount_left = stack_src:get_count() - (stack:get_count()/9)
local rest_count = (amount_left - math.floor(amount_left))*9
if(amount_left > -1) then
inv:set_list("source", { stack_src_name.." "..math.floor(amount_left) })
if(rest_count > 0) then
inv:set_list("rest", { stack_name.." "..rest_count })
else
inv:set_list("rest", { "" })
end
if(index == 1) then
inv:set_stack("output", 2, "")
else
inv:set_stack("output", 1, "")
end
inv:set_stack("output", index, stack_name.." "..stack:get_count())
canMove = true
end end
end end
end end
end end
elseif(listname == "rest") then
canMove = true
end
if(canMove) then
return stack:get_count()
else
return 0
end end
return 0
end end
minetest.register_node("bitchange:moneychanger", { minetest.register_node("bitchange:moneychanger", {
@ -151,35 +132,38 @@ minetest.register_node("bitchange:moneychanger", {
end, 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) 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 return 0
end end
if(listname == "source") then if listname == "source" then
local stack_name = stack:get_name() local stack_name = stack:get_name()
if(stack_name == "bitchange:mineninth" or stack_name == "bitchange:minecoin" or stack_name == "bitchange:minecoinblock") then local inv = meta:get_inventory()
return moneychanger.update_fields(pos, listname, index, stack, false) local inv_stack = inv:get_stack(listname, index)
else if inv_stack:get_name() ~= "" then
return 0 return 0
end end
else if stack_name == "bitchange:mineninth" or
return 0 stack_name == "bitchange:minecoin" or
stack_name == "bitchange:minecoinblock" then
return moneychanger.update_fields(pos, listname, index, stack, false)
end
end end
return 0
end, 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) 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) return moneychanger.update_fields(pos, listname, index, stack, true)
else
return 0
end end
return 0
end, end,
can_dig = function(pos, player) can_dig = function(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if(player:get_player_name() ~= meta:get_string("owner") and not minetest.get_player_privs(name)["server"]) then if bitchange.has_access(meta:get_string("owner"), player:get_player_name()) then
return 0 return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest")
end end
return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest") return 0
end end
}) })
@ -187,7 +171,7 @@ minetest.register_craft({
output = 'bitchange:moneychanger', output = 'bitchange:moneychanger',
recipe = { recipe = {
{'default:stone', 'bitchange:mineninth', 'default:stone'}, {'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'} {'default:stone', 'default:stone', 'default:stone'}
} }
}) })

View File

@ -1,126 +1,22 @@
--Created by Krock -- Conversion of other ores to money
--License: WTFPL
if (bitchange_use_moreores_tin) then if bitchange.use_technic_zinc and minetest.get_modpath("technic_worldgen") 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
minetest.register_craft({ minetest.register_craft({
output = "bitchange:coinbase 18", type = "cooking",
recipe = { output = "bitchange:mineninth 8",
{"moreores:tin_block", "default:pick_diamond"}, recipe = "technic:zinc_block",
{"moreores:tin_block", ""}
},
replacements = { {"default:pick_diamond", "default:pick_diamond"} },
}) })
end end
if (bitchange_use_technic_zinc) then if bitchange.use_moreores_tin then
if (bitchange_need_generate_zinc and not minetest.get_modpath("technic_worldgen")) then bitchange.use_default_tin = true
minetest.register_node(":technic:mineral_zinc", { minetest.log("warning", "[bitchange] Loaded deprecated setting 'use_default_tin'")
description = "Zinc Ore", end
tile_images = { "default_stone.png^technic_mineral_zinc.png" },
is_ground_content = true, if bitchange.use_default_tin then
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
drop = 'craft "technic:zinc_lump" 1',
})
minetest.register_node(":technic:zinc_block", {
description = "Zinc Block",
tiles = { "technic_zinc_block.png" },
is_ground_content = true,
groups = {cracky=1, level=2},
sounds = default.node_sound_stone_defaults()
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_zinc",
wherein = "default:stone",
clust_scarcity = 9*9*9,
clust_num_ores = 4,
clust_size = 3,
height_min = -31000,
height_max = 2,
})
minetest.register_craftitem(":technic:zinc_lump", {
description = "Zinc Lump",
inventory_image = "technic_zinc_lump.png",
})
minetest.register_craftitem(":technic:zinc_ingot", {
description = "Zinc Ingot",
inventory_image = "technic_zinc_ingot.png",
})
minetest.register_craft({
output = "technic:zinc_block",
recipe = {
{"technic:zinc_ingot", "technic:zinc_ingot", "technic:zinc_ingot"},
{"technic:zinc_ingot", "technic:zinc_ingot", "technic:zinc_ingot"},
{"technic:zinc_ingot", "technic:zinc_ingot", "technic:zinc_ingot"},
}
})
minetest.register_craft({
output = "technic:zinc_block 9",
recipe = { { "technic:zinc_block" } }
})
minetest.register_craft({
type = 'cooking',
recipe = "technic:zinc_lump",
output = "technic:zinc_ingot",
})
end
minetest.register_craft({ minetest.register_craft({
output = "bitchange:coinbase 8", type = "cooking",
recipe = { output = "bitchange:mineninth 18",
{"technic:zinc_block", "default:pick_diamond"}, recipe = "default:tinblock"
{"technic:zinc_block", ""}
},
replacements = { {"default:pick_diamond", "default:pick_diamond"} },
}) })
end end

610
shop.lua
View File

@ -1,241 +1,374 @@
--Created by Krock for the BitChange mod --[[
--Parts of codes, images and ideas from Dan Duncombe's exchange shop Exchange Shop [bitchange]
-- https://forum.minetest.net/viewtopic.php?id=7002
--License: WTFPL 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 exchange_shop = {}
local function has_exchange_shop_privilege(meta, player) -- Tool wear aware replacement for contains_item.
local player_name = player:get_player_name() local function list_contains_item(inv, listname, stack)
return ((player_name == meta:get_string("owner")) or minetest.get_player_privs(player_name).server) 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 end
local function get_exchange_shop_formspec(number,pos,title) -- Tool wear aware replacement for remove_item.
local formspec = "" local function list_remove_item(inv, listname, stack)
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z local wanted = stack:get_count()
if(number == 1) then if wanted == 0 then
-- customer return stack
formspec = ("size[8,9;]"..
"label[0,0;Exchange shop]"..
"label[1,0.5;Owner needs:]"..
"list["..name..";cust_ow;1,1;2,2;]"..
"button[3,2.5;2,1;exchange;Exchange]"..
"label[5,0.5;Owner gives:]"..
"list["..name..";cust_og;5,1;2,2;]"..
"label[1,3.5;Ejected items:]"..
"list["..name..";cust_ej;3,3.5;4,1;]"..
"list[current_player;main;0,5;8,4;]")
elseif(number == 2 or number == 3) then
-- owner
formspec = ("size[11,10;]"..
"label[0,0;Exchange shop]"..
"field[2.5,0.5;3,0.2;title;;"..title.."]"..
"label[0,0.7;You need:]"..
"list["..name..";cust_ow;0,1.2;2,2;]"..
"label[3,0.7;You give:]"..
"list["..name..";cust_og;3,1.2;2,2;]"..
"label[1,3.5;Ejected items:]"..
"list["..name..";custm_ej;0,4;4,1;]"..
"label[6,0;You are viewing:]")
if(number == 2) then
formspec = (formspec.."button[8.5,0;2.5,1;vstock;Customers stock]"..
"list["..name..";custm;6,1;5,4;]")
else
formspec = (formspec.."button[8.5,0;2.5,1;vcustm;Your stock]"..
"list["..name..";stock;6,1;5,4;]")
end
formspec = (formspec..
"label[1,5;Use (E) + (Right click) for customer interface]"..
"list[current_player;main;1,6;8,4;]")
end 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 end
local function get_exchange_shop_tube_config(mode) local function get_exchange_shop_tube_config(mode)
if(bitchange_exchangeshop_pipeworks) then if mode == "groups" then
if(mode == 1) then if bitchange.exchangeshop_pipeworks then
return {choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1} return {choppy=2, oddly_breakable_by_hand=2,
else 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 { return {
insert_object = function(pos, node, stack, direction) insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:add_item("stock",stack) return inv:add_item("stock", stack)
end, end,
can_insert = function(pos, node, stack, direction) can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:room_for_item("stock",stack) return inv:room_for_item("stock", stack)
end, end,
input_inventory="custm", input_inventory = "custm",
connect_sides = {left=1, right=1, back=1, top=1, bottom=1} connect_sides = {left=1, right=1, back=1, top=1, bottom=1}
} }
end end
else return {
if(mode == 1) then insert_object = function()
return {choppy=2,oddly_breakable_by_hand=2} return false
else end,
return { can_insert = function()
insert_object = function(pos, node, stack, direction) return false
return false end,
end, connect_sides = {}
can_insert = function(pos, node, stack, direction) }
return false
end,
connect_sides = {}
}
end
end end
end end
minetest.register_on_player_receive_fields(function(sender, formname, fields) minetest.register_on_player_receive_fields(function(sender, formname, fields)
if (formname == "bitchange:shop_formspec") then if formname ~= "bitchange:shop_formspec" then
local player_name = sender:get_player_name() return
local pos = exchange_shop[player_name] end
local meta = minetest.get_meta(pos)
local title = meta:get_string("title") or ""
if(fields.exchange) then local player_name = sender:get_player_name()
local player_inv = sender:get_inventory() local pos = exchange_shop[player_name]
local shop_inv = meta:get_inventory() if not pos then
local err_msg = "" return
local cust_ow = shop_inv:get_list("cust_ow") end
local cust_og = shop_inv:get_list("cust_og")
local cust_ow_legal = true if fields.quit then
local cust_og_legal = true exchange_shop[player_name] = nil
--?shop configured well return
for i1, item1 in pairs(cust_ow) do end
for i2, item2 in pairs(cust_ow) do local meta = minetest.get_meta(pos)
if (item1:get_name() == item2:get_name() and i1 ~= i2 and item1:get_name() ~= "") then local title = meta:get_string("title")
cust_ow_legal = false local shop_owner = meta:get_string("owner")
--break
end 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 end
if(not cust_ow_legal) then if i1 ~= i2 and name1 == item2:get_name() then
cust_ow_ok = false
break break
end end
end end
if(not cust_ow_legal) then if not cust_ow_ok then
err_msg = "The 'Owner needs' field can not contain multiple times the same items, contact the shop owner." err_msg = "The field 'Owner needs' can not contain multiple "..
end "times the same items. Please contact the shop owner."
if(err_msg == "") then --?shop configured well break
for i1, item1 in pairs(cust_og) do
for i2, item2 in pairs(cust_og) do
if (item1:get_name() == item2:get_name() and i1 ~= i2 and item1:get_name() ~= "") then
cust_og_legal = false
break
end
end
if(not cust_og_legal) then
break
end
end
if(not cust_og_legal) then
err_msg = "The 'Owner gives' field can not contain multiple times the same items, contact the shop owner."
end
end
if(err_msg == "") then --?player has space
local player_has_space = true
for i, item in pairs(cust_og) do
if (not player_inv:room_for_item("main",item)) then
player_has_space = false
break
end
end
if(not player_has_space) then
err_msg = "You do not have the space in your inventory."
end
end
if(err_msg == "") then --?player has items
local player_has_items = true
for i, item in pairs(cust_ow) do
if (not player_inv:contains_item("main",item)) then
player_has_items = false
break
end
end
if(not player_has_items) then
err_msg = "You do not have the needed items."
end
end
if(err_msg == "") then --?shop has space
local shop_has_space = true
for i, item in pairs(cust_ow) do
if (not shop_inv:room_for_item("custm",item)) then
shop_has_space = false
break
end
end
if(not shop_has_space) then
err_msg = "Exchange shop: The stock in the shop is full."
end
end
if(err_msg == "") then --?shop has items
local shop_has_items = true
for i, item in pairs(cust_og) do
if (not shop_inv:contains_item("stock",item)) then
shop_has_items = false
break
end
end
if(not shop_has_items) then
err_msg = "The shop is empty and can not give you anything."
end
end
if(err_msg == "") then --?exchange
local fully_exchanged = true
for i, item in pairs(cust_ow) do
player_inv:remove_item("main", item) --player inv. to stock else to eject fields
if (shop_inv:room_for_item("custm",item)) then
shop_inv:add_item("custm", item)
else
shop_inv:add_item("custm_ej", item)
fully_exchanged = false
end
end
for i, item in pairs(cust_og) do
shop_inv:remove_item("stock", item) --stock to player inv. else to eject fields
if (player_inv:room_for_item("main",item)) then
player_inv:add_item("main", item)
else
shop_inv:add_item("cust_ej", item)
fully_exchanged = false
end
end
if(not fully_exchanged) then
err_msg = "Fatal error! Stocks are overflowing somewhere!"
end
end
if(err_msg ~= "") then
minetest.chat_send_player(player_name, "Exchange shop: "..err_msg)
end
elseif(fields.vstock and has_exchange_shop_privilege(meta, sender) and not fields.quit) then
minetest.show_formspec(sender:get_player_name(),"bitchange:shop_formspec",get_exchange_shop_formspec(3, pos, title))
elseif(fields.vcustm and has_exchange_shop_privilege(meta, sender) and not fields.quit) then
minetest.show_formspec(sender:get_player_name(),"bitchange:shop_formspec",get_exchange_shop_formspec(2, pos, title))
elseif(fields.quit and has_exchange_shop_privilege(meta, sender)) then
if(fields.title and title ~= fields.title) then
if(fields.title ~= "") then
meta:set_string("infotext", "Exchange shop \""..fields.title.."\" (owned by "..
meta:get_string("owner")..")")
else
meta:set_string("infotext", "Exchange shop (owned by "..
meta:get_string("owner")..")")
end
meta:set_string("title", fields.title)
end end
end end
-- 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
end) end)
minetest.register_node("bitchange:shop", { minetest.register_node(":bitchange:shop", {
description = "Shop", description = "Shop",
tiles = {"bitchange_shop_top.png", "bitchange_shop_top.png", tiles = {"bitchange_shop_top.png", "bitchange_shop_top.png",
"bitchange_shop_side.png", "bitchange_shop_side.png", "bitchange_shop_side.png", "bitchange_shop_side.png",
"bitchange_shop_side.png", "bitchange_shop_front.png"}, "bitchange_shop_side.png", "bitchange_shop_front.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
groups = get_exchange_shop_tube_config(1), groups = get_exchange_shop_tube_config("groups"),
tube = get_exchange_shop_tube_config(2), tube = get_exchange_shop_tube_config("tube"),
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -259,46 +392,59 @@ minetest.register_node("bitchange:shop", {
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() 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 return true
else
minetest.chat_send_player(player:get_player_name(), "Can not dig exchange shop, one or multiple stocks are in use.")
return false
end end
minetest.chat_send_player(player:get_player_name(),
"Cannot dig exchange shop: one or multiple stocks are in use.")
return false
end, end,
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local player_name = clicker:get_player_name() local player_name = clicker:get_player_name()
local view = 0
exchange_shop[player_name] = pos local mode = "customer"
if player_name == meta:get_string("owner") then if bitchange.has_access(meta:get_string("owner"), player_name) and
if(clicker:get_player_control().aux1) then not clicker:get_player_control().aux1 then
view = 1 mode = "owner_custm"
else
view = 2
end
else
view = 1
end 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, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos) 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 return 0
end end
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos) 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() return stack:get_count()
end end
return 0 return 0
end, 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) 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() return stack:get_count()
end end
return 0 return 0
@ -306,9 +452,27 @@ minetest.register_node("bitchange:shop", {
}) })
minetest.register_craft({ minetest.register_craft({
output = 'bitchange:shop', output = "bitchange:shop",
recipe = { recipe = {
{'default:sign_wall'}, {"default:sign_wall"},
{'default:chest_locked'}, {"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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1003 B

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1006 B

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

140
toolrepair.lua Normal file
View 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
})

View File

@ -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
===============================

View File

@ -2,12 +2,8 @@
-- Something like a chest...experimental, have fun! -- Something like a chest...experimental, have fun!
--License: WTFPL --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) function get_warehouse_tube_config(mode)
if(bitchange_warehouse_pipeworks) then if(bitchange.warehouse_pipeworks) then
if(mode == 1) then if(mode == 1) then
return {cracky=1, level=2, tubedevice=1, tubedevice_receiver=1} return {cracky=1, level=2, tubedevice=1, tubedevice_receiver=1}
else else
@ -15,22 +11,22 @@ function get_warehouse_tube_config(mode)
insert_object = function(pos, node, stack, direction) insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if(inv:room_for_item("main",stack)) then if inv:room_for_item("main", stack) then
return inv:add_item("main",stack) return inv:add_item("main", stack)
else else
return inv:add_item("main2",stack) return inv:add_item("main2", stack)
end end
end, end,
can_insert = function(pos, node, stack, direction) can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if(inv:room_for_item("main",stack)) then if inv:room_for_item("main", stack) then
return true return true
else else
return inv:room_for_item("main2",stack) return inv:room_for_item("main2", stack)
end end
end, end,
input_inventory="main", input_inventory = "main",
connect_sides = {left=1, right=1, back=1, top=1, bottom=1} connect_sides = {left=1, right=1, back=1, top=1, bottom=1}
} }
end end
@ -94,28 +90,31 @@ minetest.register_node("bitchange:warehouse", {
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos) 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 return 0
end end
return count return count
end, 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) 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 return 0
end end
return stack:get_count() return stack:get_count()
end, 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) 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 return 0
end end
return stack:get_count() return stack:get_count()
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos) 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;]".. meta:set_string("formspec", "size[12,10;]"..
"label[0,0;Warehouse]".. "label[0,0;Warehouse]"..
"label[2,0;Layer:]".. "label[2,0;Layer:]"..
@ -125,7 +124,7 @@ minetest.register_node("bitchange:warehouse", {
"list[current_name;main;0,1;12,4;]".. "list[current_name;main;0,1;12,4;]"..
"list[current_player;main;2,6;8,4;]") "list[current_player;main;2,6;8,4;]")
end end
if(fields.inv_lv2) then if fields.inv_lv2 then
meta:set_string("formspec", "size[12,10;]".. meta:set_string("formspec", "size[12,10;]"..
"label[0,0;Warehouse]".. "label[0,0;Warehouse]"..
"label[2,0;Layer:]".. "label[2,0;Layer:]"..
@ -139,10 +138,10 @@ minetest.register_node("bitchange:warehouse", {
}) })
minetest.register_craft({ minetest.register_craft({
output = 'bitchange:warehouse', output = "bitchange:warehouse",
recipe = { recipe = {
{'default:chest_locked', 'bitchange:minecoinblock', 'default:chest_locked'}, {"default:chest_locked", "bitchange:minecoinblock", "default:chest_locked"},
{'default:chest_locked', 'default:mese', 'default:chest_locked'}, {"default:chest_locked", "default:mese", "default:chest_locked"},
{'default:chest_locked', 'default:chest_locked', 'default:chest_locked'} {"default:chest_locked", "default:chest_locked", "default:chest_locked"}
} }
}) })