I'm new to lua and to minetest, so I might be saying wrongs things.
I've had a look at the API, and at the register chat command page and tried out this example :
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_chatcommand("say", {
params = "<text>",
description = "Send text to chat",
func = function(text)
minetest.chat_send_all(text)
return true, "Text was sent successfully"
end,
})
When used, it prints "single player" on the chat. After looking a few mods, I tried this charge (parameters of the func) :
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_chatcommand("say", {
params = "<text>",
description = "Send text to chat",
func = function(name, text)
minetest.chat_send_all(text)
return true, "Text was sent successfully"
end,
})
Which seems more appropriate.
However, I'm a bit lost on he syntax. Are these assertions true?
- The string in "params" is useless for the computer -- it's just the /help message
- the function given to "func" will always have the same parameters : name, and a string with the end of the command line;
- if line above is correct, is this a generality for all "func" in every method, or is there a documentation somewhere?
By the way, if params contains multiple arguments (such as x y z) how should I parse the string to get them? (I haven't reach this page in my lua tutorial)
Thanks for reading