Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/submodules/mods/ctf/ctf_map/map…
Browse files Browse the repository at this point in the history
…s-a7bb69d
  • Loading branch information
LoneWolfHT authored Dec 6, 2024
2 parents f2ab4f7 + 6e85bb1 commit aaab43f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
22 changes: 12 additions & 10 deletions mods/apis/ctf_settings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ minetest.register_on_mods_loaded(function()
end

if settingdef.type == "bool" then
lastypos = lastypos + 0.2

setting_list[k] = {
"checkbox[0,%f;%s;%s;%s]tooltip[%s;%s]",
"checkbox[0.1,%f;%s;%s;%s]tooltip[%s;%s]",
lastypos,
setting,
settingdef.label or setting,
Expand All @@ -101,11 +103,11 @@ minetest.register_on_mods_loaded(function()
max_len = math.max(val:len(), max_len)
end

lastypos = lastypos + 0.3
lastypos = lastypos + 0.5
setting_list[k] = {
"dropdown[0,%f;%f;%s;%s;%d]tooltip[0,%f;%f,0.6;%s]",
"dropdown[0.1,%f;%f;%s;%s;%d]tooltip[0,%f;%f,0.6;%s]",
lastypos,
math.max(FORMSIZE.x / 2, math.min(FORMSIZE.x - SCROLLBAR_W + 2, 0.5 + (max_len * 0.23))),
math.min(FORMSIZE.x * 2/3, math.max(FORMSIZE.x - SCROLLBAR_W + 2, 0.5 + (max_len * 0.23))),
setting,
settingdef.list,
context.setting[setting],
Expand All @@ -114,13 +116,13 @@ minetest.register_on_mods_loaded(function()
(FORMSIZE.x/1.7) - 0.3,
settingdef.description or HumanReadable(setting),
}
lastypos = lastypos + 0.6
lastypos = lastypos + 0.5
elseif settingdef.type == "bar" then
lastypos = lastypos + 0.7
lastypos = lastypos + 0.9
setting_list[k] = {
"label[0,%f;%s: %d%%]"..
"label[0.1,%f;%s: %d%%]"..
"scrollbaroptions[min=%d;max=%d;smallstep=%d]"..
"scrollbar[0,%f;%f,0.4;horizontal;%s;%s]",
"scrollbar[0.1,%f;%f,0.4;horizontal;%s;%s]",
lastypos - 0.5,
settingdef.label or HumanReadable(setting),
(
Expand All @@ -144,11 +146,11 @@ minetest.register_on_mods_loaded(function()
{"box[-0.1,-0.1;%f,%f;#00000055]", FORMSIZE.x - SCROLLBAR_W, FORMSIZE.y},
{"scroll_container[-0.1,0.3;%f,%f;settings_scrollbar;vertical;0.1]",
FORMSIZE.x - SCROLLBAR_W + 2,
FORMSIZE.y + 0.7
FORMSIZE.y + 1
},
ctf_gui.list_to_formspec_str(setting_list),
"scroll_container_end[]",
make_scrollbaroptions_for_scroll_container(FORMSIZE.y + 0.7, math.max(lastypos+1, FORMSIZE.y + 0.7), 0.1),
make_scrollbaroptions_for_scroll_container(FORMSIZE.y-2, math.max(lastypos, FORMSIZE.y-2), 0.1),
{"scrollbar[%f,-0.1;%f,%f;vertical;settings_scrollbar;%f]",
FORMSIZE.x - SCROLLBAR_W,
SCROLLBAR_W,
Expand Down
16 changes: 9 additions & 7 deletions mods/ctf/ctf_landmine/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ local landmines = {
}

local number_of_landmines = 0
local ARMING_TIME = 3

local add_landmine = function(pos)
landmines[core.hash_node_position(pos)] = true
landmines[core.hash_node_position(pos)] = os.clock()
number_of_landmines = number_of_landmines + 1
end

Expand All @@ -16,7 +17,7 @@ local clear_landmines = function()
end

local remove_landmine = function(pos)
landmines[core.hash_node_position(pos)] = false
landmines[core.hash_node_position(pos)] = nil
number_of_landmines = number_of_landmines - 1
end

Expand Down Expand Up @@ -107,7 +108,7 @@ local function landmine_explode(pos)
end

core.register_node("ctf_landmine:landmine", {
description = "Landmine",
description = string.format("Landmine (%ds arming time)", ARMING_TIME),
drawtype = "nodebox",
tiles = {
"ctf_landmine_landmine.png",
Expand Down Expand Up @@ -141,9 +142,9 @@ core.register_node("ctf_landmine:landmine", {
end
end,
on_dig = function(pos, node, digger)
remove_landmine(pos)
minetest.node_dig(pos, node, digger)
end
remove_landmine(pos)
minetest.node_dig(pos, node, digger)
end
})

core.register_globalstep(function(dtime)
Expand All @@ -170,8 +171,9 @@ core.register_globalstep(function(dtime)
vector.add(pos, { x = 0, y = 1, z = 0}),
}

local current = os.clock()
for _idx2, pos2 in ipairs(positions_to_check) do
if landmines[core.hash_node_position(pos2)] then
if current - (landmines[core.hash_node_position(pos2)] or current) >= ARMING_TIME then
if not is_self_landmine(obj, pos2) then
landmine_explode(pos2)
end
Expand Down
6 changes: 3 additions & 3 deletions mods/ctf/ctf_modebase/crafting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ crafting.register_recipe({
})

crafting.register_recipe({
output = "ctf_map:damage_cobble",
items = { "ctf_map:unwalkable_cobble", "ctf_map:spike" },
output = "ctf_map:damage_cobble 5",
items = { "default:cobble 5", "ctf_map:spike" },
always_known = false,
})

Expand All @@ -175,7 +175,7 @@ crafting.register_recipe({
})

crafting.register_recipe({
output = "ctf_landmine:landmine",
output = "ctf_landmine:landmine 3",
items = { "default:steel_ingot 4", "grenades:frag" },
always_known = false,
})
9 changes: 8 additions & 1 deletion mods/other/throwable_snow/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ throwable_snow = {}
local S = minetest.get_translator(minetest.get_current_modname())

function throwable_snow.on_hit_player(thrower, player)
minetest.get_player_by_name(player):punch(
minetest.get_player_by_name(thrower),
2,
{ damage_groups = {snowball = 1, fleshy = 1} },
vector.new()
)

hud_events.new(player, {
text = S("@1 hit you with a snowball!", thrower),
quick = true,
Expand Down Expand Up @@ -44,7 +51,7 @@ local snowball_def = {
end,
on_collide = function(def, obj, name, moveresult)
for _, collision in ipairs(moveresult.collisions) do
if collision.type == "object" and collision.object:is_player() then
if collision.type == "object" and collision.object:is_player() and minetest.get_player_by_name(name) then
throwable_snow.on_hit_player(name, collision.object:get_player_name())
end
end
Expand Down

0 comments on commit aaab43f

Please sign in to comment.