mirror of
https://github.com/mt-mods/currency.git
synced 2024-11-22 12:23:44 +01:00
fix bad line endings (DOS -> Unix)
This commit is contained in:
parent
11643571f2
commit
cd3a41dd7d
@ -1,36 +1,36 @@
|
||||
Minegeld
|
||||
---------
|
||||
|
||||
They have no recipe.
|
||||
|
||||
In general, one Mg equals one US dollar, as of Sept. 2018.
|
||||
|
||||
A good starting amount is about 250Mg on a server
|
||||
|
||||
You currently get a basic income of 10 Minegeld per day,
|
||||
so long as you dig at least one node in that day
|
||||
and have an empty inventory slot for the money to go in.
|
||||
|
||||
Lump Conversion
|
||||
|
||||
Coal Lump ~1Mg
|
||||
Iron Lump ~4Mg
|
||||
Copper Lump ~4Mg
|
||||
Gold Lump ~5Mg
|
||||
Mese Crystal ~40Mg
|
||||
Diamond ~50Mg
|
||||
|
||||
Ingot Conversion
|
||||
|
||||
Steel Ingot ~5Mg
|
||||
Copper Ingot ~5Mg
|
||||
Gold Ingot ~6Mg
|
||||
|
||||
Block Conversion
|
||||
|
||||
Coal Block ~9Mg
|
||||
Steel Block ~45Mg
|
||||
Copper Block ~45Mg
|
||||
Gold Block ~54Mg
|
||||
Mese Block ~360Mg
|
||||
Diamond Block ~450Mg
|
||||
Minegeld
|
||||
---------
|
||||
|
||||
They have no recipe.
|
||||
|
||||
In general, one Mg equals one US dollar, as of Sept. 2018.
|
||||
|
||||
A good starting amount is about 250Mg on a server
|
||||
|
||||
You currently get a basic income of 10 Minegeld per day,
|
||||
so long as you dig at least one node in that day
|
||||
and have an empty inventory slot for the money to go in.
|
||||
|
||||
Lump Conversion
|
||||
|
||||
Coal Lump ~1Mg
|
||||
Iron Lump ~4Mg
|
||||
Copper Lump ~4Mg
|
||||
Gold Lump ~5Mg
|
||||
Mese Crystal ~40Mg
|
||||
Diamond ~50Mg
|
||||
|
||||
Ingot Conversion
|
||||
|
||||
Steel Ingot ~5Mg
|
||||
Copper Ingot ~5Mg
|
||||
Gold Ingot ~6Mg
|
||||
|
||||
Block Conversion
|
||||
|
||||
Coal Block ~9Mg
|
||||
Steel Block ~45Mg
|
||||
Copper Block ~45Mg
|
||||
Gold Block ~54Mg
|
||||
Mese Block ~360Mg
|
||||
Diamond Block ~450Mg
|
||||
|
338
barter.lua
338
barter.lua
@ -1,169 +1,169 @@
|
||||
barter = {}
|
||||
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
barter.chest = {}
|
||||
barter.chest.formspec = {
|
||||
main = "size[8,9]"..
|
||||
"list[current_name;pl1;0,0;3,4;]"..
|
||||
"list[current_name;pl2;5,0;3,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]",
|
||||
pl1 = {
|
||||
start = "button[3,1;1,1;pl1_start;" .. S("Start") .. "]",
|
||||
player = function(name) return "label[3,0;"..name.."]" end,
|
||||
accept1 = "button[3,1;1,1;pl1_accept1;" .. S("Confirm") .. "]"..
|
||||
"button[3,2;1,1;pl1_cancel;" .. S("Cancel") .. "]",
|
||||
accept2 = "button[3,1;1,1;pl1_accept2;" .. S("Exchange") .. "]"..
|
||||
"button[3,2;1,1;pl1_cancel;" .. S("Cancel") .. "]",
|
||||
},
|
||||
pl2 = {
|
||||
start = "button[4,1;1,1;pl2_start;" .. S("Start") .. "]",
|
||||
player = function(name) return "label[4,0;"..name.."]" end,
|
||||
accept1 = "button[4,1;1,1;pl2_accept1;" .. S("Confirm") .. "]"..
|
||||
"button[4,2;1,1;pl2_cancel;" .. S("Cancel") .. "]",
|
||||
accept2 = "button[4,1;1,1;pl2_accept2;" .. S("Exchange") .. "]"..
|
||||
"button[4,2;1,1;pl2_cancel;" .. S("Cancel") .. "]",
|
||||
},
|
||||
}
|
||||
|
||||
barter.chest.check_privilege = function(listname,playername,meta)
|
||||
if listname == "pl1" then
|
||||
if playername ~= meta:get_string("pl1") then
|
||||
return false
|
||||
elseif meta:get_int("pl1step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
if listname == "pl2" then
|
||||
if playername ~= meta:get_string("pl2") then
|
||||
return false
|
||||
elseif meta:get_int("pl2step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
barter.chest.update_formspec = function(meta)
|
||||
formspec = barter.chest.formspec.main
|
||||
pl_formspec = function (n)
|
||||
if meta:get_int(n.."step")==0 then
|
||||
formspec = formspec .. barter.chest.formspec[n].start
|
||||
else
|
||||
formspec = formspec .. barter.chest.formspec[n].player(meta:get_string(n))
|
||||
if meta:get_int(n.."step") == 1 then
|
||||
formspec = formspec .. barter.chest.formspec[n].accept1
|
||||
elseif meta:get_int(n.."step") == 2 then
|
||||
formspec = formspec .. barter.chest.formspec[n].accept2
|
||||
end
|
||||
end
|
||||
end
|
||||
pl_formspec("pl1") pl_formspec("pl2")
|
||||
meta:set_string("formspec",formspec)
|
||||
end
|
||||
|
||||
barter.chest.give_inventory = function(inv,list,playername)
|
||||
player = minetest.get_player_by_name(playername)
|
||||
if player then
|
||||
for k,v in ipairs(inv:get_list(list)) do
|
||||
player:get_inventory():add_item("main",v)
|
||||
inv:remove_item(list,v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
barter.chest.cancel = function(meta)
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1"))
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)
|
||||
end
|
||||
|
||||
barter.chest.exchange = function(meta)
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2"))
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)
|
||||
end
|
||||
|
||||
minetest.register_node("currency:barter", {
|
||||
drawtype = "nodebox",
|
||||
description = S("Barter Table"),
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"barter_top.png",
|
||||
"barter_base.png",
|
||||
"barter_side.png"},
|
||||
inventory_image = "barter_top.png",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-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.250000,-0.250000,0.500000,0.437500},
|
||||
{0.250000,-0.500000,-0.437500,0.437500,0.500000,-0.250000},
|
||||
{0.250000,-0.500000,0.250000,0.437500,0.500000,0.447500},
|
||||
},
|
||||
},
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Barter Table"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
barter.chest.update_formspec(meta)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("pl1", 3*4)
|
||||
inv:set_size("pl2", 3*4)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
pl_receive_fields = function(n)
|
||||
if fields[n.."_start"] and meta:get_string(n) == "" then
|
||||
meta:set_string(n,sender:get_player_name())
|
||||
end
|
||||
if meta:get_string(n) == "" then
|
||||
meta:set_int(n.."step",0)
|
||||
elseif meta:get_int(n.."step")==0 then
|
||||
meta:set_int(n.."step",1)
|
||||
end
|
||||
if sender:get_player_name() == meta:get_string(n) then
|
||||
if meta:get_int(n.."step")==1 and fields[n.."_accept1"] then
|
||||
meta:set_int(n.."step",2)
|
||||
end
|
||||
if meta:get_int(n.."step")==2 and fields[n.."_accept2"] then
|
||||
meta:set_int(n.."step",3)
|
||||
if n == "pl1" and meta:get_int("pl2step") == 3 then barter.chest.exchange(meta) end
|
||||
if n == "pl2" and meta:get_int("pl1step") == 3 then barter.chest.exchange(meta) end
|
||||
end
|
||||
if fields[n.."_cancel"] then barter.chest.cancel(meta) end
|
||||
end
|
||||
end
|
||||
pl_receive_fields("pl1") pl_receive_fields("pl2")
|
||||
-- End
|
||||
barter.chest.update_formspec(meta)
|
||||
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 barter.chest.check_privilege(from_list,player:get_player_name(),meta) then return 0 end
|
||||
if not barter.chest.check_privilege(to_list,player:get_player_name(),meta) 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 barter.chest.check_privilege(listname,player:get_player_name(),meta) 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 barter.chest.check_privilege(listname,player:get_player_name(),meta) then return 0 end
|
||||
return stack:get_count()
|
||||
end,
|
||||
})
|
||||
barter = {}
|
||||
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
barter.chest = {}
|
||||
barter.chest.formspec = {
|
||||
main = "size[8,9]"..
|
||||
"list[current_name;pl1;0,0;3,4;]"..
|
||||
"list[current_name;pl2;5,0;3,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]",
|
||||
pl1 = {
|
||||
start = "button[3,1;1,1;pl1_start;" .. S("Start") .. "]",
|
||||
player = function(name) return "label[3,0;"..name.."]" end,
|
||||
accept1 = "button[3,1;1,1;pl1_accept1;" .. S("Confirm") .. "]"..
|
||||
"button[3,2;1,1;pl1_cancel;" .. S("Cancel") .. "]",
|
||||
accept2 = "button[3,1;1,1;pl1_accept2;" .. S("Exchange") .. "]"..
|
||||
"button[3,2;1,1;pl1_cancel;" .. S("Cancel") .. "]",
|
||||
},
|
||||
pl2 = {
|
||||
start = "button[4,1;1,1;pl2_start;" .. S("Start") .. "]",
|
||||
player = function(name) return "label[4,0;"..name.."]" end,
|
||||
accept1 = "button[4,1;1,1;pl2_accept1;" .. S("Confirm") .. "]"..
|
||||
"button[4,2;1,1;pl2_cancel;" .. S("Cancel") .. "]",
|
||||
accept2 = "button[4,1;1,1;pl2_accept2;" .. S("Exchange") .. "]"..
|
||||
"button[4,2;1,1;pl2_cancel;" .. S("Cancel") .. "]",
|
||||
},
|
||||
}
|
||||
|
||||
barter.chest.check_privilege = function(listname,playername,meta)
|
||||
if listname == "pl1" then
|
||||
if playername ~= meta:get_string("pl1") then
|
||||
return false
|
||||
elseif meta:get_int("pl1step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
if listname == "pl2" then
|
||||
if playername ~= meta:get_string("pl2") then
|
||||
return false
|
||||
elseif meta:get_int("pl2step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
barter.chest.update_formspec = function(meta)
|
||||
formspec = barter.chest.formspec.main
|
||||
pl_formspec = function (n)
|
||||
if meta:get_int(n.."step")==0 then
|
||||
formspec = formspec .. barter.chest.formspec[n].start
|
||||
else
|
||||
formspec = formspec .. barter.chest.formspec[n].player(meta:get_string(n))
|
||||
if meta:get_int(n.."step") == 1 then
|
||||
formspec = formspec .. barter.chest.formspec[n].accept1
|
||||
elseif meta:get_int(n.."step") == 2 then
|
||||
formspec = formspec .. barter.chest.formspec[n].accept2
|
||||
end
|
||||
end
|
||||
end
|
||||
pl_formspec("pl1") pl_formspec("pl2")
|
||||
meta:set_string("formspec",formspec)
|
||||
end
|
||||
|
||||
barter.chest.give_inventory = function(inv,list,playername)
|
||||
player = minetest.get_player_by_name(playername)
|
||||
if player then
|
||||
for k,v in ipairs(inv:get_list(list)) do
|
||||
player:get_inventory():add_item("main",v)
|
||||
inv:remove_item(list,v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
barter.chest.cancel = function(meta)
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1"))
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)
|
||||
end
|
||||
|
||||
barter.chest.exchange = function(meta)
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2"))
|
||||
barter.chest.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)
|
||||
end
|
||||
|
||||
minetest.register_node("currency:barter", {
|
||||
drawtype = "nodebox",
|
||||
description = S("Barter Table"),
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"barter_top.png",
|
||||
"barter_base.png",
|
||||
"barter_side.png"},
|
||||
inventory_image = "barter_top.png",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-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.250000,-0.250000,0.500000,0.437500},
|
||||
{0.250000,-0.500000,-0.437500,0.437500,0.500000,-0.250000},
|
||||
{0.250000,-0.500000,0.250000,0.437500,0.500000,0.447500},
|
||||
},
|
||||
},
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Barter Table"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
barter.chest.update_formspec(meta)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("pl1", 3*4)
|
||||
inv:set_size("pl2", 3*4)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
pl_receive_fields = function(n)
|
||||
if fields[n.."_start"] and meta:get_string(n) == "" then
|
||||
meta:set_string(n,sender:get_player_name())
|
||||
end
|
||||
if meta:get_string(n) == "" then
|
||||
meta:set_int(n.."step",0)
|
||||
elseif meta:get_int(n.."step")==0 then
|
||||
meta:set_int(n.."step",1)
|
||||
end
|
||||
if sender:get_player_name() == meta:get_string(n) then
|
||||
if meta:get_int(n.."step")==1 and fields[n.."_accept1"] then
|
||||
meta:set_int(n.."step",2)
|
||||
end
|
||||
if meta:get_int(n.."step")==2 and fields[n.."_accept2"] then
|
||||
meta:set_int(n.."step",3)
|
||||
if n == "pl1" and meta:get_int("pl2step") == 3 then barter.chest.exchange(meta) end
|
||||
if n == "pl2" and meta:get_int("pl1step") == 3 then barter.chest.exchange(meta) end
|
||||
end
|
||||
if fields[n.."_cancel"] then barter.chest.cancel(meta) end
|
||||
end
|
||||
end
|
||||
pl_receive_fields("pl1") pl_receive_fields("pl2")
|
||||
-- End
|
||||
barter.chest.update_formspec(meta)
|
||||
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 barter.chest.check_privilege(from_list,player:get_player_name(),meta) then return 0 end
|
||||
if not barter.chest.check_privilege(to_list,player:get_player_name(),meta) 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 barter.chest.check_privilege(listname,player:get_player_name(),meta) 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 barter.chest.check_privilege(listname,player:get_player_name(),meta) then return 0 end
|
||||
return stack:get_count()
|
||||
end,
|
||||
})
|
||||
|
274
crafting.lua
274
crafting.lua
@ -1,137 +1,137 @@
|
||||
minetest.register_craft({
|
||||
output = 'currency:safe',
|
||||
recipe = {
|
||||
{'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({
|
||||
output = 'currency:shop',
|
||||
recipe = {
|
||||
{'default:sign_wall'},
|
||||
{'default:chest_locked'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'currency:barter',
|
||||
recipe = {
|
||||
{'default:sign_wall'},
|
||||
{'default:chest'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_10",
|
||||
recipe = {"currency:minegeld_cent_5", "currency:minegeld_cent_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_5 2",
|
||||
recipe = {"currency:minegeld_cent_10"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_25",
|
||||
recipe = {"currency:minegeld_cent_5", "currency:minegeld_cent_5", "currency:minegeld_cent_5", "currency:minegeld_cent_5", "currency:minegeld_cent_5",},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_5 5",
|
||||
recipe = {"currency:minegeld_cent_25"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld",
|
||||
recipe = {"currency:minegeld_cent_25", "currency:minegeld_cent_25", "currency:minegeld_cent_25", "currency:minegeld_cent_25"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_25 4",
|
||||
recipe = {"currency:minegeld"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_5",
|
||||
recipe = {"currency:minegeld", "currency:minegeld", "currency:minegeld", "currency:minegeld", "currency:minegeld"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld 5",
|
||||
recipe = {"currency:minegeld_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_10",
|
||||
recipe = {"currency:minegeld_5", "currency:minegeld_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_5 2",
|
||||
recipe = {"currency:minegeld_10"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld 5",
|
||||
recipe = {"currency:minegeld_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_10 5",
|
||||
recipe = {"currency:minegeld_50"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_50",
|
||||
recipe = {"currency:minegeld_10", "currency:minegeld_10", "currency:minegeld_10", "currency:minegeld_10", "currency:minegeld_10"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_100",
|
||||
recipe = {"currency:minegeld_50", "currency:minegeld_50"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_50 2",
|
||||
recipe = {"currency:minegeld_100" },
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_bundle",
|
||||
recipe = {
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld"
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "currency:minegeld_bundle",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'currency:safe',
|
||||
recipe = {
|
||||
{'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({
|
||||
output = 'currency:shop',
|
||||
recipe = {
|
||||
{'default:sign_wall'},
|
||||
{'default:chest_locked'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'currency:barter',
|
||||
recipe = {
|
||||
{'default:sign_wall'},
|
||||
{'default:chest'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_10",
|
||||
recipe = {"currency:minegeld_cent_5", "currency:minegeld_cent_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_5 2",
|
||||
recipe = {"currency:minegeld_cent_10"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_25",
|
||||
recipe = {"currency:minegeld_cent_5", "currency:minegeld_cent_5", "currency:minegeld_cent_5", "currency:minegeld_cent_5", "currency:minegeld_cent_5",},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_5 5",
|
||||
recipe = {"currency:minegeld_cent_25"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld",
|
||||
recipe = {"currency:minegeld_cent_25", "currency:minegeld_cent_25", "currency:minegeld_cent_25", "currency:minegeld_cent_25"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_cent_25 4",
|
||||
recipe = {"currency:minegeld"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_5",
|
||||
recipe = {"currency:minegeld", "currency:minegeld", "currency:minegeld", "currency:minegeld", "currency:minegeld"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld 5",
|
||||
recipe = {"currency:minegeld_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_10",
|
||||
recipe = {"currency:minegeld_5", "currency:minegeld_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_5 2",
|
||||
recipe = {"currency:minegeld_10"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld 5",
|
||||
recipe = {"currency:minegeld_5"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_10 5",
|
||||
recipe = {"currency:minegeld_50"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_50",
|
||||
recipe = {"currency:minegeld_10", "currency:minegeld_10", "currency:minegeld_10", "currency:minegeld_10", "currency:minegeld_10"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_100",
|
||||
recipe = {"currency:minegeld_50", "currency:minegeld_50"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_50 2",
|
||||
recipe = {"currency:minegeld_100" },
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "currency:minegeld_bundle",
|
||||
recipe = {
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld",
|
||||
"group:minegeld"
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "currency:minegeld_bundle",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
|
130
craftitems.lua
130
craftitems.lua
@ -1,65 +1,65 @@
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_cent_5", {
|
||||
description = S("5 Minegeld cent coin"),
|
||||
inventory_image = "minegeld_cent_5.png",
|
||||
stack_max = 1000,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_cent_10", {
|
||||
description = S("10 Minegeld cent coin"),
|
||||
inventory_image = "minegeld_cent_10.png",
|
||||
stack_max = 1000,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_cent_25", {
|
||||
description = S("25 Minegeld cent coin"),
|
||||
inventory_image = "minegeld_cent_25.png",
|
||||
stack_max = 1000,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld", {
|
||||
description = S("1 Minegeld Note"),
|
||||
inventory_image = "minegeld.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_5", {
|
||||
description = S("5 Minegeld Note"),
|
||||
inventory_image = "minegeld_5.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_10", {
|
||||
description = S("10 Minegeld Note"),
|
||||
inventory_image = "minegeld_10.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_50", {
|
||||
description = S("50 Minegeld Note"),
|
||||
inventory_image = "minegeld_50.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_100", {
|
||||
description = S("100 Minegeld Note"),
|
||||
inventory_image = "minegeld_100.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_bundle", {
|
||||
description = S("Bundle of random Minegeld notes"),
|
||||
inventory_image = "minegeld_bundle.png",
|
||||
stack_max = 65535,
|
||||
})
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_cent_5", {
|
||||
description = S("5 Minegeld cent coin"),
|
||||
inventory_image = "minegeld_cent_5.png",
|
||||
stack_max = 1000,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_cent_10", {
|
||||
description = S("10 Minegeld cent coin"),
|
||||
inventory_image = "minegeld_cent_10.png",
|
||||
stack_max = 1000,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_cent_25", {
|
||||
description = S("25 Minegeld cent coin"),
|
||||
inventory_image = "minegeld_cent_25.png",
|
||||
stack_max = 1000,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld", {
|
||||
description = S("1 Minegeld Note"),
|
||||
inventory_image = "minegeld.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_5", {
|
||||
description = S("5 Minegeld Note"),
|
||||
inventory_image = "minegeld_5.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_10", {
|
||||
description = S("10 Minegeld Note"),
|
||||
inventory_image = "minegeld_10.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_50", {
|
||||
description = S("50 Minegeld Note"),
|
||||
inventory_image = "minegeld_50.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_100", {
|
||||
description = S("100 Minegeld Note"),
|
||||
inventory_image = "minegeld_100.png",
|
||||
stack_max = 65535,
|
||||
groups = {minegeld = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("currency:minegeld_bundle", {
|
||||
description = S("Bundle of random Minegeld notes"),
|
||||
inventory_image = "minegeld_bundle.png",
|
||||
stack_max = 65535,
|
||||
})
|
||||
|
@ -1,4 +1,4 @@
|
||||
default
|
||||
intllib?
|
||||
loot?
|
||||
pipeworks?
|
||||
pipeworks?
|
||||
|
48
init.lua
48
init.lua
@ -1,24 +1,24 @@
|
||||
local modpath = minetest.get_modpath("currency")
|
||||
|
||||
-- internationalization boilerplate
|
||||
local S, NS = dofile(modpath.."/intllib.lua")
|
||||
|
||||
minetest.log("info", S("Currency mod loading..."))
|
||||
|
||||
dofile(modpath.."/craftitems.lua")
|
||||
minetest.log("info", "[Currency] "..S("Craft_items Loaded!"))
|
||||
dofile(modpath.."/shop.lua")
|
||||
minetest.log("info", "[Currency] "..S("Shop Loaded!"))
|
||||
dofile(modpath.."/barter.lua")
|
||||
minetest.log("info", "[Currency] "..S("Barter Loaded!"))
|
||||
dofile(modpath.."/safe.lua")
|
||||
minetest.log("info", "[Currency] "..S("Safe Loaded!"))
|
||||
dofile(modpath.."/crafting.lua")
|
||||
minetest.log("info", "[Currency] "..S("Crafting Loaded!"))
|
||||
|
||||
if minetest.settings:get_bool("creative_mode") then
|
||||
minetest.log("info", "[Currency] "..S("Creative mode in use, skipping basic income."))
|
||||
else
|
||||
dofile(modpath.."/income.lua")
|
||||
minetest.log("info", "[Currency] "..S("Income Loaded!"))
|
||||
end
|
||||
local modpath = minetest.get_modpath("currency")
|
||||
|
||||
-- internationalization boilerplate
|
||||
local S, NS = dofile(modpath.."/intllib.lua")
|
||||
|
||||
minetest.log("info", S("Currency mod loading..."))
|
||||
|
||||
dofile(modpath.."/craftitems.lua")
|
||||
minetest.log("info", "[Currency] "..S("Craft_items Loaded!"))
|
||||
dofile(modpath.."/shop.lua")
|
||||
minetest.log("info", "[Currency] "..S("Shop Loaded!"))
|
||||
dofile(modpath.."/barter.lua")
|
||||
minetest.log("info", "[Currency] "..S("Barter Loaded!"))
|
||||
dofile(modpath.."/safe.lua")
|
||||
minetest.log("info", "[Currency] "..S("Safe Loaded!"))
|
||||
dofile(modpath.."/crafting.lua")
|
||||
minetest.log("info", "[Currency] "..S("Crafting Loaded!"))
|
||||
|
||||
if minetest.settings:get_bool("creative_mode") then
|
||||
minetest.log("info", "[Currency] "..S("Creative mode in use, skipping basic income."))
|
||||
else
|
||||
dofile(modpath.."/income.lua")
|
||||
minetest.log("info", "[Currency] "..S("Income Loaded!"))
|
||||
end
|
||||
|
212
safe.lua
212
safe.lua
@ -1,106 +1,106 @@
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
function default.get_safe_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"list[nodemeta:".. spos .. ";main;1,1;6,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[nodemeta:".. spos .. ";main]"..
|
||||
"listring[current_player;main]"
|
||||
return formspec
|
||||
end
|
||||
|
||||
local function has_safe_privilege(meta, player)
|
||||
local name = ""
|
||||
if player then
|
||||
if minetest.check_player_privs(player, "protection_bypass") then
|
||||
return true
|
||||
end
|
||||
name = player:get_player_name()
|
||||
end
|
||||
if name ~= meta:get_string("owner") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_node("currency:safe", {
|
||||
description = S("Safe"),
|
||||
inventory_image = "safe_front.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_front.png",},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=1},
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", S("Safe (owned by @1)", meta:get_string("owner")))
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Safe")
|
||||
meta:set_string("owner", "")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 6*2)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main") and has_safe_privilege(meta, player)
|
||||
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_safe_privilege(meta, player) then
|
||||
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
|
||||
player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
|
||||
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_safe_privilege(meta, player) then
|
||||
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
|
||||
player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
|
||||
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_safe_privilege(meta, player) then
|
||||
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
|
||||
player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", S("@1 moves stuff in safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", S("@1 moves stuff to safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", S("@1 takes stuff from safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if has_safe_privilege(meta, clicker) then
|
||||
minetest.show_formspec(
|
||||
clicker:get_player_name(),
|
||||
"currency:safe",
|
||||
default.get_safe_formspec(pos)
|
||||
)
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
function default.get_safe_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"list[nodemeta:".. spos .. ";main;1,1;6,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[nodemeta:".. spos .. ";main]"..
|
||||
"listring[current_player;main]"
|
||||
return formspec
|
||||
end
|
||||
|
||||
local function has_safe_privilege(meta, player)
|
||||
local name = ""
|
||||
if player then
|
||||
if minetest.check_player_privs(player, "protection_bypass") then
|
||||
return true
|
||||
end
|
||||
name = player:get_player_name()
|
||||
end
|
||||
if name ~= meta:get_string("owner") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_node("currency:safe", {
|
||||
description = S("Safe"),
|
||||
inventory_image = "safe_front.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_side.png",
|
||||
"safe_front.png",},
|
||||
is_ground_content = false,
|
||||
groups = {cracky=1},
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", S("Safe (owned by @1)", meta:get_string("owner")))
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Safe")
|
||||
meta:set_string("owner", "")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 6*2)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main") and has_safe_privilege(meta, player)
|
||||
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_safe_privilege(meta, player) then
|
||||
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
|
||||
player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
|
||||
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_safe_privilege(meta, player) then
|
||||
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
|
||||
player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
|
||||
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_safe_privilege(meta, player) then
|
||||
minetest.log("action", S("@1 tried to access a safe belonging to @2 at @3",
|
||||
player:get_player_name(), meta:get_string("owner"), minetest.pos_to_string(pos)))
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", S("@1 moves stuff in safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", S("@1 moves stuff to safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", S("@1 takes stuff from safe at @2", player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if has_safe_privilege(meta, clicker) then
|
||||
minetest.show_formspec(
|
||||
clicker:get_player_name(),
|
||||
"currency:safe",
|
||||
default.get_safe_formspec(pos)
|
||||
)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
434
shop.lua
434
shop.lua
@ -1,217 +1,217 @@
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
default.shop = {}
|
||||
default.shop.current_shop = {}
|
||||
default.shop.formspec = {
|
||||
customer = function(pos)
|
||||
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
||||
local formspec = "size[8,9.5]"..
|
||||
"label[0,0;" .. S("Customer gives (pay here!)") .. "]"..
|
||||
"list[current_player;customer_gives;0,0.5;3,2;]"..
|
||||
"label[0,2.5;" .. S("Customer gets:") .. "]"..
|
||||
"list[current_player;customer_gets;0,3;3,2;]"..
|
||||
"label[5,0;" .. S("Owner wants:") .. "]"..
|
||||
"list["..list_name..";owner_wants;5,0.5;3,2;]"..
|
||||
"label[5,2.5;" .. S("Owner gives:") .. "]"..
|
||||
"list["..list_name..";owner_gives;5,3;3,2;]"..
|
||||
"list[current_player;main;0,5.5;8,4;]"..
|
||||
"button[3,2;2,1;exchange;" .. S("Exchange") .. "]"
|
||||
return formspec
|
||||
end,
|
||||
owner = function(pos)
|
||||
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
||||
local formspec = "size[8,9.5]"..
|
||||
"label[0,0;" .. S("Customers gave:") .. "]"..
|
||||
"list["..list_name..";customers_gave;0,0.5;3,2;]"..
|
||||
"label[0,2.5;" .. S("Your stock:") .. "]"..
|
||||
"list["..list_name..";stock;0,3;3,2;]"..
|
||||
"label[5,0;" .. S("You want:") .. "]"..
|
||||
"list["..list_name..";owner_wants;5,0.5;3,2;]"..
|
||||
"label[5,2.5;" .. S("In exchange, you give:") .. "]"..
|
||||
"list["..list_name..";owner_gives;5,3;3,2;]"..
|
||||
"label[0,5;" .. S("Owner, Use (E)+Place (right mouse button) for customer interface") .. "]"..
|
||||
"list[current_player;main;0,5.5;8,4;]"
|
||||
return formspec
|
||||
end,
|
||||
}
|
||||
|
||||
local have_pipeworks = minetest.global_exists("pipeworks")
|
||||
|
||||
default.shop.check_privilege = function(listname,playername,meta)
|
||||
--[[if listname == "pl1" then
|
||||
if playername ~= meta:get_string("pl1") then
|
||||
return false
|
||||
elseif meta:get_int("pl1step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
if listname == "pl2" then
|
||||
if playername ~= meta:get_string("pl2") then
|
||||
return false
|
||||
elseif meta:get_int("pl2step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end]]
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
default.shop.give_inventory = function(inv,list,playername)
|
||||
player = minetest.get_player_by_name(playername)
|
||||
if player then
|
||||
for k,v in ipairs(inv:get_list(list)) do
|
||||
player:get_inventory():add_item("main",v)
|
||||
inv:remove_item(list,v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
default.shop.cancel = function(meta)
|
||||
--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1"))
|
||||
default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)]]
|
||||
end
|
||||
|
||||
default.shop.exchange = function(meta)
|
||||
--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2"))
|
||||
default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)]]
|
||||
end
|
||||
|
||||
minetest.register_node("currency:shop", {
|
||||
description = S("Shop"),
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"shop_top.png",
|
||||
"shop_top.png",
|
||||
"shop_side.png",
|
||||
"shop_side.png",
|
||||
"shop_side.png",
|
||||
"shop_front.png"},
|
||||
inventory_image = "shop_front.png",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local owner = placer:get_player_name()
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Exchange shop (owned by @1)", owner))
|
||||
meta:set_string("owner",owner)
|
||||
--[[meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")]]
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("customers_gave", 3*2)
|
||||
inv:set_size("stock", 3*2)
|
||||
inv:set_size("owner_wants", 3*2)
|
||||
inv:set_size("owner_gives", 3*2)
|
||||
if have_pipeworks then pipeworks.after_place(pos) end
|
||||
end,
|
||||
after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig),
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("stock",stack)
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("stock", stack)
|
||||
end,
|
||||
input_inventory = "customers_gave",
|
||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
clicker:get_inventory():set_size("customer_gives", 3*2)
|
||||
clicker:get_inventory():set_size("customer_gets", 3*2)
|
||||
default.shop.current_shop[clicker:get_player_name()] = pos
|
||||
local meta = minetest.get_meta(pos)
|
||||
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))
|
||||
else
|
||||
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.customer(pos))
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") then return 0 end
|
||||
return count
|
||||
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
|
||||
return stack:get_count()
|
||||
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") then return 0 end
|
||||
return stack:get_count()
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||
if formname == "currency:shop_formspec" and fields.exchange ~= nil and fields.exchange ~= "" then
|
||||
local name = sender:get_player_name()
|
||||
local pos = default.shop.current_shop[name]
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("owner") == name then
|
||||
minetest.chat_send_player(name,S("This is your own shop, you can't exchange to yourself!"))
|
||||
else
|
||||
local minv = meta:get_inventory()
|
||||
local pinv = sender:get_inventory()
|
||||
local invlist_tostring = function(invlist)
|
||||
local out = {}
|
||||
for i, item in pairs(invlist) do
|
||||
out[i] = item:to_string()
|
||||
end
|
||||
return out
|
||||
end
|
||||
local wants = minv:get_list("owner_wants")
|
||||
local gives = minv:get_list("owner_gives")
|
||||
if wants == nil or gives == nil then return end -- do not crash the server
|
||||
-- Check if we can exchange
|
||||
local can_exchange = true
|
||||
local owners_fault = false
|
||||
for i, item in pairs(wants) do
|
||||
if not pinv:contains_item("customer_gives",item) then
|
||||
can_exchange = false
|
||||
end
|
||||
end
|
||||
for i, item in pairs(gives) do
|
||||
if not minv:contains_item("stock",item) then
|
||||
can_exchange = false
|
||||
owners_fault = true
|
||||
end
|
||||
end
|
||||
if can_exchange then
|
||||
for i, item in pairs(wants) do
|
||||
pinv:remove_item("customer_gives",item)
|
||||
minv:add_item("customers_gave",item)
|
||||
end
|
||||
for i, item in pairs(gives) do
|
||||
minv:remove_item("stock",item)
|
||||
pinv:add_item("customer_gets",item)
|
||||
end
|
||||
minetest.chat_send_player(name,S("Exchanged!"))
|
||||
else
|
||||
if owners_fault then
|
||||
minetest.chat_send_player(name,S("Exchange can not be done, contact the shop owner."))
|
||||
else
|
||||
minetest.chat_send_player(name,S("Exchange can not be done, check if you put all items!"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- internationalization boilerplate
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
default.shop = {}
|
||||
default.shop.current_shop = {}
|
||||
default.shop.formspec = {
|
||||
customer = function(pos)
|
||||
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
||||
local formspec = "size[8,9.5]"..
|
||||
"label[0,0;" .. S("Customer gives (pay here!)") .. "]"..
|
||||
"list[current_player;customer_gives;0,0.5;3,2;]"..
|
||||
"label[0,2.5;" .. S("Customer gets:") .. "]"..
|
||||
"list[current_player;customer_gets;0,3;3,2;]"..
|
||||
"label[5,0;" .. S("Owner wants:") .. "]"..
|
||||
"list["..list_name..";owner_wants;5,0.5;3,2;]"..
|
||||
"label[5,2.5;" .. S("Owner gives:") .. "]"..
|
||||
"list["..list_name..";owner_gives;5,3;3,2;]"..
|
||||
"list[current_player;main;0,5.5;8,4;]"..
|
||||
"button[3,2;2,1;exchange;" .. S("Exchange") .. "]"
|
||||
return formspec
|
||||
end,
|
||||
owner = function(pos)
|
||||
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
||||
local formspec = "size[8,9.5]"..
|
||||
"label[0,0;" .. S("Customers gave:") .. "]"..
|
||||
"list["..list_name..";customers_gave;0,0.5;3,2;]"..
|
||||
"label[0,2.5;" .. S("Your stock:") .. "]"..
|
||||
"list["..list_name..";stock;0,3;3,2;]"..
|
||||
"label[5,0;" .. S("You want:") .. "]"..
|
||||
"list["..list_name..";owner_wants;5,0.5;3,2;]"..
|
||||
"label[5,2.5;" .. S("In exchange, you give:") .. "]"..
|
||||
"list["..list_name..";owner_gives;5,3;3,2;]"..
|
||||
"label[0,5;" .. S("Owner, Use (E)+Place (right mouse button) for customer interface") .. "]"..
|
||||
"list[current_player;main;0,5.5;8,4;]"
|
||||
return formspec
|
||||
end,
|
||||
}
|
||||
|
||||
local have_pipeworks = minetest.global_exists("pipeworks")
|
||||
|
||||
default.shop.check_privilege = function(listname,playername,meta)
|
||||
--[[if listname == "pl1" then
|
||||
if playername ~= meta:get_string("pl1") then
|
||||
return false
|
||||
elseif meta:get_int("pl1step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
if listname == "pl2" then
|
||||
if playername ~= meta:get_string("pl2") then
|
||||
return false
|
||||
elseif meta:get_int("pl2step") ~= 1 then
|
||||
return false
|
||||
end
|
||||
end]]
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
default.shop.give_inventory = function(inv,list,playername)
|
||||
player = minetest.get_player_by_name(playername)
|
||||
if player then
|
||||
for k,v in ipairs(inv:get_list(list)) do
|
||||
player:get_inventory():add_item("main",v)
|
||||
inv:remove_item(list,v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
default.shop.cancel = function(meta)
|
||||
--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1"))
|
||||
default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)]]
|
||||
end
|
||||
|
||||
default.shop.exchange = function(meta)
|
||||
--[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2"))
|
||||
default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1"))
|
||||
meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")
|
||||
meta:set_int("pl1step",0)
|
||||
meta:set_int("pl2step",0)]]
|
||||
end
|
||||
|
||||
minetest.register_node("currency:shop", {
|
||||
description = S("Shop"),
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"shop_top.png",
|
||||
"shop_top.png",
|
||||
"shop_side.png",
|
||||
"shop_side.png",
|
||||
"shop_side.png",
|
||||
"shop_front.png"},
|
||||
inventory_image = "shop_front.png",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local owner = placer:get_player_name()
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Exchange shop (owned by @1)", owner))
|
||||
meta:set_string("owner",owner)
|
||||
--[[meta:set_string("pl1","")
|
||||
meta:set_string("pl2","")]]
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("customers_gave", 3*2)
|
||||
inv:set_size("stock", 3*2)
|
||||
inv:set_size("owner_wants", 3*2)
|
||||
inv:set_size("owner_gives", 3*2)
|
||||
if have_pipeworks then pipeworks.after_place(pos) end
|
||||
end,
|
||||
after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig),
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("stock",stack)
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("stock", stack)
|
||||
end,
|
||||
input_inventory = "customers_gave",
|
||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
clicker:get_inventory():set_size("customer_gives", 3*2)
|
||||
clicker:get_inventory():set_size("customer_gets", 3*2)
|
||||
default.shop.current_shop[clicker:get_player_name()] = pos
|
||||
local meta = minetest.get_meta(pos)
|
||||
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))
|
||||
else
|
||||
minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.customer(pos))
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") then return 0 end
|
||||
return count
|
||||
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
|
||||
return stack:get_count()
|
||||
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") then return 0 end
|
||||
return stack:get_count()
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||
if formname == "currency:shop_formspec" and fields.exchange ~= nil and fields.exchange ~= "" then
|
||||
local name = sender:get_player_name()
|
||||
local pos = default.shop.current_shop[name]
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("owner") == name then
|
||||
minetest.chat_send_player(name,S("This is your own shop, you can't exchange to yourself!"))
|
||||
else
|
||||
local minv = meta:get_inventory()
|
||||
local pinv = sender:get_inventory()
|
||||
local invlist_tostring = function(invlist)
|
||||
local out = {}
|
||||
for i, item in pairs(invlist) do
|
||||
out[i] = item:to_string()
|
||||
end
|
||||
return out
|
||||
end
|
||||
local wants = minv:get_list("owner_wants")
|
||||
local gives = minv:get_list("owner_gives")
|
||||
if wants == nil or gives == nil then return end -- do not crash the server
|
||||
-- Check if we can exchange
|
||||
local can_exchange = true
|
||||
local owners_fault = false
|
||||
for i, item in pairs(wants) do
|
||||
if not pinv:contains_item("customer_gives",item) then
|
||||
can_exchange = false
|
||||
end
|
||||
end
|
||||
for i, item in pairs(gives) do
|
||||
if not minv:contains_item("stock",item) then
|
||||
can_exchange = false
|
||||
owners_fault = true
|
||||
end
|
||||
end
|
||||
if can_exchange then
|
||||
for i, item in pairs(wants) do
|
||||
pinv:remove_item("customer_gives",item)
|
||||
minv:add_item("customers_gave",item)
|
||||
end
|
||||
for i, item in pairs(gives) do
|
||||
minv:remove_item("stock",item)
|
||||
pinv:add_item("customer_gets",item)
|
||||
end
|
||||
minetest.chat_send_player(name,S("Exchanged!"))
|
||||
else
|
||||
if owners_fault then
|
||||
minetest.chat_send_player(name,S("Exchange can not be done, contact the shop owner."))
|
||||
else
|
||||
minetest.chat_send_player(name,S("Exchange can not be done, check if you put all items!"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user