Pixels

by axtox

Display your pictures and indicators in real-time directly on the map using Pixels. WARNING: All pixels are being processed at a time, so it is not recommended to create more than 15000 Pixels.

Utilities
2 years ago
0.17 - 1.1
120

b Deconstruction bug with robots

4 years ago

Hello !

I got this report after trying to deconstruct diodes with the robots:

164.752 Error MainLoop.cpp:1205: Exception at tick 34993133: Le mod Pixels (2.0.0) a engendré une erreur non récupérable.
Merci d'informer l'auteur de cette erreur.

Error while running event Pixels::on_nth_tick(3)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
Pixels/scripts/render/checkup.lua:35: in function 'register_changed_pixels'
Pixels/scripts/render/checkup.lua:49: in function <Pixels/scripts/render/checkup.lua:48>
stack traceback:
[C]: in function 'index'
__Pixels
/scripts/render/checkup.lua:35: in function 'register_changed_pixels'
Pixels/scripts/render/checkup.lua:49: in function <Pixels/scripts/render/checkup.lua:48>

Good continuation ^^

4 years ago

Thanks for your report. Checking.

4 years ago
(updated 4 years ago)

I've tested the mod with ~3000 diodes being deconstructed with robots almost immediately.


Can you please provide the detailed reproduce steps? I was testing it with the personal and stationary robots and it worked just fine. I need that information so I will fix the cause of the problem and not just making a workaround
And answer few questions -
1. What mods do you have?
2. That was a multiplayer session? If yes - headless server or in-game server (game hosted from the main menu) and how many players there were?
3. What Factorio version do you use?
4. What's your PC spec?
5. What you were doing just before bug appeared (step-by-step)?

4 years ago
(updated 4 years ago)

Interesting...

It was during my compatibility tests to see if it worked with my other mods and that's the only problem I'm having at the moment. The display works fine and the manual deconstruction too.

1 - Oh god... I've got 80 active mods, it's going to be complex to find a link (at least: I guess)
https://pastebin.com/iyS3YbH4

2 - Solo session only

3 - Always up to date on the 0.18

4 -
Win 10, 64-Bits
16GB of RAM
AMD Ryzen 7 2700X
Geforce RTX 2060

5 - I modified the code of this mod for my own needs (upgrading lamps to diodes thanks to the scheduler and adding an option to choose if you want to build the diodes from lamps and not components of them), since I already had on my part of the "level screen" for different resources and I didn't especially want to redo all of them ^^" .
But seeing that the deconstruction didn't work, I went back to an unmodified version, but the bug was still there :/

I hope this info will help you, I'll give you more if you need it ^^

Good game and good code ^^

4 years ago

Hmm... My bad, sorry :/

Looks like the mistake was mine. As described just above, I did some tests concerning the upgrade by the scheduler and I don't know how I did it, but the error persisted between the 2 versions of the mod ><.
Of all the tests I've just done, I didn't encounter any conflict between the different mods. The only time there are problems is when I switch from one version to the other...

I apologize for the false concern. ><

4 years ago
(updated 4 years ago)

So now, with the original code, everything is fine?
Maybe I can create some workaround for you so your lamps will be replaced with Diods by on click? I can think about that
And thank you for the interest to the code and the mod itself. In the beggining it was done with Coroutines, to update infinite number of lamps using chunk-based updates. Look at this - 5000lamps being updated during a timeline. It is the regular lamps (no Diode were introduced). But at the end I found that I cannot use regular lamps because you can place A LOT of lamps that are not relative to the your Screen/Indicator but they STILL will be checked for color change. So there's performance and logical reasons for that.

But it leads to sync problems in multiplayer. Plus from Factorio 0.15 the Lua Coroutines were excluded from Factorio. Basically right now I'm working on the same solution without Coroutines, but it still has multiplayer issues :(

4 years ago
(updated 4 years ago)

But it leads to sync problems in multiplayer. Plus from Factorio 0.15 the Lua Coroutines were excluded from Factorio. Basically right now I'm working on the same solution without Coroutines, but it still has multiplayer issues :(

Not tested, because I'm not on my Factorio computer, but these lines in global.lua look suspicious:

---Reference to the nauvis surface (only nauvis surface is available for now)
Surface = nil

---Array that stores all references to Pixels instances in the game
Pixels = nil

---List of pending pixels to update
Redraw_Queue = nil

Putting the variables in the global table (i.e. "global.Surface = nil" etc.) or defining them as local should prevent desyncs.

4 years ago
(updated 4 years ago)

To test this functionality you'll need to download version 0.5.1 of this mod (available on the Forum Thread) and Factorio version 0.14. It works fine in single-player, but the code is so complicated and disordered so it leads to desyncs there. I was using Coroutines there and wasn't aware of multyplayer-related code.

My complete new approach with iterational checkup and my new codebase is in the "work in progress" state, but you actually can see the code in my branch

Basically current code in global.lua works fine (tested in multiplayer many times), because I'm filling them every on_load event. If you read official documentation for on_load event (step number 6) you will see that it is meant to be used to only three, and ONLY 3 things:
1. Re-setup meta-tables. Meta-tables are not persisted through save-load.
2. Re-setup conditional event handlers (subscribing to an event only when some condition is true to save processing time).
3. Create local references to data stored in the global table

So what I do is basically creating local references to data stored in the global table during on_load event as it meant to be (option number 3). Also if you'll search for desync tutorial you'll find that it is allowed to use local references.

But I will test it a little bit more with no local references at all on my investigation on chunk-based updates. Thank you for mentioning that - maybe I should add "local" keyword or even get rid of them!
The mod works pretty well in the current state even in multiplayer for now but thank you again.

4 years ago
(updated 4 years ago)

I downloaded 2.0.1 and hosted a new multiplayer game with just Pixels and Creative Mod. When I joined the game as a second user, I got a desync immediately.

I then made some changes to the mod, restarted both instances of Factorio, put up some green LEDs as the first user, and connected as second user to the game hosted by the first. I then set up some red LEDs, switched to the host, and they appeared there in map view. That's not much of a test, but it seems my changes prevented the desync.

So here's what I did:

1) Commented lines 1 to 8 from scripts/global.lua -- that were your definitions of Surface, Pixel, and Redraw_Queue.
2) Added this line to control.lua:

local Surface, Pixels, Redraw_Queue

I inserted this right before

require('scripts.global')

Just give it a try!

New response