diff --git a/config.lua b/config.lua index 8dfd381..5206753 100644 --- a/config.lua +++ b/config.lua @@ -4,7 +4,7 @@ irc.config = {} -local function setting(stype, name, default) +local function setting(stype, name, default, required) local value if stype == "bool" then value = minetest.setting_getbool("irc."..name) @@ -14,6 +14,10 @@ local function setting(stype, name, default) value = tonumber(minetest.setting_get("irc."..name)) end if value == nil then + if required then + error("Required configuration option irc.".. + name.." missing.") + end value = default end irc.config[name] = value @@ -23,13 +27,13 @@ end -- BASIC USER SETTINGS -- ------------------------- -setting("string", "nick") -- Nickname (default "MT-", 6 random hexidecimal characters) -setting("string", "server", "irc.freenode.net") -- Server to connect on joinplayer -setting("number", "port", 6667) -- Port to connect on joinplayer +setting("string", "nick", nil, true) -- Nickname +setting("string", "server", nil, true) -- Server address to connect to +setting("number", "port", 6667) -- Server port to connect to setting("string", "NSPass") -- NickServ password setting("string", "sasl.user", irc.config.nick) -- SASL username setting("string", "sasl.pass") -- SASL password -setting("string", "channel", "##mt-irc-mod") -- Channel to join +setting("string", "channel", nil, true) -- Channel to join setting("string", "key") -- Key for the channel setting("bool", "send_join_part", true) -- Whether to send player join and part messages to the channel @@ -46,14 +50,3 @@ setting("bool", "enable_player_part", true) -- Whether to enable players joini setting("bool", "auto_join", true) -- Whether to automatically show players in the channel when they join setting("bool", "auto_connect", true) -- Whether to automatically connect to the server on mod load --- Generate a random nickname if one isn't specified. -if not irc.config.nick then - local pr = PseudoRandom(os.time()) - -- Workaround for bad distribution in minetest PRNG implementation. - irc.config.nick = ("MT-%02X%02X%02X"):format( - pr:next(0, 255), - pr:next(0, 255), - pr:next(0, 255) - ) -end -