Auke Kok 80cbd6d34a Add license headers to all lua files.
Some of these are copies from the respective origins from mtg,
to make sure we have headers everywhere listing the proper code.

I've relicensed spectator_mode from WT*PL to LGPL-2.1. No other
licenses were changed.
2018-06-21 22:56:48 -07:00

74 lines
2.2 KiB
Lua

--[[
Fences - from minetest_game
GNU Lesser General Public License, version 2.1
Copyright (C) 2011-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2011-2016 Various Minetest developers and contributors
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details:
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
]]--
fences = {}
function fences.register_fence(name, def)
local fence_texture = "default_fence_overlay.png^" .. def.texture ..
"^default_fence_overlay.png^[makealpha:255,126,126"
-- Allow almost everything to be overridden
local default_fields = {
paramtype = "light",
drawtype = "nodebox",
node_box = {
type = "connected",
fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
{-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
{-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
{-1/16,-5/16,1/8,1/16,-3/16,1/2}},
connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
{1/8,-5/16,-1/16,1/2,-3/16,1/16}},
},
collision_box = {
type = "connected",
fixed = {{-1/8, -1/2, -1/8, 1/8, 1, 1/8}},
connect_front = {{-1/8,-1/2,-1/2,1/8,1,-1/8}},
connect_left = {{-1/2,-1/2,-1/8,-1/8,1,1/8}},
connect_back = {{-1/8,-1/2,1/8,1/8,1,1/2}},
connect_right = {{1/8,-1/2,-1/8,1/2,1,1/8}},
},
connects_to = {"group:fence", "group:wood"},
inventory_image = fence_texture,
wield_image = fence_texture,
tiles = {def.texture},
sunlight_propagates = true,
is_ground_content = false,
groups = def.groups or {},
}
for k, v in pairs(default_fields) do
if not def[k] then
def[k] = v
end
end
-- Always add to the fence group, even if no group provided
def.groups.fence = 1
def.texture = nil
def.material = nil
minetest.register_node(name, def)
end