nc_ctf/node.lua

132 lines
3.3 KiB
Lua
Raw Normal View History

2019-12-13 18:44:55 +01:00
-- LUALOCALS < ---------------------------------------------------------
2019-12-17 14:54:17 +01:00
local nodecore, minetest
= nodecore, minetest
2019-12-13 18:44:55 +01:00
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local function reg(name,color)
minetest.register_node(modname..":crystal_"..name,{
drawtype = "mesh",
paramtype = "light",
2019-12-13 18:44:55 +01:00
sunlight_propagates = true,
light_source = 14,
2019-12-31 10:25:41 +01:00
mesh = "nc_ctf_crystal.obj",
2019-12-13 18:44:55 +01:00
groups = {crystal = 1,cracky=4,falling_node = 1},
2019-12-31 10:25:41 +01:00
selection_box = {
type = "fixed",
fixed = {
{-0.3,-0.5,-0.3, 0.3,0.5,0.3},
}
},
2019-12-13 18:44:55 +01:00
tiles = {
{name = "(nc_ctf_crystal_base.png^[multiply:"..color..")^nc_ctf_crystal_shine.png",
animation={
type = "vertical_frames",
aspect_w = 64,
aspect_h = 64,
length = 1,
2019-12-13 18:44:55 +01:00
}
}
},
sounds = nodecore.sounds("nc_optics_glassy")
})
nodecore.register_ambiance({
label = "Crystal Ambiance",
nodenames = {modname..":crystal_"..name},
interval = 4,
chance = 4,
sound_name = "nc_ctf_weird",
check = function(pos)
return {gain = 1,pos=pos}
end
})
end
function ctf.crystals(teams)
for name, team in pairs(teams) do
reg(name,team.colorstr)
for name2, team2 in pairs(teams) do
if name2 ~= name then
local function after()
local team1,team2 = ctf.teams[name],ctf.teams[name2]
team1.score = team1.score-1
team2.score = team2.score+1
ctf.check_win()
end
nodecore.register_craft({
label = "claim crystal",
nodes = {
{match = modname .. ":crystal_"..name, replace = modname..":crystal_"..name2},
{x = 1, match = modname .. ":crystal_"..name2}
},
after = after
})
nodecore.register_craft({
label = "claim crystal",
nodes = {
{match = modname .. ":crystal_"..name, replace = modname..":crystal_"..name2},
{y = 1, match = modname .. ":crystal_"..name2}
},
after = after
})
nodecore.register_craft({
label = "claim crystal",
nodes = {
{match = modname .. ":crystal_"..name, replace = modname..":crystal_"..name2},
{y = -1, match = modname .. ":crystal_"..name2}
},
after = after
})
end
end
end
end
2019-12-17 14:54:17 +01:00
minetest.register_node(modname..":telebarrier",{
light_source = 14,
paramtype = "light",
2019-12-17 14:54:17 +01:00
drawtype="normal",
2019-12-20 19:36:26 +01:00
pointable = false,
2019-12-17 14:54:17 +01:00
tiles = {
{name = "nc_ctf_telebarrier.png",
animation={
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
2019-12-22 14:07:30 +01:00
length = 3,
},
align_style = "world",
scale=16
2019-12-17 14:54:17 +01:00
}
},
})
minetest.register_node(modname..":barrier",{
light_source = 14,
paramtype = "light",
drawtype="normal",
2019-12-20 19:36:26 +01:00
pointable = false,
2019-12-22 14:07:30 +01:00
use_texture_alpha=true,
tiles = {
{name = "nc_ctf_barrier.png",
animation={
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3,
2019-12-22 14:07:30 +01:00
},
align_style = "world",
scale=16
}
},
2019-12-17 14:54:17 +01:00
})
local bar, tbar = modname..":barrier",modname..":telebarrier"