Merge branch 'master' into 'master'
Remove hard dependency on minetest_game and add "currency" global See merge request VanessaE/currency!9
This commit is contained in:
commit
2ea826fccc
@ -1,4 +1,5 @@
|
|||||||
barter = {}
|
currency.barter = {}
|
||||||
|
barter = currency.barter -- Kept as a global variable for compatibility
|
||||||
|
|
||||||
local S = minetest.get_translator("currency")
|
local S = minetest.get_translator("currency")
|
||||||
|
|
||||||
@ -120,14 +121,14 @@ minetest.register_node("currency:barter", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.500000,0.312500,-0.500000,0.500000,0.500000,0.500000},
|
{-0.500000,0.312500,-0.500000,0.500000,0.500000,0.500000},
|
||||||
{-0.437500,-0.500000,-0.437500,-0.250000,0.500000,-0.250000},
|
{-0.437500,-0.500000,-0.437500,-0.250000,0.500000,-0.250000},
|
||||||
{-0.437500,-0.500000,0.250000,-0.250000,0.500000,0.437500},
|
{-0.437500,-0.500000,0.250000,-0.250000,0.500000,0.437500},
|
||||||
{0.250000,-0.500000,-0.437500,0.437500,0.500000,-0.250000},
|
{0.250000,-0.500000,-0.437500,0.437500,0.500000,-0.250000},
|
||||||
{0.250000,-0.500000,0.250000,0.437500,0.500000,0.447500},
|
{0.250000,-0.500000,0.250000,0.437500,0.500000,0.447500},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = currency.node_sound_wood_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", S("Barter Table"))
|
meta:set_string("infotext", S("Barter Table"))
|
||||||
|
50
crafting.lua
50
crafting.lua
@ -1,27 +1,32 @@
|
|||||||
minetest.register_craft({
|
if minetest.get_modpath("default") then
|
||||||
output = 'currency:safe',
|
minetest.register_craft({
|
||||||
recipe = {
|
output = "currency:safe",
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
recipe = {
|
||||||
{'default:steel_ingot', 'default:mese_crystal', 'default:steel_ingot'},
|
{"default:steel_ingot", "default:steel_ingot",
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
"default:steel_ingot"},
|
||||||
}
|
{"default:steel_ingot", "default:mese_crystal",
|
||||||
})
|
"default:steel_ingot"},
|
||||||
|
{"default:steel_ingot", "default:steel_ingot",
|
||||||
|
"default:steel_ingot"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'currency:shop',
|
output = "currency:shop",
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:sign_wall'},
|
{"default:sign_wall"},
|
||||||
{'default:chest_locked'},
|
{"default:chest_locked"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'currency:barter',
|
output = "currency:barter",
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:sign_wall'},
|
{"default:sign_wall"},
|
||||||
{'default:chest'},
|
{"default:chest"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
@ -166,4 +171,3 @@ minetest.register_craft({
|
|||||||
recipe = "currency:minegeld_bundle",
|
recipe = "currency:minegeld_bundle",
|
||||||
burntime = 1,
|
burntime = 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
7
init.lua
7
init.lua
@ -2,6 +2,13 @@ local modpath = minetest.get_modpath("currency")
|
|||||||
|
|
||||||
minetest.log("info", "Currency mod loading...")
|
minetest.log("info", "Currency mod loading...")
|
||||||
|
|
||||||
|
currency = {}
|
||||||
|
if minetest.global_exists("default") then
|
||||||
|
currency.node_sound_wood_defaults = default.node_sound_wood_defaults
|
||||||
|
else
|
||||||
|
currency.node_sound_wood_defaults = function() end
|
||||||
|
end
|
||||||
|
|
||||||
dofile(modpath.."/craftitems.lua")
|
dofile(modpath.."/craftitems.lua")
|
||||||
minetest.log("info", "[Currency] Craft_items Loaded!")
|
minetest.log("info", "[Currency] Craft_items Loaded!")
|
||||||
dofile(modpath.."/shop.lua")
|
dofile(modpath.."/shop.lua")
|
||||||
|
3
mod.conf
3
mod.conf
@ -1,5 +1,4 @@
|
|||||||
name = currency
|
name = currency
|
||||||
depends = default
|
optional_depends = default, loot, pipeworks
|
||||||
optional_depends = loot, pipeworks
|
|
||||||
description = Provides shops, barter tables, safes, and multiple denominations of currency, called "Minegeld".
|
description = Provides shops, barter tables, safes, and multiple denominations of currency, called "Minegeld".
|
||||||
min_minetest_version = 5.2.0
|
min_minetest_version = 5.2.0
|
||||||
|
8
safe.lua
8
safe.lua
@ -1,6 +1,6 @@
|
|||||||
local S = minetest.get_translator("currency")
|
local S = minetest.get_translator("currency")
|
||||||
|
|
||||||
function default.get_safe_formspec(pos)
|
function currency.get_safe_formspec(pos)
|
||||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||||
local formspec =
|
local formspec =
|
||||||
"size[8,9]"..
|
"size[8,9]"..
|
||||||
@ -11,6 +11,10 @@ function default.get_safe_formspec(pos)
|
|||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if minetest.global_exists("default") then
|
||||||
|
default.get_safe_formspec = currency.get_safe_formspec
|
||||||
|
end
|
||||||
|
|
||||||
local function has_safe_privilege(meta, player)
|
local function has_safe_privilege(meta, player)
|
||||||
local name = ""
|
local name = ""
|
||||||
if player then
|
if player then
|
||||||
@ -100,7 +104,7 @@ minetest.register_node("currency:safe", {
|
|||||||
minetest.show_formspec(
|
minetest.show_formspec(
|
||||||
clicker:get_player_name(),
|
clicker:get_player_name(),
|
||||||
"currency:safe",
|
"currency:safe",
|
||||||
default.get_safe_formspec(pos)
|
currency.get_safe_formspec(pos)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
45
shop.lua
45
shop.lua
@ -1,8 +1,12 @@
|
|||||||
local S = minetest.get_translator("currency")
|
local S = minetest.get_translator("currency")
|
||||||
|
|
||||||
default.shop = {}
|
currency.shop = {}
|
||||||
default.shop.current_shop = {}
|
if minetest.global_exists("default") then
|
||||||
default.shop.formspec = {
|
default.shop = currency.shop
|
||||||
|
end
|
||||||
|
|
||||||
|
currency.shop.current_shop = {}
|
||||||
|
currency.shop.formspec = {
|
||||||
customer = function(pos)
|
customer = function(pos)
|
||||||
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
||||||
local formspec = "size[8,9.5]"..
|
local formspec = "size[8,9.5]"..
|
||||||
@ -37,7 +41,7 @@ default.shop.formspec = {
|
|||||||
|
|
||||||
local have_pipeworks = minetest.global_exists("pipeworks")
|
local have_pipeworks = minetest.global_exists("pipeworks")
|
||||||
|
|
||||||
default.shop.check_privilege = function(listname,playername,meta)
|
currency.shop.check_privilege = function(listname,playername,meta)
|
||||||
--[[if listname == "pl1" then
|
--[[if listname == "pl1" then
|
||||||
if playername ~= meta:get_string("pl1") then
|
if playername ~= meta:get_string("pl1") then
|
||||||
return false
|
return false
|
||||||
@ -56,7 +60,7 @@ default.shop.check_privilege = function(listname,playername,meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
default.shop.give_inventory = function(inv,list,playername)
|
currency.shop.give_inventory = function(inv,list,playername)
|
||||||
player = minetest.get_player_by_name(playername)
|
player = minetest.get_player_by_name(playername)
|
||||||
if player then
|
if player then
|
||||||
for k,v in ipairs(inv:get_list(list)) do
|
for k,v in ipairs(inv:get_list(list)) do
|
||||||
@ -66,18 +70,18 @@ default.shop.give_inventory = function(inv,list,playername)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
default.shop.cancel = function(meta)
|
currency.shop.cancel = function(meta)
|
||||||
--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1"))
|
--[[currency.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1"))
|
||||||
default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2"))
|
currency.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2"))
|
||||||
meta:set_string("pl1","")
|
meta:set_string("pl1","")
|
||||||
meta:set_string("pl2","")
|
meta:set_string("pl2","")
|
||||||
meta:set_int("pl1step",0)
|
meta:set_int("pl1step",0)
|
||||||
meta:set_int("pl2step",0)]]
|
meta:set_int("pl2step",0)]]
|
||||||
end
|
end
|
||||||
|
|
||||||
default.shop.exchange = function(meta)
|
currency.shop.exchange = function(meta)
|
||||||
--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2"))
|
--[[currency.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2"))
|
||||||
default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1"))
|
currency.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1"))
|
||||||
meta:set_string("pl1","")
|
meta:set_string("pl1","")
|
||||||
meta:set_string("pl2","")
|
meta:set_string("pl2","")
|
||||||
meta:set_int("pl1step",0)
|
meta:set_int("pl1step",0)
|
||||||
@ -165,7 +169,7 @@ minetest.register_node("currency:shop", {
|
|||||||
"shop_front.png"},
|
"shop_front.png"},
|
||||||
inventory_image = "shop_front.png",
|
inventory_image = "shop_front.png",
|
||||||
groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
|
groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = currency.node_sound_wood_defaults(),
|
||||||
after_place_node = function(pos, placer, itemstack)
|
after_place_node = function(pos, placer, itemstack)
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -205,12 +209,12 @@ minetest.register_node("currency:shop", {
|
|||||||
on_rightclick = function(pos, node, clicker, itemstack)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
clicker:get_inventory():set_size("customer_gives", 3*2)
|
clicker:get_inventory():set_size("customer_gives", 3*2)
|
||||||
clicker:get_inventory():set_size("customer_gets", 3*2)
|
clicker:get_inventory():set_size("customer_gets", 3*2)
|
||||||
default.shop.current_shop[clicker:get_player_name()] = pos
|
currency.shop.current_shop[clicker:get_player_name()] = pos
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then
|
if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then
|
||||||
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.owner(pos))
|
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.owner(pos))
|
||||||
else
|
else
|
||||||
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.customer(pos))
|
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.customer(pos))
|
||||||
end
|
end
|
||||||
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)
|
||||||
@ -249,7 +253,7 @@ minetest.register_node("currency:shop_empty", {
|
|||||||
"shop_front_empty.png"},
|
"shop_front_empty.png"},
|
||||||
drop = "currency:shop",
|
drop = "currency:shop",
|
||||||
groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
|
groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = currency.node_sound_wood_defaults(),
|
||||||
after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig),
|
after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig),
|
||||||
tube = {
|
tube = {
|
||||||
insert_object = function(pos, node, stack, direction)
|
insert_object = function(pos, node, stack, direction)
|
||||||
@ -272,12 +276,12 @@ minetest.register_node("currency:shop_empty", {
|
|||||||
on_rightclick = function(pos, node, clicker, itemstack)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
clicker:get_inventory():set_size("customer_gives", 3*2)
|
clicker:get_inventory():set_size("customer_gives", 3*2)
|
||||||
clicker:get_inventory():set_size("customer_gets", 3*2)
|
clicker:get_inventory():set_size("customer_gets", 3*2)
|
||||||
default.shop.current_shop[clicker:get_player_name()] = pos
|
currency.shop.current_shop[clicker:get_player_name()] = pos
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then
|
if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then
|
||||||
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.owner(pos))
|
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.owner(pos))
|
||||||
else
|
else
|
||||||
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.customer(pos))
|
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.customer(pos))
|
||||||
end
|
end
|
||||||
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)
|
||||||
@ -308,7 +312,7 @@ minetest.register_node("currency:shop_empty", {
|
|||||||
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
if formname == "currency:shop_formspec" and fields.exchange ~= nil and fields.exchange ~= "" then
|
if formname == "currency:shop_formspec" and fields.exchange ~= nil and fields.exchange ~= "" then
|
||||||
local name = sender:get_player_name()
|
local name = sender:get_player_name()
|
||||||
local pos = default.shop.current_shop[name]
|
local pos = currency.shop.current_shop[name]
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if meta:get_string("owner") == name then
|
if meta:get_string("owner") == name then
|
||||||
minetest.chat_send_player(name, S("This is your own shop, you can't exchange to yourself!"))
|
minetest.chat_send_player(name, S("This is your own shop, you can't exchange to yourself!"))
|
||||||
@ -362,4 +366,3 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user