diff --git a/mods/chatplus/init.lua b/mods/chatplus/init.lua index 9ae5667..af82f33 100644 --- a/mods/chatplus/init.lua +++ b/mods/chatplus/init.lua @@ -158,7 +158,7 @@ function chatplus.send(from, msg) for i=1, #chatplus._handlers do if chatplus._handlers[i] then res = chatplus._handlers[i](from,key,msg) - + if res ~= nil then break end diff --git a/mods/ctf_barrier/init.lua b/mods/ctf_barrier/init.lua index 5964648..a15359c 100644 --- a/mods/ctf_barrier/init.lua +++ b/mods/ctf_barrier/init.lua @@ -7,21 +7,45 @@ minetest.register_node("ctf_barrier:ind_glass", { sunlight_propagates = true, is_ground_content = false, walkable = true, + buildable_to = false, + pointable = false, groups = {immortal = 1}, sounds = default.node_sound_glass_defaults() }) + +minetest.register_node("ctf_barrier:ind_glass_red", { + description = "You cheater you!", + drawtype = "glasslike", + tiles = {"ctf_barrier_red.png"}, + inventory_image = minetest.inventorycube("default_glass.png"), + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + walkable = true, + buildable_to = false, + use_texture_alpha = false, + alpha = 0, + pointable = false, + groups = {immortal = 1}, + sounds = default.node_sound_glass_defaults() +}) + local lim = ctf.setting("match.map_reset_limit") local c_glass = minetest.get_content_id("ctf_barrier:ind_glass") +local c_glass_red = minetest.get_content_id("ctf_barrier:ind_glass_red") +local c_water = minetest.get_content_id("default:water_source") +local c_water_f = minetest.get_content_id("default:water_flowing") local c_stone = minetest.get_content_id("ctf_flag:ind_base") local c_air = minetest.get_content_id("air") local r = tonumber(minetest.setting_get("barrier")) minetest.register_on_generated(function(minp, maxp, seed) - if not ((minp.x < -r and maxp.x > -r) - or (minp.x < r and maxp.x > r) - or (minp.y < -r and maxp.x > -r) - or (minp.y < r and maxp.x > r) - or (minp.z < -r and maxp.z > -r) - or (minp.z < r and maxp.z > r)) then + if not ((minp.x <= -r and maxp.x >= -r) + or (minp.x <= r and maxp.x >= r) + or (minp.y <= -r and maxp.x >= -r) + or (minp.y <= r and maxp.x >= r) + or (minp.z <= -r and maxp.z >= -r) + or (minp.z <= 0 and maxp.z >= 0) + or (minp.z <= r and maxp.z >= r and ctf_match.build_timer > 0)) then return end @@ -33,10 +57,9 @@ minetest.register_on_generated(function(minp, maxp, seed) MaxEdge={x=emax.x, y=emax.y, z=emax.z}, } local data = vm:get_data() - local dist = 3 -- Left - if minp.x < -r and maxp.x > -r then + if minp.x <= -r and maxp.x >= -r then local x = -r for z = minp.z, maxp.z do for y = minp.y, maxp.y do @@ -52,7 +75,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end -- Right - if minp.x < r and maxp.x > r then + if minp.x <= r and maxp.x >= r then local x = r for z = minp.z, maxp.z do for y = minp.y, maxp.y do @@ -67,7 +90,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end -- Front - if minp.z < -r and maxp.z > -r then + if minp.z <= -r and maxp.z >= -r then local z = -r for x = minp.x, maxp.x do for y = minp.y, maxp.y do @@ -82,7 +105,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end -- Back - if minp.z < r and maxp.z > r then + if minp.z <= r and maxp.z >= r then local z = r for x = minp.x, maxp.x do for y = minp.y, maxp.y do @@ -96,6 +119,73 @@ minetest.register_on_generated(function(minp, maxp, seed) end end + -- Barrier + if minp.z <= 0 and maxp.z >= 0 and ctf_match.build_timer > 0 then + local z = 0 + local x1 = minp.x + if x1 < -r then x1 = -r end + local x2 = maxp.x + if x2 > r then x2 = r end + for x = x1, x2 do + for y = minp.y, maxp.y do + local vi = a:index(x, y, z) + local node = data[vi] + if node == c_air or node == c_glass_red or + node == c_water or node == c_water_f then + data[vi] = c_glass_red + end + end + end + end + vm:set_data(data) vm:write_to_map(data) end) + +ctf_match.register_on_build_time_end(function() + local min = { + x = -r + 1, + y = -r, + z = -1 + } + local max = { + x = r - 1, + y = r, + z = 1 + } + + local vm = minetest.get_voxel_manip() + local emin, emax = vm:read_from_map(min, max) + local a = VoxelArea:new{ + MinEdge = emin, + MaxEdge = emax + } + local data = vm:get_data() + for x = min.x, max.x do + for y = min.y, max.y do + local vi = a:index(x, y, 0) + if data[vi] == c_glass_red then + data[vi] = c_air + end + end + end + + print(n .. " invalid nodes out of " .. t .. " (" .. (t-n) .. " valid)") + + vm:set_data(data) + vm:write_to_map(data) + vm:update_map() +end) + +--[[minetest.register_abm({ + nodenames = {"ctf_barrier:ind_glass_red"}, + interval = 10.0, -- Run every 10 seconds + chance = 2, -- Select every 1 in 50 nodes + action = function(pos, node, active_object_count, active_object_count_wider) + if ctf_match.build_timer > 0 then + return + end + + minetest.set_node(pos, {name = "air"}) + end +})]] diff --git a/mods/ctf_barrier/textures/ctf_barrier_red.png b/mods/ctf_barrier/textures/ctf_barrier_red.png new file mode 100644 index 0000000..4bf11fe Binary files /dev/null and b/mods/ctf_barrier/textures/ctf_barrier_red.png differ diff --git a/mods/ctf_match/buildtime.lua b/mods/ctf_match/buildtime.lua new file mode 100644 index 0000000..c9bdb28 --- /dev/null +++ b/mods/ctf_match/buildtime.lua @@ -0,0 +1,56 @@ +ctf.register_on_init(function() + ctf._set("match.build_time", 10) +end) + +ctf_match.registered_on_build_time_start = {} +function ctf_match.register_on_build_time_start(func) + if ctf._mt_loaded then + error("You can't register callbacks at game time!") + end + table.insert(ctf_match.registered_on_build_time_start, func) +end + +ctf_match.registered_on_build_time_end = {} +function ctf_match.register_on_build_time_end(func) + if ctf._mt_loaded then + error("You can't register callbacks at game time!") + end + table.insert(ctf_match.registered_on_build_time_end, func) +end + +ctf_match.build_timer = 0 + +function ctf_match.is_in_build_time() + return ctf_match.build_timer > 0 +end + +ctf.register_on_new_game(function() + ctf_match.build_timer = ctf.setting("match.build_time") + if ctf_match.build_timer > 0 then + for i = 1, #ctf_match.registered_on_build_time_start do + ctf_match.registered_on_build_time_start[i]() + end + end +end) + +minetest.register_globalstep(function(delta) + if ctf_match.build_timer > 0 then + ctf_match.build_timer = ctf_match.build_timer - delta + if ctf_match.build_timer <= 0 then + for i = 1, #ctf_match.registered_on_build_time_end do + ctf_match.registered_on_build_time_end[i]() + end + end + end +end) + +ctf_match.register_on_build_time_start(function() + minetest.chat_send_all("Prepare your base! Match starts in " .. + ctf.setting("match.build_time") .. " seconds.") + minetest.setting_set("enable_pvp", "false") +end) + +ctf_match.register_on_build_time_end(function() + minetest.chat_send_all("Build time over! Attack and defend!") + minetest.setting_set("enable_pvp", "true") +end) diff --git a/mods/ctf_match/init.lua b/mods/ctf_match/init.lua index 1e5140a..f052e0b 100644 --- a/mods/ctf_match/init.lua +++ b/mods/ctf_match/init.lua @@ -6,6 +6,7 @@ for i, flag in pairs(claimed) do end dofile(minetest.get_modpath("ctf_match") .. "/matches.lua") +dofile(minetest.get_modpath("ctf_match") .. "/buildtime.lua") dofile(minetest.get_modpath("ctf_match") .. "/reset.lua") dofile(minetest.get_modpath("ctf_match") .. "/chat.lua") dofile(minetest.get_modpath("ctf_match") .. "/vote.lua") diff --git a/mods/ctf_match/matches.lua b/mods/ctf_match/matches.lua index b0cfd4e..e158025 100644 --- a/mods/ctf_match/matches.lua +++ b/mods/ctf_match/matches.lua @@ -6,8 +6,21 @@ ctf.register_on_init(function() ctf._set("match.clear_inv", false) end) +ctf_match.registered_on_new_match = {} +function ctf_match.register_on_new_match(func) + if ctf._mt_loaded then + error("You can't register callbacks at game time!") + end + table.insert(ctf_match.registered_on_new_match, func) +end + + -- Load next match. May be overrided function ctf_match.next() + for i = 1, #ctf_match.registered_on_new_match do + ctf_match.registered_on_new_match[i]() + end + ctf.reset() -- Note: ctf.reset calls register_on_new_game, below. end diff --git a/mods/ctf_pvp_engine b/mods/ctf_pvp_engine index b16d5c3..e672344 160000 --- a/mods/ctf_pvp_engine +++ b/mods/ctf_pvp_engine @@ -1 +1 @@ -Subproject commit b16d5c3b6589a88e04e4a0b914873638e489285c +Subproject commit e672344383aeb9bea2a5b21f79ad66219db03116 diff --git a/mods/tsm_chests_example/init.lua b/mods/tsm_chests_example/init.lua index e04ccc2..d978f26 100644 --- a/mods/tsm_chests_example/init.lua +++ b/mods/tsm_chests_example/init.lua @@ -157,6 +157,9 @@ minetest.register_on_generated(function(minp, maxp, seed) if ground~=nil then local chest_pos = {x=pos.x,y=ground+1, z=pos.z} + if chest_pos.z == 0 then + chest_pos.z = -1 + end local nn = minetest.get_node(chest_pos).name -- chest node name (before it becomes a chest) if nn == "air" or nn == "default:water_source" then -->>>> chest spawning starts here <<<<-- diff --git a/settings_cache.csv b/settings_cache.csv index 9691540..384386b 100644 --- a/settings_cache.csv +++ b/settings_cache.csv @@ -29,7 +29,7 @@ "match.break_alliances" true "match.clear_inv" true "match.destroy_team" true -"match.map_reset_limit" 60 +"match.map_reset_limit" 200 "match.remove_player_on_leave" true "match.teams" "red, red, 15, 7, 39; blue, blue, -9, 9, -43" "maximum_in_team" -1