forked from mtcontrib/bitchange
Cleanups, new node
Added tool repair node to .. repair tools with money
This commit is contained in:
parent
73161dbd9f
commit
1a68fcbdc8
@ -43,11 +43,6 @@ 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
|
||||
@ -196,21 +191,21 @@ minetest.register_node("bitchange:bank", {
|
||||
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
|
||||
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 (has_bank_privilege(meta, player)) then
|
||||
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 (has_bank_privilege(meta, player)) then
|
||||
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
|
@ -43,11 +43,6 @@ 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
|
||||
@ -178,21 +173,21 @@ minetest.register_node("bitchange:bank", {
|
||||
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
|
||||
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 (has_bank_privilege(meta, player)) then
|
||||
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 (has_bank_privilege(meta, player)) then
|
||||
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
|
@ -43,11 +43,6 @@ 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
|
||||
@ -178,21 +173,21 @@ minetest.register_node("bitchange:bank", {
|
||||
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
|
||||
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 (has_bank_privilege(meta, player)) then
|
||||
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 (has_bank_privilege(meta, player)) then
|
||||
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
|
@ -6,6 +6,7 @@ bitchange_initial_give = 2
|
||||
bitchange_enable_exchangeshop = true
|
||||
bitchange_enable_moneychanger = true
|
||||
bitchange_enable_warehouse = false
|
||||
bitchange_enable_toolrepair = 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
|
||||
|
10
init.lua
10
init.lua
@ -15,6 +15,9 @@ end
|
||||
if(bitchange_enable_warehouse) then
|
||||
dofile(mod_path.."/warehouse.lua")
|
||||
end
|
||||
if(bitchange_enable_toolrepair) then
|
||||
dofile(mod_path.."/toolrepair.lua")
|
||||
end
|
||||
if(bitchange_enable_bank) then
|
||||
local loaded_bank = ""
|
||||
if(minetest.get_modpath("money") ~= nil) then
|
||||
@ -38,4 +41,11 @@ if(not minetest.setting_getbool("creative_mode") and bitchange_initial_give > 0)
|
||||
player:get_inventory():add_item("main", "bitchange:mineninth "..bitchange_initial_give)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Privs
|
||||
minetest.register_privilege("bitchange", "Can access to owned nodes of the bitchange mod")
|
||||
function bitchange_has_access(owner, player_name)
|
||||
return (player_name == owner or minetest.get_player_privs(player_name).server or minetest.get_player_privs(player_name).bitchange)
|
||||
end
|
||||
|
||||
print("[BitChange] Loaded.")
|
@ -120,9 +120,8 @@ moneychanger.update_fields = function(pos, listname, index, stack, take)
|
||||
end
|
||||
if(canMove) then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
minetest.register_node("bitchange:moneychanger", {
|
||||
@ -151,36 +150,32 @@ minetest.register_node("bitchange:moneychanger", {
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if(player:get_player_name() ~= meta:get_string("owner")) then
|
||||
if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return 0
|
||||
end
|
||||
if(listname == "source") then
|
||||
local stack_name = stack:get_name()
|
||||
if(stack_name == "bitchange:mineninth" or stack_name == "bitchange:minecoin" or stack_name == "bitchange:minecoinblock") then
|
||||
return moneychanger.update_fields(pos, listname, index, stack, false)
|
||||
else
|
||||
return 0
|
||||
end
|
||||
else
|
||||
return 0
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if(player:get_player_name() == meta:get_string("owner") or minetest.get_player_privs(name)["server"]) then
|
||||
if(bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return moneychanger.update_fields(pos, listname, index, stack, true)
|
||||
else
|
||||
return 0
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if(player:get_player_name() ~= meta:get_string("owner") and not minetest.get_player_privs(name)["server"]) then
|
||||
return 0
|
||||
end
|
||||
if(bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return inv:is_empty("source") and inv:is_empty("output") and inv:is_empty("rest")
|
||||
end
|
||||
return 0
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
18
shop.lua
18
shop.lua
@ -5,11 +5,6 @@
|
||||
|
||||
local exchange_shop = {}
|
||||
|
||||
local function has_exchange_shop_privilege(meta, player)
|
||||
local player_name = player:get_player_name()
|
||||
return ((player_name == meta:get_string("owner")) or minetest.get_player_privs(player_name).server)
|
||||
end
|
||||
|
||||
local function get_exchange_shop_formspec(number,pos,title)
|
||||
local formspec = ""
|
||||
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||
@ -94,6 +89,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||
local pos = exchange_shop[player_name]
|
||||
local meta = minetest.get_meta(pos)
|
||||
local title = meta:get_string("title") or ""
|
||||
local shop_owner = meta:get_string("owner")
|
||||
|
||||
if(fields.exchange) then
|
||||
local player_inv = sender:get_inventory()
|
||||
@ -209,11 +205,11 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||
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
|
||||
elseif(fields.vstock and bitchange_has_access(shop_owner, player_name) 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
|
||||
elseif(fields.vcustm and bitchange_has_access(shop_owner, player_name) 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
|
||||
elseif(fields.quit and bitchange_has_access(shop_owner, player_name)) then
|
||||
if(fields.title and title ~= fields.title) then
|
||||
if(fields.title ~= "") then
|
||||
meta:set_string("infotext", "Exchange shop \""..fields.title.."\" (owned by "..
|
||||
@ -284,21 +280,21 @@ minetest.register_node("bitchange:shop", {
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if (not has_exchange_shop_privilege(meta, player)) then
|
||||
if (not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if (has_exchange_shop_privilege(meta, player) and (listname ~= "cust_ej") and (listname ~= "custm_ej")) then
|
||||
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name()) and (listname ~= "cust_ej") and (listname ~= "custm_ej")) then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if (has_exchange_shop_privilege(meta, player) or (listname == "cust_ej")) then
|
||||
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name()) or (listname == "cust_ej")) then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
|
BIN
textures/bitchange_toolrepair_bottom.png
Normal file
BIN
textures/bitchange_toolrepair_bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
textures/bitchange_toolrepair_side.png
Normal file
BIN
textures/bitchange_toolrepair_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 980 B |
BIN
textures/bitchange_toolrepair_top.png
Normal file
BIN
textures/bitchange_toolrepair_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 928 B |
137
toolrepair.lua
Normal file
137
toolrepair.lua
Normal file
@ -0,0 +1,137 @@
|
||||
--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]"..
|
||||
"list[current_name;src;3.5,1;1,1;]"..
|
||||
"label[3.4,2;\\["..text2.."\\]]"..
|
||||
"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:minecoin") 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 = 8,
|
||||
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()
|
||||
|
||||
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:minecoin") then
|
||||
set_infotext(meta, 1)
|
||||
return
|
||||
end
|
||||
|
||||
if(wear - 2000 < 0) then
|
||||
src:add_wear(-2000 + wear)
|
||||
else
|
||||
src:add_wear(-2000)
|
||||
end
|
||||
inv:set_stack("src", 1, src)
|
||||
set_infotext(meta, 2)
|
||||
inv:remove_item("fuel", "bitchange:minecoin 1")
|
||||
end
|
||||
})
|
@ -1,3 +1,11 @@
|
||||
======>- Version 1.6.8 -<======
|
||||
- tool repair node
|
||||
- privilege: bitchange
|
||||
- more cleanups
|
||||
|
||||
======>- Version 1.6.7 -<======
|
||||
- cleanups, adjustments
|
||||
|
||||
======>- Version 1.6.6 -<======
|
||||
- default config 'config.default.txt'
|
||||
- generation adjustments (coins are alot cheaper now)
|
||||
|
@ -2,10 +2,6 @@
|
||||
-- Something like a chest...experimental, have fun!
|
||||
--License: WTFPL
|
||||
|
||||
function has_locked_chest_privilege(meta, player)
|
||||
return (player:get_player_name() == meta:get_string("owner"))
|
||||
end
|
||||
|
||||
function get_warehouse_tube_config(mode)
|
||||
if(bitchange_warehouse_pipeworks) then
|
||||
if(mode == 1) then
|
||||
@ -94,21 +90,21 @@ minetest.register_node("bitchange:warehouse", {
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
if(not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
|
Loading…
Reference in New Issue
Block a user