-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
News Fixes #18
base: master
Are you sure you want to change the base?
News Fixes #18
Conversation
Just realized how i could make registering death_msg_tbls slightly more elegant, how yay.. |
mods/news/init.lua
Outdated
if not (type or name or msgs) then | ||
return | ||
end | ||
|
||
if news.chat_reasons[type] then | ||
news.chat_reasons[type][name] = msgs | ||
for _, tbl in pairs(arg) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's arg
? I suggest using for _, tbl in ipairs({...})
or using select()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arg is a list of extra positional parameters returned from "...", its a default lua keyword, so i see no reason to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The arg
table was deprecated in Lua 5.1 (and does not work in Lua 5.2 or LuaJIT).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Minetest engine has a simple Lua API and uses Lua 5.1.
From the minetest developer wiki. I have no errors when using the keyword "arg" but if you want i can change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing it would probably be better, some Minetest servers (any with LuaJIT libraries installed) use LuaJIT.
"dug straight down", | ||
} | ||
news.register_deathmsg_tbl("nodes", lava_death_msgs, "default:lava_source", "default:lava_flowing") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor annoyance: No newline at the end of the file.
mods/news/init.lua
Outdated
@@ -26,13 +26,15 @@ news.chat_reasons.drown = { | |||
|
|||
minetest.register_privilege("news_report", {give_to_admin = true}) | |||
|
|||
function news.register_deathmsg_tbl(type, name, msgs) | |||
function news.register_deathmsg_tbl(type, msgs, ...) | |||
if not (type or name or msgs) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only return if both type
, name
(not defined) and msgs
are all false (or nil).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, forgot to change that line
No description provided.