Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

News Fixes #18

wants to merge 6 commits into from

Conversation

Cahrs
Copy link
Contributor

@Cahrs Cahrs commented Nov 4, 2019

No description provided.

@Cahrs
Copy link
Contributor Author

Cahrs commented Nov 4, 2019

Just realized how i could make registering death_msg_tbls slightly more elegant, how yay..

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
Copy link
Contributor

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().

Copy link
Contributor Author

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.

Copy link
Contributor

@luk3yx luk3yx Nov 4, 2019

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).

Copy link
Contributor Author

@Cahrs Cahrs Nov 5, 2019

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.

Copy link
Contributor

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")
Copy link
Contributor

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.

@@ -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
Copy link
Contributor

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).

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants