Page 3 of 4

Re: [MOD 0.14] VehicleSnap

Posted: Fri Dec 16, 2016 6:33 pm
by Rseding91
Zaflis wrote:Current start of the script is now:

Code: Select all

global.lastorientation = {}
global.player_ticks = {}
global.tick = 2

script.on_configuration_changed(function(data)
  if data.mod_changes == nil then return end
  if global.lastorientation == nil then global.lastorientation = {} end
  if global.player_ticks == nil then global.player_ticks = {} end
  if global.tick == nil then global.tick = 2 end
end)
Unless you convince me to put first 3 lines inside on_init, i'd consider it solved :) It worked in all test cases i could think of, but obviously i cannot test multiplayer sync.

Also the mod is using the game.players directly. Say your player index is 4 and you're driving a car. If player index 3 leaves the game, you will now be index 3, no? If that happens you might see your snap variable reset.
That's fine to put them there. The game overwrites the global values on load so it's save/load safe.

It wouldn't hurt to put them in on_init but it doesn't hurt to have them here either.

Re: [MOD 0.14] VehicleSnap

Posted: Fri Dec 16, 2016 7:49 pm
by Arumba
So for the next MP session we do, should we leave it disabled, manually modify and share a version of it based on the previous comments, or is it going to be updated on the portal? I'm more than willing to provide a solid MP testing ground for it. I can get ~50+ players in a game very quickly if it needs to be stress tested or something.

Re: [MOD 0.14] VehicleSnap

Posted: Fri Dec 16, 2016 8:05 pm
by Zaflis
Would you test with the version i uploaded in previous page? download/file.php?id=19401
If that makes a difference i'll upload it to mod portal.

No, you don't need to disable it. The recent 1.14.21 version seemed to fix all the errors even related to mod updating.

Re: [MOD 0.14] VehicleSnap

Posted: Fri Dec 16, 2016 8:14 pm
by Arumba
Zaflis wrote:Would you test with the version i uploaded in previous page? download/file.php?id=19401
If that makes a difference i'll upload it to mod portal.

No, you don't need to disable it. The recent 1.14.21 version seemed to fix all the errors even related to mod updating.
Okay, will try it with MASA session and then later tonight with the large scale MP session we've been running this week. Thanks! Will report back if it breaks the whole world.

*Edit*

We recorded ~3 hours today without any issues. Then again we had no issues in our previous session, but still, things look good on this end.

Re: [MOD 0.14] VehicleSnap

Posted: Sat Dec 17, 2016 4:06 pm
by Nexela
Zaflis wrote:Current start of the script is now:
Also the mod is using the game.players directly. Say your player index is 4 and you're driving a car. If player index 3 leaves the game, you will now be index 3, no? If that happens you might see your snap variable reset.
The player index will stay the same

Re: [MOD 0.14] VehicleSnap

Posted: Sat Dec 17, 2016 8:24 pm
by Zaflis
Good to know. I'll upload it to portal.

Re: [MOD 0.14] VehicleSnap

Posted: Mon May 01, 2017 6:52 am
by MainTango
This mod is absolutely blissful. I have a request but I don't know if it's possible or not. Would you consider adding a hotkey to toggle the mod's functionality on/off during gameplay?

Re: [MOD 0.14] VehicleSnap

Posted: Mon May 01, 2017 8:39 am
by Zaflis
It seems possible: viewtopic.php?f=25&t=30644

Any key suggestions? It might be that to change keys one would have to open the zip file and edit a file. Shift-V is 1 option that comes to mind.

Also since it's multiplayer compatible mod, i'd have to globally sync the snapping state per player and finding which one is the local self. I just hope it would be simple...

Re: [MOD 0.14] VehicleSnap

Posted: Mon May 01, 2017 9:13 am
by MainTango
Zaflis wrote:It seems possible: viewtopic.php?f=25&t=30644

Any key suggestions? It might be that to change keys one would have to open the zip file and edit a file. Shift-V is 1 option that comes to mind.

Also since it's multiplayer compatible mod, i'd have to globally sync the snapping state per player and finding which one is the local self. I just hope it would be simple...
I wish I could be of assistance with the multiplayer thing but I'm just garbage with these things.
As far as key suggestions, shift+V sounds good. You could even do shift+W if you ask me. No idea whether other mods already use that.
Users can remap it should there be any conflicts. The control settings menu even has a Mods tab nowadays :D

