[0.17.23][lua] Incorrect event data when rich text tags are included
Posted: Sun Mar 31, 2019 9:09 am
Under very specific circumstances, event data is not transferred properly between mods (see this bug report for LTN Tracker and follow-up discussion in case you are interested in where this came from).
If rich text is included into event data, that data is sometimes not properly transferred to event listeners. Two mods are attached to reproduce the issue. This is what serpent.block output looks like for sender and receiver:
In the first example, string2 is overwritten with the value of string1. The second example works as intended. If sender itself subscribes to the custom event, event data is correct in both cases.
The example mods should work in any game. Sender raises an event twice (with slightly different data) every 60 ticks to which receiver is subscribed.
If rich text is included into event data, that data is sometimes not properly transferred to event listeners. Two mods are attached to reproduce the issue. This is what serpent.block output looks like for sender and receiver:
Code: Select all
639.717 Script @__sender__/control.lua:12: Data, before event raised:
{
string1 = "[img=item/express-transport-belt] String A",
string2 = "[img=item/express-transport-belt] String B" --< this is fed into raise_event
}
639.718 Script @__receiver__/control.lua:3: Event received:
{
data = {
string1 = "[img=item/express-transport-belt] String A",
string2 = "[img=item/express-transport-belt] String A" --< this is what is received
},
mod_name = "sender",
name = 145,
tick = 300
}
639.718 Script @__sender__/control.lua:19: Data, before event raised:
{
string1 = "[img=item/express-transport-belt] A",
string2 = "[img=item/express-transport-belt] B"
}
639.718 Script @__receiver__/control.lua:3: Event received:
{
data = {
string1 = "[img=item/express-transport-belt] A",
string2 = "[img=item/express-transport-belt] B"
},
mod_name = "sender",
name = 145,
tick = 300
}
The example mods should work in any game. Sender raises an event twice (with slightly different data) every 60 ticks to which receiver is subscribed.