-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed all references to ACOVG (recreated repo)
- Loading branch information
0 parents
commit 24dee29
Showing
32 changed files
with
4,529 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
read_globals = { | ||
"DIR_DELIM", "INIT", | ||
|
||
"minetest", "core", | ||
"dump", "dump2", | ||
|
||
"Raycast", | ||
"Settings", | ||
"PseudoRandom", | ||
"PerlinNoise", | ||
"VoxelManip", | ||
"SecureRandom", | ||
"VoxelArea", | ||
"PerlinNoiseMap", | ||
"PcgRandom", | ||
"ItemStack", | ||
"AreaStore", | ||
|
||
"vector", | ||
|
||
"mcl_util", | ||
|
||
table = { | ||
fields = { | ||
"copy", | ||
"indexof", | ||
"insert_all", | ||
"key_value_swap", | ||
"shuffle", | ||
} | ||
}, | ||
|
||
string = { | ||
fields = { | ||
"split", | ||
"trim", | ||
} | ||
}, | ||
|
||
math = { | ||
fields = { | ||
"hypot", | ||
"sign", | ||
"factorial" | ||
} | ||
}, | ||
} | ||
|
||
globals = { | ||
"better_commands", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"Lua.workspace.library": [ | ||
"C:\\portable\\apps\\minetest\\builtin", | ||
"C:/Users/Nolan/AppData/Roaming/Code/User/globalStorage/sumneko.lua/addonManager/addons/minetest/module/library" | ||
], | ||
"Lua.diagnostics.disable": [ | ||
"undefined-field", | ||
"cast-local-type" | ||
], | ||
"Lua.diagnostics.globals": [ | ||
"mcl_formspec", | ||
"mcl_item_id", | ||
"armor", | ||
"bucket", | ||
"mcl_buckets", | ||
"mcl_armor", | ||
"mcl_enchanting", | ||
"default", | ||
"mcl_sounds", | ||
"mcl_util", | ||
"mcl_potions", | ||
"mcl_vars", | ||
"playerphysics", | ||
"mcl_playerinfo", | ||
"mcl_bamboo", | ||
"mcl_core", | ||
"dump", | ||
"better_commands", | ||
"ItemStack", | ||
"core", | ||
"better_command_blocks" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
---@alias contextTable {executor: minetest.ObjectRef, pos: vector.Vector, rot: vector.Vector, anchor: string, origin: string, [any]: any} | ||
---@alias splitParam {[1]: integer, [2]: integer, [3]: string, type: string, any: string} | ||
---@alias betterCommandFunc fun(name: string, param: string, context: contextTable): success: boolean, message: string?, count: number | ||
---@alias betterCommandDef {description: string, param?: string, privs: table<string, boolean>, func: betterCommandFunc} | ||
|
||
--local bc = better_commands | ||
local storage = minetest.get_mod_storage() | ||
|
||
|
||
local modpath = minetest.get_modpath("better_commands") | ||
function better_commands.run_file(file, subfolder) | ||
dofile(string.format("%s%s%s.lua", modpath, subfolder and "/"..subfolder.."/" or "", file)) | ||
end | ||
|
||
local api_files = { | ||
"damage", | ||
"entity", | ||
"parsing", | ||
"register", | ||
"scoreboard", | ||
"teams", | ||
} | ||
|
||
for _, file in ipairs(api_files) do | ||
better_commands.run_file(file, "API") | ||
end | ||
|
||
local scoreboard_string = storage:get_string("scoreboard") | ||
if scoreboard_string and scoreboard_string ~= "" then | ||
better_commands.scoreboard = minetest.deserialize(scoreboard_string) | ||
else | ||
better_commands.scoreboard = {objectives = {}, displays = {colors = {}}} | ||
end | ||
|
||
local team_string = storage:get_string("teams") | ||
if team_string and team_string ~= "" then | ||
better_commands.teams = minetest.deserialize(team_string) | ||
else | ||
better_commands.teams = {teams = {}, players = {}} | ||
end | ||
|
||
local timer = 0 | ||
minetest.register_globalstep(function(dtime) | ||
timer = timer + dtime | ||
if timer > better_commands.save_interval then | ||
timer = 0 | ||
storage:set_string("scoreboard", minetest.serialize(better_commands.scoreboard)) | ||
storage:set_string("teams", minetest.serialize(better_commands.teams)) | ||
better_commands.update_hud() | ||
end | ||
end) | ||
|
||
minetest.register_on_shutdown(function() | ||
storage:set_string("scoreboard", minetest.serialize(better_commands.scoreboard)) | ||
storage:set_string("teams", minetest.serialize(better_commands.teams)) | ||
storage:set_string("successful_shutdown", "true") | ||
end) | ||
|
||
minetest.register_on_joinplayer(function(player) | ||
better_commands.sidebars[player:get_player_name()] = {} | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
--local bc = better_commands | ||
|
||
---Deals damage; copied from Mineclonia's mcl_util.deal_damage | ||
---@param target minetest.ObjectRef | ||
---@param damage integer | ||
---@param reason table? | ||
---@param damage_immortal? boolean | ||
function better_commands.deal_damage(target, damage, reason, damage_immortal) | ||
local luaentity = target:get_luaentity() | ||
|
||
if luaentity then | ||
if luaentity.deal_damage then -- Mobs Redo/Mobs MC | ||
luaentity:deal_damage(damage, reason or {type = "generic"}) | ||
minetest.log("deal_damage") | ||
return | ||
elseif luaentity.hurt then -- Animalia | ||
luaentity:hurt(damage) | ||
minetest.log("hurt") | ||
luaentity:indicate_damage() | ||
return | ||
elseif luaentity.health then -- Mobs Redo/Mobs MC/NSSM | ||
-- local puncher = mcl_reason and mcl_reason.direct or target | ||
-- target:punch(puncher, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy = damage}}, vector.direction(puncher:get_pos(), target:get_pos()), damage) | ||
if luaentity.health > 0 then | ||
minetest.log("luaentity.health") | ||
luaentity.health = luaentity.health - damage | ||
end | ||
return | ||
end | ||
end | ||
|
||
local hp = target:get_hp() | ||
local armorgroups = target:get_armor_groups() | ||
|
||
if hp > 0 and armorgroups and (damage_immortal or not armorgroups.immortal) then | ||
minetest.log("set_hp") | ||
target:set_hp(hp - damage, reason) | ||
end | ||
end | ||
|
||
minetest.register_on_dieplayer(function(player, reason) | ||
local player_name = player:get_player_name() | ||
for _, def in pairs(better_commands.scoreboard.objectives) do | ||
if def.criterion == "deathCount" then | ||
if def.scores[player_name] then | ||
def.scores[player_name].score = def.scores[player_name].score + 1 | ||
end | ||
end | ||
end | ||
local killer | ||
if reason._mcl_reason then | ||
killer = reason._mcl_reason.source | ||
else | ||
killer = reason.object | ||
end | ||
if killer and killer:is_player() then | ||
local player_name = player:get_player_name() | ||
local killer_name = killer:get_player_name() | ||
local player_team = better_commands.teams.players[player_name] | ||
local killer_team = better_commands.teams.players[killer_name] | ||
for _, def in pairs(better_commands.scoreboard.objectives) do | ||
if def.criterion == "playerKillCount" or (player_team and def.criterion == "teamkill."..player_team) then | ||
if def.scores[killer_name] then | ||
def.scores[killer_name].score = def.scores[killer_name].score + 1 | ||
end | ||
elseif killer_team and def.criterion == "killedByTeam."..killer_team then | ||
if def.scores[player_name] then | ||
def.scores[player_name].score = def.scores[player_name].score + 1 | ||
end | ||
elseif def.criterion == "killed_by.player" then | ||
if def.scores[player_name] then | ||
def.scores[player_name].score = def.scores[player_name].score + 1 | ||
end | ||
end | ||
end | ||
elseif killer then | ||
local killer_type = killer:get_luaentity().name | ||
for _, def in pairs(better_commands.scoreboard.objectives) do | ||
local killed_by = def.criterion:match("^killed_by%.(.*)$") | ||
if killed_by and (killer_type == killed_by or | ||
(better_commands.entity_aliases[killer_type] and better_commands.entity_aliases[killer_type][killed_by])) then | ||
if def.scores[player_name] then | ||
def.scores[player_name].score = def.scores[player_name].score + 1 | ||
end | ||
end | ||
end | ||
end | ||
end) | ||
|
||
-- Make sure players always die when /killed, also track hp | ||
minetest.register_on_player_hpchange(function(player, hp_change, reason) | ||
if reason.better_commands == "kill" then | ||
return -player:get_properties().hp_max, true | ||
end | ||
local player_name = player:get_player_name() | ||
for _, def in pairs(better_commands.scoreboard.objectives) do | ||
if def.criterion == "health" then | ||
if def.scores[player_name] then | ||
minetest.after(0, function() def.scores[player_name].score = player:get_hp() end) | ||
end | ||
end | ||
end | ||
if hp_change < 0 then | ||
local attacker | ||
if reason._mcl_reason then | ||
attacker = reason._mcl_reason.source | ||
else | ||
attacker = reason.object | ||
end | ||
if attacker and attacker:is_player() then | ||
local player_name = player:get_player_name() | ||
local attacker_name = attacker:get_player_name() | ||
local player_team = better_commands.teams.players[player_name] | ||
local attacker_team = better_commands.teams.players[attacker_name] | ||
if player_team == attacker_team then | ||
if better_commands.teams.teams[player_team].pvp == false then | ||
return 0, true | ||
end | ||
end | ||
end | ||
end | ||
return hp_change | ||
end, true) |
Oops, something went wrong.