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"),
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"barter_top.png",
|
||||
tiles = {
|
||||
"barter_top.png",
|
||||
"barter_base.png",
|
||||
"barter_side.png"},
|
||||
"barter_side.png"
|
||||
},
|
||||
inventory_image = "barter_top.png",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -128,6 +130,7 @@ minetest.register_node("currency:barter", {
|
||||
},
|
||||
},
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2},
|
||||
is_ground_content = false,
|
||||
sounds = currency.node_sound_wood_defaults(),
|
||||
on_construct = function(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)]]
|
||||
end
|
||||
|
||||
local check_stock = function(
|
||||
pos
|
||||
)
|
||||
local meta = minetest.get_meta(
|
||||
pos
|
||||
)
|
||||
local minv = meta:get_inventory(
|
||||
)
|
||||
local gives = minv:get_list(
|
||||
"owner_gives"
|
||||
)
|
||||
local check_stock = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local minv = meta:get_inventory()
|
||||
local gives = minv:get_list("owner_gives")
|
||||
local can_exchange = true
|
||||
for i, item in pairs(
|
||||
gives
|
||||
) do
|
||||
if not minv:contains_item(
|
||||
"stock",
|
||||
item
|
||||
) then
|
||||
for i, item in pairs(gives) do
|
||||
if not minv:contains_item("stock", item) then
|
||||
can_exchange = false
|
||||
end
|
||||
end
|
||||
local owner = meta:get_string(
|
||||
"owner"
|
||||
)
|
||||
local owner = meta:get_string("owner")
|
||||
if can_exchange then
|
||||
meta:set_string(
|
||||
"infotext",
|
||||
S(
|
||||
"Exchange shop (owned by @1)",
|
||||
owner
|
||||
)
|
||||
meta:set_string("infotext",
|
||||
S("Exchange shop (owned by @1)", owner)
|
||||
)
|
||||
local applicable = "currency:shop"
|
||||
local node = minetest.get_node(
|
||||
pos
|
||||
)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == applicable then
|
||||
return
|
||||
end
|
||||
node.name = applicable
|
||||
minetest.swap_node(
|
||||
pos,
|
||||
node
|
||||
)
|
||||
minetest.swap_node(pos, node)
|
||||
else
|
||||
meta:set_string(
|
||||
"infotext",
|
||||
S(
|
||||
"Exchange shop (owned by @1)",
|
||||
owner
|
||||
) .. ", " .. S(
|
||||
"out of stock"
|
||||
)
|
||||
meta:set_string("infotext",
|
||||
S("Exchange shop (owned by @1)", owner)
|
||||
.. ", " .. S("out of stock")
|
||||
)
|
||||
local applicable = "currency:shop_empty"
|
||||
local node = minetest.get_node(
|
||||
pos
|
||||
)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == applicable then
|
||||
return
|
||||
end
|
||||
node.name = applicable
|
||||
minetest.swap_node(
|
||||
pos,
|
||||
node
|
||||
)
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("currency:shop", {
|
||||
description = S("Shop"),
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"shop_top.png",
|
||||
tiles = {
|
||||
"shop_top.png",
|
||||
"shop_top.png",
|
||||
"shop_side.png",
|
||||
"shop_side.png",
|
||||
"shop_side.png",
|
||||
"shop_front.png"},
|
||||
"shop_front.png"
|
||||
},
|
||||
inventory_image = "shop_front.png",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
|
||||
is_ground_content = false,
|
||||
sounds = currency.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
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_gives", 3*2)
|
||||
if have_pipeworks then pipeworks.after_place(pos) end
|
||||
check_stock(
|
||||
pos
|
||||
)
|
||||
check_stock(pos)
|
||||
end,
|
||||
after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig),
|
||||
tube = {
|
||||
@ -193,9 +161,7 @@ minetest.register_node("currency:shop", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local result = inv:add_item("stock", stack)
|
||||
check_stock(
|
||||
pos
|
||||
)
|
||||
check_stock(pos)
|
||||
return result
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
@ -248,14 +214,17 @@ minetest.register_node("currency:shop", {
|
||||
minetest.register_node("currency:shop_empty", {
|
||||
description = S("Shop") .. " (" .. S("out of stock") .. ")",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"shop_top.png",
|
||||
tiles = {
|
||||
"shop_top.png",
|
||||
"shop_top.png",
|
||||
"shop_side_empty.png",
|
||||
"shop_side_empty.png",
|
||||
"shop_side_empty.png",
|
||||
"shop_front_empty.png"},
|
||||
"shop_front_empty.png"
|
||||
},
|
||||
drop = "currency:shop",
|
||||
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(),
|
||||
after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig),
|
||||
tube = {
|
||||
@ -263,9 +232,7 @@ minetest.register_node("currency:shop_empty", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local result = inv:add_item("stock", stack)
|
||||
check_stock(
|
||||
pos
|
||||
)
|
||||
check_stock(pos)
|
||||
return result
|
||||
end,
|
||||
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)
|
||||
end
|
||||
minetest.chat_send_player(name, S("Exchanged!"))
|
||||
check_stock(
|
||||
pos
|
||||
)
|
||||
check_stock(pos)
|
||||
else
|
||||
if owners_fault then
|
||||
minetest.chat_send_player(name, S("Exchange can not be done, contact the shop owner."))
|
||||
|
Loading…
Reference in New Issue
Block a user