mirror of
https://github.com/mt-mods/currency.git
synced 2024-11-25 05:43: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)
|
||||||
|
95
shop.lua
95
shop.lua
@ -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,9 +153,7 @@ 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 = {
|
||||||
@ -193,9 +161,7 @@ minetest.register_node("currency:shop", {
|
|||||||
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)
|
||||||
@ -248,14 +214,17 @@ 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 = {
|
||||||
@ -263,9 +232,7 @@ minetest.register_node("currency:shop_empty", {
|
|||||||
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)
|
||||||
@ -360,9 +327,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
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