Strange behaviour of msg.post(url, "set_text", table)

Hi everyone,

I have come accross a strange behaviour.
I am trying to pass message to my gui via msg.post but somehow when I name the message_id as “set_text”, only text part of my table is transferred.

E.g.:

msg.post("#debug_window", "set_text", {name="stime", text=value})

So I am clearly sending a table with two values but I get this

pprint({message_id, message, sender})
-------------------------------------
{ --[[000001F353CC5790]]
  1 = hash: [set_text],
  2 = { --[[000001F353CC5660]]
    text = "Time: 0.00 s"
  },
  3 = url: [main:/go#debug_helper]
}

If the passed table does not contain “text” field it throws an error

ERROR:SCRIPT: main/debug_helper.script:24: Field text not specified in table

But if I were to choose different message_id than “set_text” it works as expected.

And yet another thing, If I choose “set_name” it also works as expected.

You can see output messages here:
Console_output_example.txt (1.1 KB)

So my question is… Is the “set_text” some kind of reserved word?
I did not find anything about it and there is a lot of information about msg.post, so I just got lost after some time.

This is a test project I made in order to eliminate my other work.
msg_passing_test.zip (61.2 KB)

Thanks for your help in advance
Azurac

I suspect this is why:

Note the warning!

1 Like

Ok, so label… hmm I did not expect this.

I’ll read it. Thanks a lot.


I am not sure. As I see it, all it says is that the label text is not set immediately.

I tried to even dive into that Application Lifecycle article a bit, but I just did not find anything which would prove this. But it may be also because I did not comprehend it quite well. It’s complicated.

The reason the label text is not set immediately is:

This method uses the message passing that means the value will be set after dispatch messages step.

I can only assume the message that is passed under the hood is named “set_text”.

Yes, I can understand what is written there. I was refering to my original question that I did not find any connection there.

But yeah, it behaves as if it was forced to use some predefined function. I am just wandering if there are some other reserved message_id names that I shouldn’t use.

If you ask me, this is just weird and not very intuitive…

Sorry to bother you @britzl, but could you please comment on this?
Thanks

@Alex_8BitSkull is correct. There are a number of messages used internally in the engine, with set_text being one of them. We do not have these messages documented anywhere, mainly because we have no automated process in place to extract documentation about them from engine code.

1 Like

So, maybe some warning to the message_id parameter in msg.post API reference could be added?

Anyway, thank you both for the help and confirmation.

2 Likes