Skip to content

Commit a06b1eb

Browse files
committed
Another tweak for #235
Triggers seem to mis-fire when they are too close. It gets worse when they overlap, and better if further apart. Side triggers are now shortened by 15% when a front or rear trigger exists to hopefully improve this..
1 parent ecd6d57 commit a06b1eb

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

UniversalAutoload.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,9 @@ function UniversalAutoload:onLoad(savegame)
17821782
link(spec.loadVolume.rootNode, leftPickupTrigger.node)
17831783

17841784
local width, height, length = 1.66*spec.loadVolume.width, 2*spec.loadVolume.height, spec.loadVolume.length+spec.loadVolume.width/2
1785+
if spec.frontUnloadingOnly or spec.rearUnloadingOnly or spec.isCurtainTrailer then
1786+
length = 0.85 * length
1787+
end
17851788

17861789
setRotation(leftPickupTrigger.node, 0, 0, 0)
17871790
setTranslation(leftPickupTrigger.node, 1.1*(width+spec.loadVolume.width)/2, 0, 0)
@@ -1798,6 +1801,9 @@ function UniversalAutoload:onLoad(savegame)
17981801
link(spec.loadVolume.rootNode, rightPickupTrigger.node)
17991802

18001803
local width, height, length = 1.66*spec.loadVolume.width, 2*spec.loadVolume.height, spec.loadVolume.length+spec.loadVolume.width/2
1804+
if spec.frontUnloadingOnly or spec.rearUnloadingOnly or spec.isCurtainTrailer then
1805+
length = 0.85 * length
1806+
end
18011807

18021808
setRotation(rightPickupTrigger.node, 0, 0, 0)
18031809
setTranslation(rightPickupTrigger.node, -1.1*(width+spec.loadVolume.width)/2, 0, 0)
@@ -4535,7 +4541,7 @@ function UniversalAutoload:ualPlayerTrigger_Callback(triggerId, otherActorId, on
45354541
local spec = self.spec_universalAutoload
45364542
local playerId = player.userId
45374543

4538-
if onEnter then
4544+
if onEnter or onStay then
45394545
UniversalAutoload.updatePlayerTriggerState(self, playerId, true)
45404546
UniversalAutoload.forceRaiseActive(self, true)
45414547
else
@@ -4556,7 +4562,7 @@ function UniversalAutoload:ualLoadingTrigger_Callback(triggerId, otherActorId, o
45564562
local object = UniversalAutoload.getNodeObject(otherActorId)
45574563
if object ~= nil then
45584564
if UniversalAutoload.getIsValidObject(self, object) then
4559-
if onEnter then
4565+
if onEnter or onStay then
45604566
UniversalAutoload.addAvailableObject(self, object, triggerId)
45614567
elseif onLeave then
45624568
UniversalAutoload.removeAvailableObject(self, object, triggerId)
@@ -4572,7 +4578,7 @@ function UniversalAutoload:ualUnloadingTrigger_Callback(triggerId, otherActorId,
45724578
local object = UniversalAutoload.getNodeObject(otherActorId)
45734579
if object ~= nil then
45744580
if UniversalAutoload.getIsValidObject(self, object) then
4575-
if onEnter then
4581+
if onEnter or onStay then
45764582
if debugLoading then print(" UnloadingTrigger ENTER: " .. tostring(object.id)) end
45774583
UniversalAutoload.addLoadedObject(self, object)
45784584
elseif onLeave then
@@ -4658,6 +4664,7 @@ function UniversalAutoload:addAvailableObject(object, triggerId)
46584664
end
46594665

46604666
if spec.availableObjects[object] == nil and spec.loadedObjects[object] == nil then
4667+
if debugLoading then print(tostring(object.id) .. " IN " .. tostring(triggerId)) end
46614668
spec.availableObjects[object] = object
46624669
spec.objectToTriggerId[object] = triggerId
46634670
spec.totalAvailableCount = spec.totalAvailableCount + 1
@@ -4681,6 +4688,7 @@ function UniversalAutoload:removeAvailableObject(object, triggerId)
46814688
local isActiveForLoading = spec.isLoading or spec.isUnloading or spec.doPostLoadDelay
46824689

46834690
if spec.availableObjects[object] ~= nil and (triggerId == nil or spec.objectToTriggerId[object] == triggerId) then
4691+
if debugLoading then print(tostring(object.id) .. " OUT " .. tostring(triggerId)) end
46844692
spec.availableObjects[object] = nil
46854693
spec.objectToTriggerId[object] = nil
46864694
spec.totalAvailableCount = spec.totalAvailableCount - 1

modDesc.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modDesc descVersion="79">
33

44
<author>loki_79</author>
5-
<version>1.5.1.7</version>
5+
<version>1.5.1.8</version>
66

77
<title>
88
<en>Universal Autoload</en>

0 commit comments

Comments
 (0)