[15.10] on_robot_mined_entity event doesn't always trigger

Place to get help with not working mods / modding interface.
Post Reply
Ahsous
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Jul 01, 2016 6:28 pm
Contact:

[15.10] on_robot_mined_entity event doesn't always trigger

Post by Ahsous »

Hello,

I wrote a mod that uses the on_robot_mined_entity event and noticed that this event doesn't trigger when deconstructing entities that are close to the player.
When I deconstruct entities that are close to the player the construction robots don't really fly to the entity but instead just pop up above the player and vanish shortly after.
I wrote a simply mod that outputs test to the console when the event is triggered:

Code: Select all

script.on_event(defines.events.on_robot_mined_entity, function(event)
    game.print("test")
  end)

Cheers,
Ahsous
Attachments
BugTest_1.0.0.zip
(712 Bytes) Downloaded 96 times

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

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Rseding91 »

Yes it does. You're printing the same message over and over which hits the spam prevention and doesn't show the extra messages since they're all identical.
If you want to get ahold of me I'm almost always on Discord.

kikker450
Inserter
Inserter
Posts: 30
Joined: Fri May 05, 2017 9:07 am
Contact:

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by kikker450 »

Rseding91 wrote:Yes it does. You're printing the same message over and over which hits the spam prevention and doesn't show the extra messages since they're all identical.
Quick side question, I've searched through the forums (on "spam prevention") and looked through the settings ingame but is there a way to turn spam prevention off?

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

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Bilka »

Just print something that always changes, such as game.tick.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Ahsous
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Jul 01, 2016 6:28 pm
Contact:

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Ahsous »

I don't think this has something to do with spam protection (since it's that way on the first message too and I don't send that many messages anyway)

I uploaded a video showcasing it (with printing game.tick instead of "test"):
https://www.youtube.com/watch?v=lnac6cc ... e=youtu.be

As you can see I don't get a message on entities that are right next to the player.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Klonan »

Ahsous wrote:I don't think this has something to do with spam protection (since it's that way on the first message too and I don't send that many messages anyway)

I uploaded a video showcasing it (with printing game.tick instead of "test"):
https://www.youtube.com/watch?v=lnac6cc ... e=youtu.be

As you can see I don't get a message on entities that are right next to the player.
Use game.write_file, which doesn't prevent a spam of messages, to make sure it truly isn't triggering

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by gheift »

or as an alternative you can use this

Code: Select all

local debug_idx = 0
script.on_event(defines.events.on_robot_mined_entity, function(event)
    game.print("test (" .. debug_idx .. ")")
    print("test (" .. debug_idx .. ")") -- this prints to the console/stdout, at least under linux
    debug_idx = debug_idx + 1
end)

Ahsous
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Jul 01, 2016 6:28 pm
Contact:

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Ahsous »

Using:

Code: Select all

script.on_event(defines.events.on_robot_mined_entity, function(event)
    game.write_file("bugTest.txt", tostring(game.tick) .. "\n", true)
    game.print(game.tick)
  end)
https://www.youtube.com/watch?v=Iz0pN0Q ... e=youtu.be

Results in the following bugTest.txt:
14569890
14570062
14570774
Same numbers as the ingame output even if I cut more than 3 trees (in 3 different steps).

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Klonan »

Ahsous wrote:Using:

Code: Select all

script.on_event(defines.events.on_robot_mined_entity, function(event)
    game.write_file("bugTest.txt", tostring(game.tick) .. "\n", true)
    game.print(game.tick)
  end)
https://www.youtube.com/watch?v=Iz0pN0Q ... e=youtu.be

Results in the following bugTest.txt:
14569890
14570062
14570774
Same numbers as the ingame output even if I cut more than 3 trees (in 3 different steps).
I tested by deconstructing 10 trees near me, and the log output shows 10 trees were deconstructed

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

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Rseding91 »

The videos you've uploaded are private so I can't see them.

When I test it myself it produces exactly as it should: http://imgur.com/a/WVlxn

Code: Select all

script.on_event(defines.events.on_robot_mined_entity, function(event)
  log(event.tick)
end)
If you want to get ahold of me I'm almost always on Discord.

Ahsous
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Jul 01, 2016 6:28 pm
Contact:

Re: [15.10] on_robot_mined_entity event doesn't always trigger

Post by Ahsous »

Oh god, I should've tested it without any mods active.
I had the mod Bluebuild installed (and forgot about it after getting bots). That mod deconstructs stuff without bots (and instantly removes entities around the player). That's why it looked like the bot came out of the player and instantly returned (I made the videos public now btw).

The event works like intended, sorry that I wasted your time :oops:

Post Reply

Return to “Modding help”