Skip to content

Instantly share code, notes, and snippets.

@HybridDog
Created October 2, 2015 15:38
Show Gist options
  • Save HybridDog/1d7b19e440c24322026a to your computer and use it in GitHub Desktop.
Save HybridDog/1d7b19e440c24322026a to your computer and use it in GitHub Desktop.
local function inform_near_players(pos, msg)
for _,player in pairs(minetest.get_objects_inside_radius(pos, 10)) do
if player:is_player() then
minetest.chat_send_player(player:get_player_name(), msg)
end
end
end
function apn(pos, placer, itemstack)
local grop = minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "myuno")
if group > 3 then
return
end
local name = placer:get_player_name()
if grop == 0 then
minetest.chat_send_player(name, "You can not place a card there!")
minetest.remove_node(pos)
return itemstack
end
local node = minetest.get_node(pos)
local descr = minetest.registered_items[node.name].description
if grop == 1 then
inform_near_players(pos, name.." placed a "..descr)
return
end
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, node)
minetest.remove_node(pos)
if grop == 3 then
return itemstack
end
inform_near_players(pos, name.." placed a "..descr)
end
@DonBatman
Copy link

Thanks for this. I tried it out. Seems to work great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment