Added .luacheckrc and addec logging to command: emeralds

This commit is contained in:
James David Clarke 2024-01-14 22:18:33 +00:00 committed by impulse
parent c33c4be134
commit 0bf4d57b2f
2 changed files with 75 additions and 21 deletions

48
.luacheckrc Normal file

@ -0,0 +1,48 @@
unused_args = false
allow_defined_top = true
globals = {
"minetest","atm","emeraldbank",
}
read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Builtin
"vector", "ItemStack",
"dump", "DIR_DELIM", "VoxelArea", "Settings","core",
-- MTG
"default", "sfinv", "creative",
-- Mineclone
"mcl_loot", "tga_encoder", "mcl_util", "flowlib", "mcl_sounds", "mcl_autogroup",
"mcl_events", "biomeinfo", "mcl_damage", "mcl_particles", "mcl_worlds", "mcl_colors",
"mcl_explosions", "mcl_vars", "controls", "walkover", "mcl_meshhand", "mcl_fovapi",
"playerphysics", "mcl_hunger", "mcl_death_drop", "mcl_player", "mcl_playerplus",
"mcl_gamemode", "mcl_spawn", "mcl_skins", "mcl_sprint", "mcl_playerinfo",
"mcl_item_id", "tt", "mcl_craftguide", "doc", "mcl_dripping",
"mcl_entity_invs", "mcl_item_entity", "mcl_burning",
"mcl_minecarts", "pillager", "mobs_mc", "sounds",
"textures", "mcl_mobs", "mcl_paintings",
"mcl_grindstone", "mcl_walls", "mcl_bamboo",
"mcl_maps", "mcl_clock", "mcl_end", "mcl_starting_inventory",
"mcl_bows", "mcl_bows_s", "mcl_dye", "mcl_copper",
"mcl_flowerpots", "mcl_furnaces", "mcl_farming",
"mcl_campfires", "mcl_crafting_table", "mcl_doors",
"mcl_jukebox", "screwdriver", "mcl_itemframes",
"mcl_heads", "mcl_beacons", "xpanes", "mcl_enchanting",
"mcl_beds", "mcl_throwing", "mcl_banners", "mcl_mobspawners",
"mcl_cocoas", "mcl_smithing_table", "mcl_flowers",
"mcl_core", "mcl_torches", "mcl_target", "mesecon", "mcl_observers",
"mcl_sculk", "mcl_armor", "mcl_lanterns", "mcl_stairs", "mcl_bells",
"mcl_hamburger", "mcl_signs", "mcl_honey", "mcl_stonecutter", "mcl_fire",
"mcl_compass", "mcl_ocean", "mcl_fences", "mcl_buckets", "mcl_potions",
"tnt", "mcl_cherry_blossom", "mcl_portals", "mcl_chests", "mcl_shields",
"mcl_wip", "mcl_raids", "mcl_moon", "lightning", "mcl_weather",
"mcl_formspec", "mcl_death_messages", "mcl_bossbars", "awards",
"mcl_inventory", "mcl_title", "mcl_offhand", "hb", "mcl_experience",
"mcl_info", "mcl_credits", "tsm_railcorridors", "mcl_mapgen_core",
"mcl_structures", "settlements", "mcl_dungeons", "mcl_colors_official"
}

@ -24,10 +24,10 @@ local S = core.get_translator(core.get_current_modname())
-- user /pay chat command
core.register_chatcommand("pay", {
params = "<player> <num>",
params = "<player> <num>",
description = S("Pay money to other player. Transfer your emeralds to another bank account."),
func = function(name, param)
local player1 = core.get_player_by_name(name)
local player1 = core.get_player_by_name(name)
local name2, stringnum = param:match("([^ ]+) (.+)")
local player2
local num = tonumber(stringnum)
@ -43,7 +43,8 @@ core.register_chatcommand("pay", {
-- user /money chat command
core.register_chatcommand("money", {
description = S("Return your emeralds in your bank account."),
description = S("Return your emeralds in your bank account. Or if have server priv, other players too"),
params = "[player]",
func = function(name, param)
-- Determine the target player: either the command issuer or the specified player
local target_player = param ~= "" and minetest.check_player_privs(name, {server=true}) and param or name
@ -65,26 +66,31 @@ core.register_chatcommand("money", {
-- admin chat command
core.register_chatcommand("emeralds", {
params = "<player> <num>",
description = S("Admin Command! Add player emeralds in bank account, also can use negative numbers"),
privs = {server=true},
func = function(name, param)
local playername, stringnum = param:match("([^ ]+) (.+)")
local player
local num = tonumber(stringnum)
if playername and num then
player = core.get_player_by_name(playername)
end
if player and num then
emeraldbank.add_emeralds(player, num)
atm.read_account(playername)
minetest.chat_send_player(name, S("@1 has now @2 emeralds in bank account", playername, atm.balance[playername]))
return true
end
return false
end
params = "<player> <num>",
description = S("Admin Command! Add player emeralds in bank account, also can use negative numbers"),
privs = {server=true},
func = function(name, param)
local playername, stringnum = param:match("([^ ]+) (.+)")
local player
local num = tonumber(stringnum)
if playername and num then
player = core.get_player_by_name(playername)
end
if player and num then
emeraldbank.add_emeralds(player, num)
atm.read_account(playername)
minetest.chat_send_player(name, S("@1 has now @2 emeralds in bank account",
playername, atm.balance[playername]))
return true
else
-- Notify the command issuer that the player is not found or not online
minetest.chat_send_player(name, S("Player @1 not found or not online.", playername))
return false
end
end
})
-- experimental upgrade command
core.register_chatcommand("upgrade", {
description = S("Admin Command! Upgrade a shop"),