Compare commits
No commits in common. "62e0fe449e6e8be86846f24a2fe403c2dc817462" and "efbe6dc7b4d21c8ee185eabc561334d473bd66bc" have entirely different histories.
62e0fe449e
...
efbe6dc7b4
5 changed files with 7 additions and 211 deletions
|
@ -29,12 +29,12 @@ end, true)
|
||||||
|
|
||||||
|
|
||||||
local sword_special_timer = {}
|
local sword_special_timer = {}
|
||||||
local SWORD_SPECIAL_COOLDOWN = 20
|
local SWORD_SPECIAL_COOLDOWN = 40
|
||||||
local function sword_special_timer_func(pname, timeleft)
|
local function sword_special_timer_func(pname, timeleft)
|
||||||
sword_special_timer[pname] = timeleft
|
sword_special_timer[pname] = timeleft
|
||||||
|
|
||||||
if timeleft - 2 >= 0 then
|
if timeleft - 10 >= 0 then
|
||||||
minetest.after(2, sword_special_timer_func, pname, timeleft - 2)
|
minetest.after(10, sword_special_timer_func, pname, timeleft - 10)
|
||||||
else
|
else
|
||||||
sword_special_timer[pname] = nil
|
sword_special_timer[pname] = nil
|
||||||
end
|
end
|
||||||
|
@ -57,8 +57,8 @@ minetest.register_tool("ctf_classes:sword_bronze", {
|
||||||
local pname = placer:get_player_name()
|
local pname = placer:get_player_name()
|
||||||
if not pointed_thing then return end
|
if not pointed_thing then return end
|
||||||
|
|
||||||
if sword_special_timer[pname] and placer:get_player_control().sneak then
|
if sword_special_timer[pname] then
|
||||||
minetest.chat_send_player(pname, "You have to wait "..sword_special_timer[pname].."s to place marker again")
|
minetest.chat_send_player(pname, "You can't place a marker yet (>"..sword_special_timer[pname].."s left)")
|
||||||
|
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||||
|
@ -102,8 +102,8 @@ minetest.register_tool("ctf_classes:sword_bronze", {
|
||||||
-- Check if player is sneaking before placing marker
|
-- Check if player is sneaking before placing marker
|
||||||
if not placer:get_player_control().sneak then return end
|
if not placer:get_player_control().sneak then return end
|
||||||
|
|
||||||
sword_special_timer[pname] = 4
|
sword_special_timer[pname] = 20
|
||||||
sword_special_timer_func(pname, 4)
|
sword_special_timer_func(pname, 20)
|
||||||
|
|
||||||
minetest.registered_chatcommands["m"].func(pname, "placed with sword")
|
minetest.registered_chatcommands["m"].func(pname, "placed with sword")
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -424,25 +424,6 @@ do
|
||||||
sounds = default.node_sound_leaves_defaults()
|
sounds = default.node_sound_leaves_defaults()
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(":ctf_map:papyrus", {
|
|
||||||
description = "Indestructible Papyrus",
|
|
||||||
drawtype = "plantlike",
|
|
||||||
tiles = {"default_papyrus.png"},
|
|
||||||
inventory_image = "default_papyrus.png",
|
|
||||||
wield_image = "default_papyrus.png",
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
|
|
||||||
},
|
|
||||||
groups = {immortal = 1},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
after_dig_node = function(pos, node, metadata, digger)
|
|
||||||
default.dig_up(pos, node, digger)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(":ctf_map:jungletree", {
|
minetest.register_node(":ctf_map:jungletree", {
|
||||||
description = "Indestructible Jungle Tree",
|
description = "Indestructible Jungle Tree",
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
# `hud_events`
|
|
||||||
|
|
||||||
Forked and edited from `hud_score` by ANAND (ClobberXD), licensed under the LGPLv2.1+ license.
|
|
||||||
|
|
||||||
`hud_events` provides an API to display HUD event elements which can be used to
|
|
||||||
display various hints and messages.
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
- `hud_event.new(name, event_def)`: Adds a new HUD event element to player `name`.
|
|
||||||
- `name` [string]: Player name
|
|
||||||
- `event_def` [table]: HUD event element definition. See below.
|
|
||||||
|
|
||||||
## HUD event element definition
|
|
||||||
|
|
||||||
HUD event element definition table, passed to `hud_event.new`.
|
|
||||||
|
|
||||||
Example definition:
|
|
||||||
|
|
||||||
```lua
|
|
||||||
{
|
|
||||||
name = "ctf_bandages:healing", -- Can be any arbitrary string
|
|
||||||
color = "0x00FF00", -- Should be compatible with Minetest's HUD def
|
|
||||||
value = "x has healed y", -- The actual event to be displayed
|
|
||||||
-- Field `time` is automatically added by `hud_event.new`
|
|
||||||
-- to keep track of element expiry
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## `players` table
|
|
||||||
|
|
||||||
This is a table of tables, indexed by player names. This table holds the HUD
|
|
||||||
data of all online players. Each sub-table is a list of HUD event elements,
|
|
||||||
which are added by `hud_event.new`.
|
|
||||||
|
|
||||||
```lua
|
|
||||||
local players = {
|
|
||||||
["name"] = {
|
|
||||||
[1] = <hud_event_element>,
|
|
||||||
[2] = <hud_event_element>,
|
|
||||||
[3] = <hud_event_element>
|
|
||||||
...
|
|
||||||
},
|
|
||||||
["name2"] = {
|
|
||||||
...
|
|
||||||
},
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Changes
|
|
||||||
|
|
||||||
Changes that have been made compared to the original `hud_score` mod. Lines mentioned underneath refer to the lines in the `hud_events`' init.lua file.
|
|
||||||
- replaced all occurences of `score` with `event` (10th March 2021)
|
|
||||||
- changed variables and arguments in the lines 5, 6 and 36 (10th march 2021)
|
|
||||||
- edited and added arguments in line 39 and 40 (10th march 2021)
|
|
||||||
- deleted an `if` statement after line 28 (10th march 2021)
|
|
|
@ -1,125 +0,0 @@
|
||||||
hud_event = {}
|
|
||||||
local hud = hudkit()
|
|
||||||
|
|
||||||
local players = {}
|
|
||||||
local duration = 7
|
|
||||||
local max = 3
|
|
||||||
local next_check = 10000000
|
|
||||||
|
|
||||||
local function update(name)
|
|
||||||
local player = minetest.get_player_by_name(name)
|
|
||||||
if not player then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Handle all elements marked for deletion
|
|
||||||
-- and rebuild table
|
|
||||||
local temp = {}
|
|
||||||
for _, def in ipairs(players[name]) do
|
|
||||||
if def.delete then
|
|
||||||
if hud:exists(player, def.name) then
|
|
||||||
hud:remove(player, def.name)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
table.insert(temp, def)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, def in ipairs(temp) do
|
|
||||||
local text = tostring(def.value)
|
|
||||||
if hud:exists(player, def.name) then
|
|
||||||
hud:change(player, def.name, "text", text)
|
|
||||||
hud:change(player, def.name, "offset", {x = 0, y = i * 20})
|
|
||||||
else
|
|
||||||
hud:add(player, def.name, {
|
|
||||||
hud_elem_type = "text",
|
|
||||||
alignment = {x = 0, y = 0},
|
|
||||||
position = {x = 0.5, y = 0.7},
|
|
||||||
offset = {x = 0, y = i * 20},
|
|
||||||
number = tonumber(def.color),
|
|
||||||
text = text,
|
|
||||||
z_index = -200
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
players[name] = temp
|
|
||||||
end
|
|
||||||
|
|
||||||
function hud_event.new(name, def)
|
|
||||||
-- Verify HUD event element def
|
|
||||||
if not name or not def or type(def) ~= "table" or
|
|
||||||
not def.name or not def.value or not def.color then
|
|
||||||
error("hud_event: Invalid HUD event element definition", 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
|
||||||
if not player then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Store element expiration time in def.time
|
|
||||||
-- and append event element def to players[name]
|
|
||||||
def.time = os.time() + duration
|
|
||||||
if next_check > duration then
|
|
||||||
next_check = duration
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If a HUD event element with the same name exists already,
|
|
||||||
-- reuse it instead of creating a new element
|
|
||||||
local is_new = true
|
|
||||||
for i, hud_event_spec in ipairs(players[name]) do
|
|
||||||
if hud_event_spec.name == def.name then
|
|
||||||
is_new = false
|
|
||||||
players[name][i] = def
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_new then
|
|
||||||
table.insert(players[name], def)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If more than `max` active elements, mark oldest element for deletion
|
|
||||||
if #players[name] > max then
|
|
||||||
players[name][1].delete = true
|
|
||||||
end
|
|
||||||
|
|
||||||
update(name)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
next_check = next_check - dtime
|
|
||||||
if next_check > 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
next_check = 10000000
|
|
||||||
|
|
||||||
-- Loop through HUD score elements of all players
|
|
||||||
-- and remove them if they've expired
|
|
||||||
for name, hudset in pairs(players) do
|
|
||||||
local modified = false
|
|
||||||
for i, def in pairs(hudset) do
|
|
||||||
local rem = def.time - os.time()
|
|
||||||
if rem <= 0 then
|
|
||||||
def.delete = true
|
|
||||||
modified = true
|
|
||||||
elseif rem < next_check then
|
|
||||||
next_check = rem
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If a player's hudset was modified, update player's HUD
|
|
||||||
if modified then
|
|
||||||
update(name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
players[player:get_player_name()] = {}
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
|
||||||
players[player:get_player_name()] = nil
|
|
||||||
end)
|
|
|
@ -1,3 +0,0 @@
|
||||||
name = hud_events
|
|
||||||
description = API for displaying events on HUD
|
|
||||||
depends = hudkit
|
|
Loading…
Reference in a new issue