new signs for marketplace
parent
5abd113f8f
commit
ff20bb6194
11
api.lua
11
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,10 +189,11 @@ minetest.register_craftitem("x_marketplace:head", {
|
|||
end
|
||||
|
||||
end
|
||||
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
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
default
|
1
init.lua
1
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")
|
||||
|
|
|
@ -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", ""},
|
||||
}
|
||||
})
|
Binary file not shown.
After Width: | Height: | Size: 250 B |
Binary file not shown.
After Width: | Height: | Size: 248 B |
Binary file not shown.
After Width: | Height: | Size: 157 B |
Binary file not shown.
After Width: | Height: | Size: 281 B |
Binary file not shown.
After Width: | Height: | Size: 316 B |
Binary file not shown.
After Width: | Height: | Size: 167 B |
Loading…
Reference in New Issue