Re: [MOD 0.14] VehicleSnap

Posted: Mon May 01, 2017 10:41 am
by Nexela
control.lua

Re: [MOD 0.15] VehicleSnap

Posted: Mon May 01, 2017 1:19 pm
by Zaflis
That's really nice code. You changed so much though that i don't know for sure if things still work or not. I had checks to ensure that mod works even in the case that it's added after the world was created, or if mod was updated.

Code: Select all

if pdata.player_ticks > 1 then
That's first reference to player_ticks. Is it safe to compare it to number if it doesn't exist yet? I used to have some crashes in my testing with similar code. I may not have time to test today.

Re: [MOD 0.15] VehicleSnap

Posted: Tue May 02, 2017 10:10 am
by Zaflis
I knew it, they need to be initialized somewhere

Code: Select all

Error while running event VehicleSnap::on_tick (ID 0)
__VehicleSnap__/control.lua:46: attempt to perform arithmetic on field 'lastorientation' (a nil value)
I also need to add data.lua

Code: Select all

data:extend({
  {
    type = "custom-input",
    name = "VehicleSnap-toggle",
    key_sequence = "SHIFT + V",
    consuming = "script-only"
  }
})
and related locale for controls menu. Will see how goes...

Re: [MOD 0.15] VehicleSnap

Posted: Tue May 02, 2017 10:34 am
by Nexela
Zaflis wrote:That's really nice code. You changed so much though that i don't know for sure if things still work or not. I had checks to ensure that mod works even in the case that it's added after the world was created, or if mod was updated.

Code: Select all

if pdata.player_ticks > 1 then
That's first reference to player_ticks. Is it safe to compare it to number if it doesn't exist yet? I used to have some crashes in my testing with similar code. I may not have time to test today.
Oooops good catch, fixed above

Looks like I forgot the on_init, The above code is fixed and should handle everything correctly.

All of it is untested though, I will leave that up to you. :)

Re: [MOD 0.15] VehicleSnap

Posted: Tue May 02, 2017 10:47 am
by Nexela
Just noticed some spots say lastorientation and others say last_orientation fixing above so they are consistent :)

Re: [MOD 0.15] VehicleSnap

Posted: Tue May 02, 2017 11:21 am
by Zaflis
Yeah i noticed those earlier too, also i needed to use the snap variable in player loop for toggle functionality. I got everything working as far as i can tell, so 1.15.1 is released. I only tested in singleplayer and private multiplayer without others. The mod toggle key can be changed from Factorio's controls menu. And thanks for helps :)

Re: [MOD 0.15] VehicleSnap

Posted: Tue May 02, 2017 9:49 pm
by MainTango
Hotkey works like a charm for me. Thanks a lot for implementing it :D

Re: [MOD 0.15] VehicleSnap

Posted: Fri Jul 21, 2017 10:43 pm
by widders
Hey, love the mod although it still can't make up for my inept driving.

One thing I noticed in 0.15.28-30 at least it doesn't work when driving backwards. I don't know if that was intentional but it's a bit annoying sometimes.

Re: [MOD 0.15] VehicleSnap

Posted: Fri Jul 21, 2017 10:54 pm
by widders
I thought I'd have a look and I found the problem. Line 51 of control.lua:

Code: Select all

if player.vehicle.speed > 0.1 then
needs a math.abs(player.vehicle.speed) to cover backwards as well, I tried it seems to work fine :p

Re: [MOD 0.15] VehicleSnap

Posted: Fri Jul 21, 2017 11:02 pm
by Zaflis
It was a little delicate subject, in the end i thought reverse is so slow and rarely used that it wouldn't benefit much of snapping. Did you test if tanks reach reverse speed of -0.1? If the number is put too low, one old bug would resurface... That was a tricky one too, that vehicle gets stuck on anything solid such as structures or shoreline. That's why i had to not snap in low speeds.

Re: [MOD 0.15] VehicleSnap

Posted: Tue Oct 10, 2017 6:34 pm
by sarcolopter
just updated, looks like that broke it