code tidy

This commit is contained in:
tenplus1 2023-08-13 11:21:24 +01:00
parent 528fe5e37c
commit 961d6779b5
6 changed files with 24 additions and 27 deletions

View File

@ -1,4 +1,6 @@
local S = mobs_npc.S -- Translation support
local S = minetest.get_translator("mobs_npc")
local mcl = minetest.get_modpath("mcl_core") ~= nil local mcl = minetest.get_modpath("mcl_core") ~= nil
local def = minetest.get_modpath("default") ~= nil local def = minetest.get_modpath("default") ~= nil

View File

@ -1,5 +1,6 @@
-- Translation support
local S = minetest.get_translator("mobs_npc")
local S = mobs_npc.S
local mcl = minetest.get_modpath("mcl_core") ~= nil local mcl = minetest.get_modpath("mcl_core") ~= nil
@ -99,8 +100,8 @@ mobs:register_mob("mobs_npc:igor", {
local name = clicker:get_player_name() local name = clicker:get_player_name()
-- right clicking with gold lump drops random item from list -- right clicking with gold lump drops random item from list
if mobs_npc.drop_trade(self, clicker, mcl and "mcl_raw_ores:raw_gold" or "default:gold_lump", if mobs_npc.drop_trade(self, clicker, mcl and "mcl_raw_ores:raw_gold"
self.npc_drops or mobs_npc.igor_drops) then or "default:gold_lump", self.npc_drops or mobs_npc.igor_drops) then
return return
end end

View File

@ -1,20 +1,11 @@
local path = minetest.get_modpath(minetest.get_current_modname()) .. "/" local path = minetest.get_modpath(minetest.get_current_modname()) .. "/"
-- Check for translation method -- Translation support
local S local S = minetest.get_translator("mobs_npc")
if minetest.get_translator then
S = minetest.get_translator("mobs_npc") -- 5.x translation function
else -- boilerplate function
S = function(str, ...)
local args = {...}
return str:gsub("@%d+", function(match)
return args[tonumber(match:sub(2))]
end)
end
end
mobs_npc = {S = S} -- Global
mobs_npc = {}
-- Check for custom mob spawn file -- Check for custom mob spawn file
@ -48,4 +39,4 @@ if minetest.get_modpath("lucky_block") then
end end
print ("[MOD] Mobs Redo NPCs loaded") print ("[MOD] Mobs NPC loaded")

View File

@ -1,6 +1,7 @@
title = Mobs NPC
name = mobs_npc name = mobs_npc
description = Add a simple NPC, Igor and Trader into your world.
depends = mobs depends = mobs
optional_depends = default, lucky_block, simple_dialogs, screwdriver, mcl_core optional_depends = default, lucky_block, simple_dialogs, screwdriver, mcl_core
description = Adds simple NPC and Trader.
author = TenPlus1 author = TenPlus1
title = Mobs NPC min_minetest_version = 5.0

View File

@ -1,6 +1,7 @@
local S = mobs_npc.S -- Translation support
local mcl = minetest.get_modpath("mcl_core") ~= nil local S = minetest.get_translator("mobs_npc")
local mcl = minetest.get_modpath("mcl_core") ~= nil
-- Npc by TenPlus1 -- Npc by TenPlus1
@ -103,8 +104,8 @@ mobs:register_mob("mobs_npc:npc", {
local name = clicker:get_player_name() local name = clicker:get_player_name()
-- right clicking with gold lump drops random item from list -- right clicking with gold lump drops random item from list
if mobs_npc.drop_trade(self, clicker, mcl and "mcl_raw_ores:raw_gold" or "default:gold_lump", if mobs_npc.drop_trade(self, clicker, mcl and "mcl_raw_ores:raw_gold"
self.npc_drops or mobs_npc.npc_drops) then or "default:gold_lump", self.npc_drops or mobs_npc.npc_drops) then
return return
end end

View File

@ -1,15 +1,16 @@
local S = mobs_npc.S -- Translation support
local S = minetest.get_translator("mobs_npc")
local mcl = minetest.get_modpath("mcl_core") ~= nil local mcl = minetest.get_modpath("mcl_core") ~= nil
-- define table containing names for use and shop items for sale -- define table containing names for use and shop items for sale
mobs.human = { mobs.human = {
names = { names = {
"Bob", "Duncan", "Bill", "Tom", "James", "Ian", "Lenny", "Bob", "Duncan", "Bill", "Tom", "James", "Ian", "Lenny",
"Dylan", "Ethan", "Sam" "Dylan", "Ethan", "Sam", "Aubrey"
}, },
items = { items = {