mirror of
https://github.com/mt-mods/currency.git
synced 2024-11-28 23:33:43 +01:00
Add is_ground_content = false to nodes (#4)
* shop isn't ground content also some eye-bleeding whitespace changes * barter-table isn't ground content and only the worst whitespace fixed
This commit is contained in:
parent
7a6eb3c1ac
commit
d97edda151
@ -113,9 +113,11 @@ minetest.register_node("currency:barter", {
|
|||||||
description = S("Barter Table"),
|
description = S("Barter Table"),
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
tiles = {"barter_top.png",
|
tiles = {
|
||||||
|
"barter_top.png",
|
||||||
"barter_base.png",
|
"barter_base.png",
|
||||||
"barter_side.png"},
|
"barter_side.png"
|
||||||
|
},
|
||||||
inventory_image = "barter_top.png",
|
inventory_image = "barter_top.png",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
@ -128,6 +130,7 @@ minetest.register_node("currency:barter", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||||
|
is_ground_content = false,
|
||||||
sounds = currency.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)
|
||||||
|
123
shop.lua
123
shop.lua
@ -41,7 +41,7 @@ currency.shop.formspec = {
|
|||||||
|
|
||||||
local have_pipeworks = minetest.global_exists("pipeworks")
|
local have_pipeworks = minetest.global_exists("pipeworks")
|
||||||
|
|
||||||
currency.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
|
||||||
@ -60,12 +60,12 @@ currency.shop.check_privilege = function(listname,playername,meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
currency.shop.give_inventory = function(inv,list,playername)
|
currency.shop.give_inventory = function(inv, list, playername)
|
||||||
local player = minetest.get_player_by_name(playername)
|
local 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
|
||||||
player:get_inventory():add_item("main",v)
|
player:get_inventory():add_item("main", v)
|
||||||
inv:remove_item(list,v)
|
inv:remove_item(list, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -88,87 +88,57 @@ currency.shop.exchange = function(meta)
|
|||||||
meta:set_int("pl2step",0)]]
|
meta:set_int("pl2step",0)]]
|
||||||
end
|
end
|
||||||
|
|
||||||
local check_stock = function(
|
local check_stock = function(pos)
|
||||||
pos
|
local meta = minetest.get_meta(pos)
|
||||||
)
|
local minv = meta:get_inventory()
|
||||||
local meta = minetest.get_meta(
|
local gives = minv:get_list("owner_gives")
|
||||||
pos
|
|
||||||
)
|
|
||||||
local minv = meta:get_inventory(
|
|
||||||
)
|
|
||||||
local gives = minv:get_list(
|
|
||||||
"owner_gives"
|
|
||||||
)
|
|
||||||
local can_exchange = true
|
local can_exchange = true
|
||||||
for i, item in pairs(
|
for i, item in pairs(gives) do
|
||||||
gives
|
if not minv:contains_item("stock", item) then
|
||||||
) do
|
|
||||||
if not minv:contains_item(
|
|
||||||
"stock",
|
|
||||||
item
|
|
||||||
) then
|
|
||||||
can_exchange = false
|
can_exchange = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local owner = meta:get_string(
|
local owner = meta:get_string("owner")
|
||||||
"owner"
|
|
||||||
)
|
|
||||||
if can_exchange then
|
if can_exchange then
|
||||||
meta:set_string(
|
meta:set_string("infotext",
|
||||||
"infotext",
|
S("Exchange shop (owned by @1)", owner)
|
||||||
S(
|
|
||||||
"Exchange shop (owned by @1)",
|
|
||||||
owner
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
local applicable = "currency:shop"
|
local applicable = "currency:shop"
|
||||||
local node = minetest.get_node(
|
local node = minetest.get_node(pos)
|
||||||
pos
|
|
||||||
)
|
|
||||||
if node.name == applicable then
|
if node.name == applicable then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
node.name = applicable
|
node.name = applicable
|
||||||
minetest.swap_node(
|
minetest.swap_node(pos, node)
|
||||||
pos,
|
|
||||||
node
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
meta:set_string(
|
meta:set_string("infotext",
|
||||||
"infotext",
|
S("Exchange shop (owned by @1)", owner)
|
||||||
S(
|
.. ", " .. S("out of stock")
|
||||||
"Exchange shop (owned by @1)",
|
|
||||||
owner
|
|
||||||
) .. ", " .. S(
|
|
||||||
"out of stock"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
local applicable = "currency:shop_empty"
|
local applicable = "currency:shop_empty"
|
||||||
local node = minetest.get_node(
|
local node = minetest.get_node(pos)
|
||||||
pos
|
|
||||||
)
|
|
||||||
if node.name == applicable then
|
if node.name == applicable then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
node.name = applicable
|
node.name = applicable
|
||||||
minetest.swap_node(
|
minetest.swap_node(pos, node)
|
||||||
pos,
|
|
||||||
node
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("currency:shop", {
|
minetest.register_node("currency:shop", {
|
||||||
description = S("Shop"),
|
description = S("Shop"),
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
tiles = {"shop_top.png",
|
tiles = {
|
||||||
|
"shop_top.png",
|
||||||
"shop_top.png",
|
"shop_top.png",
|
||||||
"shop_side.png",
|
"shop_side.png",
|
||||||
"shop_side.png",
|
"shop_side.png",
|
||||||
"shop_side.png",
|
"shop_side.png",
|
||||||
"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},
|
||||||
|
is_ground_content = false,
|
||||||
sounds = currency.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()
|
||||||
@ -183,22 +153,18 @@ minetest.register_node("currency:shop", {
|
|||||||
inv:set_size("owner_wants", 3*2)
|
inv:set_size("owner_wants", 3*2)
|
||||||
inv:set_size("owner_gives", 3*2)
|
inv:set_size("owner_gives", 3*2)
|
||||||
if have_pipeworks then pipeworks.after_place(pos) end
|
if have_pipeworks then pipeworks.after_place(pos) end
|
||||||
check_stock(
|
check_stock(pos)
|
||||||
pos
|
|
||||||
)
|
|
||||||
end,
|
end,
|
||||||
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)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local result = inv:add_item("stock",stack)
|
local result = inv:add_item("stock", stack)
|
||||||
check_stock(
|
check_stock(pos)
|
||||||
pos
|
|
||||||
)
|
|
||||||
return result
|
return result
|
||||||
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)
|
||||||
@ -248,24 +214,25 @@ minetest.register_node("currency:shop", {
|
|||||||
minetest.register_node("currency:shop_empty", {
|
minetest.register_node("currency:shop_empty", {
|
||||||
description = S("Shop") .. " (" .. S("out of stock") .. ")",
|
description = S("Shop") .. " (" .. S("out of stock") .. ")",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
tiles = {"shop_top.png",
|
tiles = {
|
||||||
|
"shop_top.png",
|
||||||
"shop_top.png",
|
"shop_top.png",
|
||||||
"shop_side_empty.png",
|
"shop_side_empty.png",
|
||||||
"shop_side_empty.png",
|
"shop_side_empty.png",
|
||||||
"shop_side_empty.png",
|
"shop_side_empty.png",
|
||||||
"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},
|
||||||
|
is_ground_content = false,
|
||||||
sounds = currency.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)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local result = inv:add_item("stock",stack)
|
local result = inv:add_item("stock", stack)
|
||||||
check_stock(
|
check_stock(pos)
|
||||||
pos
|
|
||||||
)
|
|
||||||
return result
|
return result
|
||||||
end,
|
end,
|
||||||
can_insert = function(pos,node,stack,direction)
|
can_insert = function(pos,node,stack,direction)
|
||||||
@ -339,12 +306,12 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
local can_exchange = true
|
local can_exchange = true
|
||||||
local owners_fault = false
|
local owners_fault = false
|
||||||
for i, item in pairs(wants) do
|
for i, item in pairs(wants) do
|
||||||
if not pinv:contains_item("customer_gives",item) then
|
if not pinv:contains_item("customer_gives", item) then
|
||||||
can_exchange = false
|
can_exchange = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i, item in pairs(gives) do
|
for i, item in pairs(gives) do
|
||||||
if not minv:contains_item("stock",item) then
|
if not minv:contains_item("stock", item) then
|
||||||
can_exchange = false
|
can_exchange = false
|
||||||
owners_fault = true
|
owners_fault = true
|
||||||
end
|
end
|
||||||
@ -352,17 +319,15 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
if can_exchange then
|
if can_exchange then
|
||||||
local it
|
local it
|
||||||
for i, item in pairs(wants) do
|
for i, item in pairs(wants) do
|
||||||
it = pinv:remove_item("customer_gives",item)
|
it = pinv:remove_item("customer_gives", item)
|
||||||
minv:add_item("customers_gave",it)
|
minv:add_item("customers_gave", it)
|
||||||
end
|
end
|
||||||
for i, item in pairs(gives) do
|
for i, item in pairs(gives) do
|
||||||
it = minv:remove_item("stock",item)
|
it = minv:remove_item("stock", item)
|
||||||
pinv:add_item("customer_gets",it)
|
pinv:add_item("customer_gets", it)
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, S("Exchanged!"))
|
minetest.chat_send_player(name, S("Exchanged!"))
|
||||||
check_stock(
|
check_stock(pos)
|
||||||
pos
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
if owners_fault then
|
if owners_fault then
|
||||||
minetest.chat_send_player(name, S("Exchange can not be done, contact the shop owner."))
|
minetest.chat_send_player(name, S("Exchange can not be done, contact the shop owner."))
|
||||||
|
Loading…
Reference in New Issue
Block a user