diff --git a/api.lua b/api.lua index 1b33735..5ecbc87 100644 --- a/api.lua +++ b/api.lua @@ -124,10 +124,10 @@ function x_marketplace.set_player_balance(name, amount) return new_balance end -function x_marketplace.find_signs(player_pos, text) +function x_marketplace.find_signs(player_pos, text, sign) local pos0 = vector.subtract(player_pos, 2) local pos1 = vector.add(player_pos, 2) - local positions = minetest.find_nodes_in_area(pos0, pos1, "default:sign_wall_steel") + local positions = minetest.find_nodes_in_area(pos0, pos1, sign) local found = false if #positions <= 0 then @@ -158,7 +158,7 @@ minetest.register_craftitem("x_marketplace:head", { if pointed_thing.type == "node" then local node = minetest.get_node(pointed_thing.under) - if node.name == "default:sign_wall_steel" then + if node.name == "x_marketplace:sign_wall_bones" then local node_meta = minetest.get_meta(pointed_thing.under) if node_meta:get_string("text"):trim() == "/mp sellhead" then @@ -189,11 +189,12 @@ minetest.register_craftitem("x_marketplace:head", { end end + + else + minetest.chat_send_player(user:get_player_name(), minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: If you want to sell the head, you have to punch steel sign with text '/mp sellhead' on it.")) end end - minetest.chat_send_player(user:get_player_name(), minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: If you want to sell the head, you have to punch steel sign with text '/mp sellhead' on it.")) - return itemstack end, }) diff --git a/chatcommands.lua b/chatcommands.lua index e8323ad..c82690d 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -55,10 +55,10 @@ minetest.register_chatcommand("mp", { local player = minetest.get_player_by_name(caller) local player_pos = player:get_pos() - local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp sell") + local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp sell", "x_marketplace:sign_wall_mese") if not find_signs then - return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no steel signs around you with text '/mp sell' on them. Transaction cancelled.") + return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no Mese Signs around you with text '/mp sell' on them. Transaction cancelled.") end local hand = player:get_wielded_item() @@ -134,10 +134,10 @@ minetest.register_chatcommand("mp", { elseif params[1] == "buyhand" then local player = minetest.get_player_by_name(caller) - local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp buy") + local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp buy", "x_marketplace:sign_wall_diamond") if not find_signs then - return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no steel signs around you with text '/mp buy' on them. Transaction cancelled.") + return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no Diamond Signs around you with text '/mp buy' on them. Transaction cancelled.") end local hand = player:get_wielded_item() @@ -212,10 +212,10 @@ minetest.register_chatcommand("mp", { end local player = minetest.get_player_by_name(caller) - local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp sell") + local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp sell", "x_marketplace:sign_wall_mese") if not find_signs then - return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no steel signs around you with text '/mp sell' on them. Transaction cancelled.") + return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no Mese Signs around you with text '/mp sell' on them. Transaction cancelled.") end local store_item = x_marketplace.store_list[params[2]] @@ -281,10 +281,10 @@ minetest.register_chatcommand("mp", { end local player = minetest.get_player_by_name(caller) - local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp buy") + local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp buy", "x_marketplace:sign_wall_diamond") if not find_signs then - return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no steel signs around you with text '/mp buy' on them. Transaction cancelled.") + return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no Diamond Signs around you with text '/mp buy' on them. Transaction cancelled.") end local store_item = x_marketplace.store_list[params[2]] @@ -345,10 +345,10 @@ minetest.register_chatcommand("mp", { end local player = minetest.get_player_by_name(caller) - local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp buy") + local find_signs = x_marketplace.find_signs(player:get_pos(), "/mp buy", "x_marketplace:sign_wall_diamond") if not find_signs then - return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no steel signs around you with text '/mp buy' on them. Transaction cancelled.") + return false, minetest.colorize(x_marketplace.colors.yellow, "MARKET PLACE: There are no Diamond Signs around you with text '/mp buy' on them. Transaction cancelled.") end -- item not in store diff --git a/depends.txt b/depends.txt index e69de29..331d858 100644 --- a/depends.txt +++ b/depends.txt @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/init.lua b/init.lua index 1d7446d..5d7cf49 100644 --- a/init.lua +++ b/init.lua @@ -15,5 +15,6 @@ local path = minetest.get_modpath("x_marketplace") dofile(path.."/store_list.lua") dofile(path.."/api.lua") dofile(path.."/chatcommands.lua") +dofile(path.."/nodes.lua") print ("[Mod] x_marketplace loaded") diff --git a/nodes.lua b/nodes.lua new file mode 100644 index 0000000..8282c7e --- /dev/null +++ b/nodes.lua @@ -0,0 +1,159 @@ +-- +-- Bones sign (sellhead) +-- +minetest.register_node("x_marketplace:sign_wall_bones", { + description = "Bones Sign - write '/mp sellhead' to sell heads", + drawtype = "nodebox", + tiles = {"x_marketplace_sign_wall_bones.png"}, + inventory_image = "x_marketplace_sign_bones.png", + wield_image = "x_marketplace_sign_bones.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + node_box = { + type = "wallmounted", + wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125}, + wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, + wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}, + }, + groups = {crumbly = 2}, + sounds = default.node_sound_gravel_defaults(), + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "field[text;;${text}]") + end, + on_receive_fields = function(pos, formname, fields, sender) + --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) + local player_name = sender:get_player_name() + if minetest.is_protected(pos, player_name) then + minetest.record_protection_violation(pos, player_name) + return + end + local meta = minetest.get_meta(pos) + if not fields.text then return end + minetest.log("action", (player_name or "") .. " wrote \"" .. + fields.text .. "\" to sign at " .. minetest.pos_to_string(pos)) + meta:set_string("text", fields.text) + meta:set_string("infotext", '"' .. fields.text .. '"') + end, +}) + +-- +-- Mese sign (sell) +-- +minetest.register_node("x_marketplace:sign_wall_mese", { + description = "Mese Sign - write '/mp sell' to sell to marketplace", + drawtype = "nodebox", + tiles = {"x_marketplace_sign_wall_mese.png"}, + inventory_image = "x_marketplace_sign_mese.png", + wield_image = "x_marketplace_sign_mese.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + node_box = { + type = "wallmounted", + wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125}, + wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, + wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}, + }, + groups = {cracky = 1, level = 2}, + sounds = default.node_sound_stone_defaults(), + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "field[text;;${text}]") + end, + on_receive_fields = function(pos, formname, fields, sender) + --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) + local player_name = sender:get_player_name() + if minetest.is_protected(pos, player_name) then + minetest.record_protection_violation(pos, player_name) + return + end + local meta = minetest.get_meta(pos) + if not fields.text then return end + minetest.log("action", (player_name or "") .. " wrote \"" .. + fields.text .. "\" to sign at " .. minetest.pos_to_string(pos)) + meta:set_string("text", fields.text) + meta:set_string("infotext", '"' .. fields.text .. '"') + end, +}) + +-- +-- Diamond sign (buy) +-- +minetest.register_node("x_marketplace:sign_wall_diamond", { + description = "Diamond Sign - write '/mp buy' to buy from marketplace", + drawtype = "nodebox", + tiles = {"x_marketplace_sign_wall_diamond.png"}, + inventory_image = "x_marketplace_sign_diamond.png", + wield_image = "x_marketplace_sign_diamond.png", + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + is_ground_content = false, + walkable = false, + node_box = { + type = "wallmounted", + wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125}, + wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, + wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375}, + }, + groups = {cracky = 1, level = 3}, + sounds = default.node_sound_stone_defaults(), + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "field[text;;${text}]") + end, + on_receive_fields = function(pos, formname, fields, sender) + --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) + local player_name = sender:get_player_name() + if minetest.is_protected(pos, player_name) then + minetest.record_protection_violation(pos, player_name) + return + end + local meta = minetest.get_meta(pos) + if not fields.text then return end + minetest.log("action", (player_name or "") .. " wrote \"" .. + fields.text .. "\" to sign at " .. minetest.pos_to_string(pos)) + meta:set_string("text", fields.text) + meta:set_string("infotext", '"' .. fields.text .. '"') + end, +}) + +-- +-- CRAFTING +-- + +minetest.register_craft({ + output = "x_marketplace:sign_wall_bones", + recipe = { + {"bones:bones", "bones:bones", "bones:bones"}, + {"bones:bones", "bones:bones", "bones:bones"}, + {"", "group:stick", ""}, + } +}) + +minetest.register_craft({ + output = "x_marketplace:sign_wall_mese", + recipe = { + {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"}, + {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"}, + {"", "group:stick", ""}, + } +}) + +minetest.register_craft({ + output = "x_marketplace:sign_wall_diamond", + recipe = { + {"default:diamond", "default:diamond", "default:diamond"}, + {"default:diamond", "default:diamond", "default:diamond"}, + {"", "group:stick", ""}, + } +}) \ No newline at end of file diff --git a/textures/x_marketplace_sign_bones.png b/textures/x_marketplace_sign_bones.png new file mode 100644 index 0000000..4673b75 Binary files /dev/null and b/textures/x_marketplace_sign_bones.png differ diff --git a/textures/x_marketplace_sign_diamond.png b/textures/x_marketplace_sign_diamond.png new file mode 100644 index 0000000..a019b9c Binary files /dev/null and b/textures/x_marketplace_sign_diamond.png differ diff --git a/textures/x_marketplace_sign_mese.png b/textures/x_marketplace_sign_mese.png new file mode 100644 index 0000000..9d9856c Binary files /dev/null and b/textures/x_marketplace_sign_mese.png differ diff --git a/textures/x_marketplace_sign_wall_bones.png b/textures/x_marketplace_sign_wall_bones.png new file mode 100644 index 0000000..fde72bd Binary files /dev/null and b/textures/x_marketplace_sign_wall_bones.png differ diff --git a/textures/x_marketplace_sign_wall_diamond.png b/textures/x_marketplace_sign_wall_diamond.png new file mode 100644 index 0000000..cd17458 Binary files /dev/null and b/textures/x_marketplace_sign_wall_diamond.png differ diff --git a/textures/x_marketplace_sign_wall_mese.png b/textures/x_marketplace_sign_wall_mese.png new file mode 100644 index 0000000..0b3e741 Binary files /dev/null and b/textures/x_marketplace_sign_wall_mese.png differ