My (attached) mod works fine in single player, it moves the ore where I expect it to when I expect it to. When I fire up a 2 player game with a friend the ore only moves on my screen regardless of who placed my machine, and eventually we desync, usually after interacting with moved ore or the place it is/was.
I'm using entity.teleport() around line 76 of control.lua. The other possibility that occurs to me is that I'm doing something wrong when I subscribe to a couple events around line 10.
Any advice on how to be more multiplayer friendly is welcome, even just general rules of thumb or links to guides.
Desync when teleporing ore entities
Desync when teleporing ore entities
- Attachments
-
- Resource_Relocation_Machine_0.0.1.zip
- (27.84 KiB) Downloaded 51 times
Re: Desync when teleporing ore entities
You're subscribing to 2 event handlers in the on_load event unconditionally which means that anyone loading into an existing game will subscribe to them while the first player who created the map will not have them subscribed.
It looks like you don't understand how event handlers work and when you should subscribe to them.
It looks like you don't understand how event handlers work and when you should subscribe to them.
If you want to get ahold of me I'm almost always on Discord.
Re: Desync when teleporing ore entities
Ah. You're right that I don't understand event handlers, I'll have to study up on them. I put them where they're at in a fit of awkward bug hunting, and I only understood them well enough to borrow them from the mod I was using for reference (Item Collectors).
Do I just move them outside any other code blocks like they were in Item Collectors? And does that have any implications for using it on maps created before my mod was installed?
And thanks for pointing me at the broken bit of code. I don't have much coding experience and most of that has been with Visual Studio and the ability to step through with a debugger.
edit: And I realized right after posting that you wrote Item Collectors, Rseding. Thanks for the clear simple code to look at, and your use of the MIT license.
Do I just move them outside any other code blocks like they were in Item Collectors? And does that have any implications for using it on maps created before my mod was installed?
And thanks for pointing me at the broken bit of code. I don't have much coding experience and most of that has been with Visual Studio and the ability to step through with a debugger.
edit: And I realized right after posting that you wrote Item Collectors, Rseding. Thanks for the clear simple code to look at, and your use of the MIT license.