Skip to content

Commit ea9c3d4

Browse files
v1.1
1 parent d5fd8eb commit ea9c3d4

File tree

13 files changed

+159
-126
lines changed

13 files changed

+159
-126
lines changed

API/API.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ end
4242
local timer = 0
4343
minetest.register_globalstep(function(dtime)
4444
timer = timer + dtime
45-
if timer > better_commands.save_interval then
45+
if timer > better_commands.settings.save_interval then
4646
timer = 0
4747
storage:set_string("scoreboard", minetest.serialize(better_commands.scoreboard))
4848
storage:set_string("teams", minetest.serialize(better_commands.teams))

API/damage.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ function better_commands.deal_damage(target, damage, reason, damage_immortal)
1111
if luaentity then
1212
if luaentity.deal_damage then -- Mobs Redo/Mobs MC
1313
luaentity:deal_damage(damage, reason or {type = "generic"})
14-
minetest.log("deal_damage")
1514
return
1615
elseif luaentity.hurt then -- Animalia
1716
luaentity:hurt(damage)
18-
minetest.log("hurt")
1917
luaentity:indicate_damage()
2018
return
2119
elseif luaentity.health then -- Mobs Redo/Mobs MC/NSSM
2220
-- local puncher = mcl_reason and mcl_reason.direct or target
2321
-- target:punch(puncher, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, vector.direction(puncher:get_pos(), target:get_pos()), damage)
2422
if luaentity.health > 0 then
25-
minetest.log("luaentity.health")
2623
luaentity.health = luaentity.health - damage
2724
end
2825
return
@@ -33,7 +30,6 @@ function better_commands.deal_damage(target, damage, reason, damage_immortal)
3330
local armorgroups = target:get_armor_groups()
3431

3532
if hp > 0 and armorgroups and (damage_immortal or not armorgroups.immortal) then
36-
minetest.log("set_hp")
3733
target:set_hp(hp - damage, reason)
3834
end
3935
end

API/parsing.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ function better_commands.parse_time_string(time, absolute)
533533

534534
if not absolute then
535535
result = (minetest.get_timeofday() + (amount/24000)) % 1
536-
elseif better_commands.mc_time then
536+
elseif better_commands.settings.acovg_time then
537537
result = ((amount + 6000)/24000) % 1
538538
else
539539
result = (amount/24000) % 1

API/register.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
minetest.register_on_mods_loaded(function()
2020
for name, def in pairs(better_commands.commands) do
2121
if minetest.registered_chatcommands[name] then
22-
if better_commands.override then
22+
if better_commands.settings.override then
2323
minetest.log("action", "[Better Commands] Overriding "..name)
2424
better_commands.old_commands[name] = minetest.registered_chatcommands[name]
2525
minetest.unregister_chatcommand(name, def)

API/scoreboard.lua

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,11 @@ local S = minetest.get_translator(minetest.get_current_modname())
44
better_commands.criteria_patterns = {
55
"^killed_by%..*$", -- killed_by.<entity name>
66
"^teamkill%..*$", -- teamkill.<team name>
7-
"^killedByTeam%..*$", -- killedByTeam. <team name>
7+
"^killedByTeam%..*$", -- killedByTeam.<team name>
8+
"^picked_up%.[_%w]*:?[_%w]+$" -- picked_up.<itemstring>
89
--"^distanceTo%.%-?%d*%.?%d+,%-?%d*%.?%d+,%-?%d*%.?%d+$" -- distanceTo.<x>,<y>,<z>
910
}
1011

11-
function better_commands.validate_criterion(criterion)
12-
if better_commands.valid_criteria[criterion] then
13-
return true
14-
end
15-
for _, pattern in ipairs(better_commands.criteria_patterns) do
16-
if criterion:match(pattern) then
17-
return true
18-
end
19-
end
20-
end
21-
2212
better_commands.valid_criteria = {
2313
dummy = true,
2414
trigger = true,
@@ -32,6 +22,21 @@ better_commands.valid_criteria = {
3222
--armor = (better_commands.mcl or minetest.get_modpath("3d_armor") and true)
3323
}
3424

25+
---Validates a criterion
26+
---@param criterion string
27+
---@return boolean
28+
function better_commands.validate_criterion(criterion)
29+
if better_commands.valid_criteria[criterion] then
30+
return true
31+
end
32+
for _, pattern in ipairs(better_commands.criteria_patterns) do
33+
if criterion:match(pattern) then
34+
return true
35+
end
36+
end
37+
return false
38+
end
39+
3540
---Gets matching names in a scoreboard
3641
---@param selector splitParam
3742
---@param context contextTable

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
22

33
## v1.0
4-
Initial release. Missing *lots* of commands, several `execute` subcommands, lots of scoreboard objectives, and lots of entity selectors.
4+
Initial release. Missing *lots* of commands, several `execute` subcommands, lots of scoreboard objectives, and lots of entity selectors.
5+
6+
## v1.1
7+
* Removed a reference to ACOVG (hopefully the last)
8+
* Added TODO.md
9+
* Redid settings slightly (so it's easy to add more)
10+
* Removed debug logging when using the `/kill` command

COMMANDS/kill.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ better_commands.register_command("kill", {
1717
local last
1818
for _, target in ipairs(targets) do
1919
if target.is_player then
20-
if better_commands.kill_creative_players or not (target:is_player() and minetest.is_creative_enabled(target:get_player_name())) then
20+
if better_commands.settings.kill_creative_players or not (target:is_player() and minetest.is_creative_enabled(target:get_player_name())) then
2121
last = better_commands.get_entity_name(target)
2222
better_commands.deal_damage(
2323
---@diagnostic disable-next-line: param-type-mismatch

COMMANDS/time.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ better_commands.register_command("time", {
2929
return true, S("Time set"), 1
3030
elseif action == "query" then
3131
if time == "daytime" then
32-
if better_commands.mc_time then
32+
if better_commands.settings.acovg_time then
3333
return true, S("Current time: @1", math.floor(minetest.get_timeofday()*24000+18000) % 24000), 1
3434
else
3535
return true, S("Current time: @1", math.floor(minetest.get_timeofday()*24000)), 1

README.md

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -106,102 +106,4 @@ Some arguments (such as `name` and `type`) allow you to prefix the value with `!
106106
7. Except in MCLA/VL, the `playerKillCount` and `killed_by`, `teamkill`, and `killedByTeam` objectives can only track direct kills (so not arrows or explosions, for example).
107107
8. Objectives cannot be displayed as hearts, although literally the only reason is that there's no good half heart character.
108108
9. Team prefixes and suffixes have been replaced with `nameFormat` (for example, `/team modify a_nice_team nameFormat [Admin] %s the great`), where any `%s` is replaced with the player's name. If your name was `singleplayer`, it would appear as `[Admin] singleplayer the great`. The reason for this is pretty simple: I don't want to figure out how to do quotes, and Minetest removes trailing space, meaning prefixes ending in spaces are impossible. This fixes that.
109-
10. The `/give` command is currently unable to give multiple tools (so `/give @s default:pick_wood 5` will only give 1). This may change.
110-
111-
## TODO
112-
- [ ] Add scoreboard playerlist and nametags (?)
113-
- [ ] Figure out feet/eyes since most entities don't have that
114-
- [ ] Make output match ACOVG's (error messages, number results, etc.)
115-
- [ ] Add more scoreboard criteria (settings to disable)
116-
- [ ] `xp`/`level` (MCLA/VL only)
117-
- [ ] `food` (MCLA/VL/stamina)
118-
- [ ] `air`
119-
- [ ] `armor` (MCLA/VL/3D Armor)
120-
- [x] `trigger`
121-
- [ ] `picked_up.<itemstring>`
122-
- [ ] `mined.<itemstring>`
123-
- [ ] `crafted.<itemstring>`
124-
- [ ] `total_world_time`
125-
- [ ] `leave_game`
126-
- [ ] Add missing `execute` subcommands
127-
- [ ] `in`
128-
- [ ] `summon`
129-
- [ ] `if/unless`
130-
- [ ] `biome`
131-
- [ ] `block`/`node`
132-
- [ ] `blocks`/`nodes`
133-
- [ ] `data`
134-
- [ ] `dimension`
135-
- [ ] `entity`
136-
- [ ] `loaded`
137-
- [ ] `score`
138-
- [ ] `store`
139-
- [ ] `block`/`node`
140-
- [ ] `bossbar`
141-
- [ ] `entity`
142-
- [ ] `score`
143-
- [ ] Add more commands
144-
- [x] `trigger`
145-
- [ ] `alwaysday`/`daylock`
146-
- [ ] `ban`/`ban-ip`/`banlist`
147-
- [ ] `bossbar`? (probably significantly modified)
148-
- [ ] `advancement`
149-
- [ ] `fill` (Extra argument for LBM vs `set_node(s)`)
150-
- [ ] `changesetting`?
151-
- [ ] `clear`
152-
- [ ] `spawnpoint`
153-
- [ ] `clearspawnpoint`
154-
- [ ] `clone`
155-
- [ ] `damage`
156-
- [ ] `data`
157-
- [ ] `deop` (removes all but basic privs)
158-
- [ ] `op` (grants certain privs, including `server`)
159-
- [ ] `effect` (MCLA/VL only)
160-
- [ ] `enchant` (MCLA/VL only, also override forceenchant?)
161-
- [ ] `experience`/`xp` (MCLA/VL only)
162-
- [ ] `fog`
163-
- [ ] `forceload`
164-
- [ ] `gamemode` (in MTG, grants/revokes `creative`)
165-
- [ ] `gamerule`? (maybe equivalent to `changesetting`?)
166-
- [ ] `item`?
167-
- [ ] `kick`
168-
- [ ] `list`
169-
- [ ] `locate` (copy from or depend on Wuzzy's `findbiome`, maybe also support MCLA/VL end shrines)
170-
- [ ] `loot`
171-
- [ ] `music` (depending on various mods)
172-
- [ ] `pardon`
173-
- [ ] `pardon-ip`
174-
- [ ] `particle`
175-
- [ ] `place`
176-
- [ ] `random` (although seeds seem to be somewhat inconsistent in MT)
177-
- [ ] `recipe` (MCLA/VL only)
178-
- [ ] `remove`
179-
- [ ] `replaceitem`
180-
- [ ] `return`
181-
- [ ] `ride`?
182-
- [ ] `seed`
183-
- [ ] `setidletimeout`?
184-
- [ ] `spreadplayers`?
185-
- [ ] `stop`
186-
- [ ] `structure`?
187-
- [x] `summon`
188-
- [ ] `tag`
189-
- [ ] `teammsg`/`tm`
190-
- [ ] `testfor`
191-
- [ ] `testforblock`
192-
- [ ] `testforblocks`
193-
- [ ] `tickingarea`?
194-
- [ ] `toggledownfall` (depending on mods)
195-
- [ ] `weather` (depending on mods)
196-
- [ ] `whitelist`
197-
- [ ] `worldborder`? (maybe not visible, probably no collision)
198-
- [ ] Add more selector arguments
199-
- [ ] `dx`/`dy`/`dz`
200-
- [ ] `x_rotation`/`rx`/`rxm`/`y_rotation`/`ry`/`rym`
201-
- [ ] `scores`
202-
- [ ] `tag`
203-
- [ ] `team`
204-
- [ ] `level`/`l`/`lm` (MCLA/VL only)
205-
- [ ] `gamemode`/`l`/`lm` (more of an "is creative?" command)
206-
- [ ] `advancements` (with MCLA/VL/awards), change syntax
207-
- [ ] `haspermission` (privs)
109+
10. The `/give` command is currently unable to give multiple tools (so `/give @s default:pick_wood 5` will only give 1). This may change.

TODO.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# TODO
2+
A place for me to write out my future plans. Also, I can just copy/paste into a random generator and decide what to do next.
3+
4+
- [ ] Add scoreboard playerlist and nametags (?)
5+
- [ ] Figure out feet/eyes since most entities don't have that
6+
- [ ] Make output match ACOVG's (error messages, number results, etc.)
7+
- [ ] Add more scoreboard criteria (settings to disable)
8+
- [ ] `xp`/`level` (MCLA/VL only)
9+
- [ ] `food` (MCLA/VL/stamina)
10+
- [ ] `air`
11+
- [ ] `armor` (MCLA/VL/3D Armor)
12+
- [x] `trigger`
13+
- [ ] `picked_up.<itemstring>`
14+
- [ ] `mined.<itemstring>`
15+
- [ ] `crafted.<itemstring>`
16+
- [ ] `total_world_time`
17+
- [ ] `leave_game`
18+
- [ ] Advancements/awards?
19+
- [ ] Add missing `execute` subcommands
20+
- [ ] `in`
21+
- [ ] `summon`
22+
- [ ] `if/unless`
23+
- [ ] `biome`
24+
- [ ] `block`/`node`
25+
- [ ] `blocks`/`nodes`
26+
- [ ] `data`
27+
- [ ] `dimension`
28+
- [ ] `entity`
29+
- [ ] `loaded`
30+
- [ ] `score`
31+
- [ ] `store`
32+
- [ ] `block`/`node`
33+
- [ ] `bossbar`
34+
- [ ] `entity`
35+
- [ ] `score`
36+
- [ ] Add more selector arguments
37+
- [ ] `dx`/`dy`/`dz`
38+
- [ ] `x_rotation`/`rx`/`rxm`/`y_rotation`/`ry`/`rym`
39+
- [ ] `scores`
40+
- [ ] `tag`
41+
- [ ] `team`
42+
- [ ] `level`/`l`/`lm` (MCLA/VL only)
43+
- [ ] `gamemode`/`l`/`lm` (more of an "is creative?" command)
44+
- [ ] `advancements` (with MCLA/VL/awards), change syntax
45+
- [ ] `haspermission` (privs)
46+
- [ ] Add more commands
47+
- [x] `trigger`
48+
- [ ] `alwaysday`/`daylock`
49+
- [ ] `ban`/`ban-ip`/`banlist`
50+
- [ ] `bossbar`? (probably significantly modified, maybe MCLA/VL only)
51+
- [ ] `advancement`
52+
- [ ] `fill` (Extra argument for LBM vs `set_node(s)`)
53+
- [ ] `changesetting`?
54+
- [ ] `clear`
55+
- [ ] `spawnpoint`
56+
- [ ] `clearspawnpoint`
57+
- [ ] `clone`
58+
- [ ] `damage`
59+
- [ ] `data`
60+
- [ ] `deop` (removes all but basic privs)
61+
- [ ] `op` (grants certain privs, including `server`)
62+
- [ ] `effect` (MCLA/VL only)
63+
- [ ] `enchant` (MCLA/VL only, also override forceenchant?)
64+
- [ ] `experience`/`xp` (MCLA/VL only)
65+
- [ ] `fog`
66+
- [ ] `forceload`
67+
- [ ] `gamemode` (in MTG, grants/revokes `creative`)
68+
- [ ] `gamerule`? (maybe equivalent to `changesetting`?)
69+
- [ ] `item`?
70+
- [ ] `kick`
71+
- [ ] `list`
72+
- [ ] `locate` (copy from or depend on Wuzzy's `findbiome`, maybe also support MCLA/VL end shrines)
73+
- [ ] `loot`
74+
- [ ] `music` (depending on various mods)
75+
- [ ] `pardon`
76+
- [ ] `pardon-ip`
77+
- [ ] `particle`
78+
- [ ] `place`
79+
- [ ] `random` (although seeds seem to be somewhat inconsistent in MT)
80+
- [ ] `recipe` (MCLA/VL only)
81+
- [ ] `remove`
82+
- [ ] `replaceitem`
83+
- [ ] `return`
84+
- [ ] `ride`?
85+
- [ ] `seed`
86+
- [ ] `setidletimeout`?
87+
- [ ] `spreadplayers`?
88+
- [ ] `stop`
89+
- [ ] `structure`?
90+
- [x] `summon`
91+
- [ ] `tag`
92+
- [ ] `teammsg`/`tm`
93+
- [ ] `testfor`
94+
- [ ] `testforblock`
95+
- [ ] `testforblocks`
96+
- [ ] `tickingarea`?
97+
- [ ] `toggledownfall` (depending on mods)
98+
- [ ] `weather` (depending on mods)
99+
- [ ] `whitelist`
100+
- [ ] `worldborder`? (maybe not visible, probably no collision)

init.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
better_commands = {commands = {}, old_commands = {}, players = {}}
22

3-
better_commands.override = minetest.settings:get_bool("better_commands_override", false)
4-
better_commands.mc_time = minetest.settings:get_bool("better_commands_mc_time", false)
5-
better_commands.save_interval = tonumber(minetest.settings:get("better_commands_save_interval")) or 3
6-
better_commands.kill_creative_players = minetest.settings:get_bool("better_commands_kill_creative_players", false)
73
better_commands.mcl = minetest.get_modpath("mcl_core")
84

95
local modpath = minetest.get_modpath("better_commands")
106
dofile(modpath.."/entity_aliases.lua")
7+
dofile(modpath.."/settings.lua")
118
dofile(modpath.."/API/api.lua")
129
dofile(modpath.."/COMMANDS/commands.lua")
1310

settings.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
better_commands.settings = {}
2+
3+
---Gets a setting and stores it in better_commands.settings
4+
---@param setting string
5+
---@param default any
6+
---@param type string?
7+
local function get_setting(setting, default, type)
8+
local long_setting = "better_commands_"..setting
9+
if not type or type == "string" then
10+
better_commands.settings[setting] = minetest.settings:get(long_setting) or default
11+
elseif type == "bool" then
12+
better_commands.settings[setting] = minetest.settings:get_bool(long_setting, default)
13+
elseif type == "number" then
14+
better_commands.settings[setting] = tonumber(minetest.settings:get(long_setting)) or default
15+
end
16+
end
17+
18+
local settings = {
19+
{"override", false, "bool"},
20+
{"acovg_time", false, "bool"},
21+
{"save_interval", 3, "number"},
22+
{"kill_creative_players", false, "bool"},
23+
}
24+
25+
for _, setting in ipairs(settings) do
26+
get_setting(unpack(setting))
27+
end

settingtypes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
better_commands_override (Override existing commands?) bool false
33

44
# Use ACOVG times for the /time command? If enabled, day starts at 0, not 7000.
5-
better_commands_mc_time (Use ACOVG time?) bool false
5+
better_commands_acovg_time (Use ACOVG time?) bool false
66

77
# Can the /kill command kill players in creative mode?
88
better_commands_kill_creative_players (Kill creative players?) bool false

0 commit comments

Comments
 (0)