Skip to content

How to pass arbitrary number of arguments from script-message to Lua plugin? #16089

Answered by avih
enoryw asked this question in Q&A
Discussion options

You must be logged in to vote

First argument is printed because of print("first:", first), but the rest doesn't with arg being nil:

You're right, sorry. It changed between lua version and it's still supported in my version (5.1), but no longer in 5.2 or luajit.

My link was for Lua 5.0, but because it was chapter 5.2 of that book I thought it's the manual of lua 5.2, and it's not.

That's the manual of Lua 5.2: https://www.lua.org/manual/5.2/manual.html#3.4.10 and you should always refer to it when you don't know something in Lua.

Anyway, the answer is this:

mp.register_script_message("my-message", function (first, ...)
    local  the_rest = {...}
    print("first:", first)
    for i,v in ipairs(the_rest) do
        p…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@enoryw
Comment options

@avih
Comment options

avih Mar 22, 2025
Collaborator

Answer selected by enoryw
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants