[0.17.23][lua] Incorrect event data when rich text tags are included

This subforum contains all the issues which we already resolved.
Post Reply
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

[0.17.23][lua] Incorrect event data when rich text tags are included

Post by eduran »

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:

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
}
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.
Attachments
sender_0.1.0.zip
(937 Bytes) Downloaded 104 times
receiver_0.1.0.zip
(787 Bytes) Downloaded 96 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.23][lua] Incorrect event data when rich text tags are included

Post by Rseding91 »

Thanks for the report however there's nothing special about passing "rich text tags" between mods with remote calls. The remote call system doesn't even know what rich text is - it's just passing the literal string.

So, I'm going to say not a bug and something on your mod side is broken unless you can show it happening with just 1 tiny example mod and doing it through remote call in the console.

Moving to modding help.
If you want to get ahold of me I'm almost always on Discord.

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: [0.17.23][lua] Incorrect event data when rich text tags are included

Post by eduran »

Event data is the issue. It has nothing to do with remote.call. The attached mods are the smallest possible example I can think of (~40 lines of Lua code). I don't see how I could reproduce this via console commands.

One mod raises an event, the other receives it. The event data on the receiving end is incorrect. It might not be related to rich text, it could also be something else about the transferred strings.

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [0.17.23][lua] Incorrect event data when rich text tags are included

Post by Bilka »

Rseding91 wrote:
Mon Apr 01, 2019 9:30 am
just 1 tiny example mod and doing it through remote call in the console.
Okay, attached is a mod that contains only the following code:

Code: Select all

local custom_event = script.generate_event_name()
script.on_event(custom_event, function(e) game.print(serpent.block(e)) end)
To reproduce the issue, start a game without mods and run this console command:

Code: Select all

/c script.raise_event(145, {["string1"] = "[img=item/express-transport-belt] String A", ["string2"] = "[img=item/express-transport-belt] String B"})
You will observe this:

Image
Attachments
receiver_0.1.1.zip
(717 Bytes) Downloaded 104 times
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: [0.17.23][lua] Incorrect event data when rich text tags are included

Post by eduran »

Thanks Bilka for providing a simpler example. I did not know you could hard-code the event ID like that.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.23][lua] Incorrect event data when rich text tags are included

Post by Rseding91 »

Ok, I was able to reproduce it with that 1 mod and it's now fixed for the next version of 0.17. It had nothing to do with rich text and instead was related to the 2 identical sized strings used for keys.
If you want to get ahold of me I'm almost always on Discord.

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: [0.17.23][lua] Incorrect event data when rich text tags are included

Post by eduran »

Rseding91 wrote:
Mon Apr 01, 2019 10:43 am
It had nothing to do with rich text and instead was related to the 2 identical sized strings used for keys.
I agree it is not related to rich text, but disagree on it being caused by table keys. You can use integer keys and get the same result. Instead, it seems to be caused by long strings (above 40 characters):

Code: Select all

/c script.raise_event(145, {[1] = "this is a string with more than 40 characters", [2] = "another string with more than 40 characters"})

Code: Select all

/c script.raise_event(145, {[1] = "this is a string with exactly 40 chars!!", [2] = "another string with more than 40 characters"})
bug.jpg
bug.jpg (290.78 KiB) Viewed 2729 times

Post Reply

Return to “Resolved Problems and Bugs”