loki79uk / FS22_UniversalAutoload

Mod for FS22. Please download latest release below.
122 stars 35 forks source link

Krone Profi Liner can't be load/unload from rear when back door opened #235

Closed harokyang closed 5 months ago

harokyang commented 5 months ago

In debug mode, there is no detect zone at the rear of the profi liner, no matter the door opened or not I tried isBoxTrailer, noLoadingFolded, and removed enableSideLoading All doing nothing. Seems the Liner is hardcoded to only consider side loading I use the Straw Harvest Pack DLC storage building The loading area of the storage is only wide enough for rear unload

harokyang commented 5 months ago

is it possible to implement a partially unload feature Trailer will unload to an area until the area is full, and will wait for clearance then unload more The area check interval could be set longer to save performance. And make sure thing won't popup instantly when player or sotrage just removed the objects This will ease lots of “unable to unload” case, as the player could just park the trailer, set it to unload, then manually move those unloaded objects from the unloading area, and new objects will unloaded automatically

It looks like some workers on trailer only responsible for unload objects to the immediate area near the trailer until no place to unload, and someone else take the job to move them out and make space available again so the trailer worker can unload again

loki79uk commented 5 months ago

You should use the special "isCurtainTrailer" for all of the features, including only loading when the rear door is open. Are you making your own config here? Always use (or look at) the default ones as a starting point: https://github.com/loki79uk/FS22_UniversalAutoload/blob/main/config/SupportedVehicles.xml#L31-L34

loki79uk commented 5 months ago

is it possible to implement a partially unload feature

I originally planned to make a UAL specialisation for buildings, then we could coordinate the loading and unloading between them, but then GIANTS did their one and it complicated matters. One of the main limiting factors is how much information about loaded pallet positions is stored in the save game file between saves. I will try something like this in UAL2, but it is too big of a change to make to the current version.

loki79uk commented 5 months ago

Can you add me on discord for these kind of configuration issues and discussions about feature requests. I'd prefer to use GitHub issues only for actual bugs, it makes it look like I have a lot of work to do! :D

harokyang commented 5 months ago

I'm already use the default setting, nothing happened with Liner's back door Also I found the StrawPelletsPallet is not recognized by UAL. I see the object is listed in mod xml, but the pallet is not highlighted in debug mode All tested with default xml setting

Edited: Oh, just saw your updated 1.5.1.5 release. I will try that

loki79uk commented 5 months ago

Okay, I see what you mean - there is no "standard" rear loading from the back doors for the curtain trailer, as you would get for the box trailers. I think there was a good reason that I did it this way, but I will try this evening to see if I can remember why. The rear door open/closed should prevent manual loading with a forklift by physically blocking access to the (manual) rear loading trigger.

loki79uk commented 5 months ago

I have had a look and have mostly remembered the problem. UAL needs to know the trigger id for each identified pallet, but I don't store it anywhere. I used to exclude pallets at a much earlier stage, but then they are not available for debugging display or any later logic.

So all of this (old) logic is no longer used because the trigger id is never passed in: https://github.com/loki79uk/FS22_UniversalAutoload/blob/2347d525eb5eb76fb39035fd1e4d947ead7ac525/UniversalAutoload.lua#L3980

For most vehicles we never care which trigger detected the pallets, only the curtain trailer. And I decided that it was too risky to potentially break all the working logic just for that, so left it with loading only when a curtain is open, and therefore only used the side triggers. The manual loading is affected (physically) by the rear doors being open or closed.

Having said that, I'll try to have another go when I get some inspiration. I have recently started working on a complete re-write ready for FS25, so hopefully I can improve the design for next time..

loki79uk commented 5 months ago

Try this now for rear loading on the KRONE: https://github.com/loki79uk/FS22_UniversalAutoload/releases/tag/v1.5.1.6

.

Edited: Oh, just saw your updated 1.5.1.5 release. I will try that

Did this solve the straw pallet issue?

harokyang commented 5 months ago

Try this now for rear loading on the KRONE: https://github.com/loki79uk/FS22_UniversalAutoload/releases/tag/v1.5.1.6

.

Edited: Oh, just saw your updated 1.5.1.5 release. I will try that

Did this solve the straw pallet issue?

Yes, 1.5.1.5 is ok But there is an issue in Straw Harvest itself, the palletizer machine won't detect output has been cleaned if pallets are loaded by autoload, and won't start packing again. So autoload is useless for the hall

harokyang commented 5 months ago

I tried your 1.5.1.6 Seems the rear load only works if one of the side curtain opened If both side curtain closed, but only the rear door opened, the load action won't show up

loki79uk commented 5 months ago

I tried your 1.5.1.6 Seems the rear load only works if one of the side curtain opened If both side curtain closed, but only the rear door opened, the load action won't show up

Good point, I forgot to test that. I'll look again this evening after work.

loki79uk commented 5 months ago

Yes, 1.5.1.5 is ok But there is an issue in Straw Harvest itself, the palletizer machine won't detect output has been cleaned if pallets are loaded by autoload, and won't start packing again. So autoload is useless for the hall

I'll see if there is anything that can be done about this as well, but may be harder since it is another mod. Can always send them a suggested fix if I find one.

harokyang commented 5 months ago

Another issue is You drive by an object, and the object entered side loading area If you continue driving, and the object exit the side loading area but still in the rear loading, the object will be considered not for loading It's also happened if you drive backward and the object enter the rear area first than enter the side area, it will also not be marked for loading You may need a enter/exit counter for object instead of a boolean flag

loki79uk commented 5 months ago

Another issue is You drive by an object, and the object entered side loading area If you continue driving, and the object exit the side loading area but still in the rear loading, the object will be considered not for loading It's also happened if you drive backward and the object enter the rear area first than enter the side area, it will also not be marked for loading You may need a enter/exit counter for object instead of a boolean flag

Okay, yes that might work better, or I need to separate the two triggers so that they don't overlap or touch. I guess the issue is that part of a pallet enters the next trigger before the original part has left, so can actually be in both at once (unlike left vs right).

loki79uk commented 5 months ago

I think this is better now, but please test and let me know! https://github.com/loki79uk/FS22_UniversalAutoload/releases/tag/v1.5.1.7

harokyang commented 5 months ago

I think this is better now, but please test and let me know! https://github.com/loki79uk/FS22_UniversalAutoload/releases/tag/v1.5.1.7

Good job, it works much better now In most case it is correct, but still failed in one corner case If you drive by one object, and when the object is at the middle of both loading area(recognized by both) Immediately stop the vehicle, and start driving in opposite direction When the object exits one loading zone but still in another, it will not be marked for loading

loki79uk commented 5 months ago

Good job, it works much better now In most case it is correct, but still failed in one corner case If you drive by one object, and when the object is at the middle of both loading area(recognized by both) Immediately stop the vehicle, and start driving in opposite direction When the object exits one loading zone but still in another, it will not be marked for loading

Can you take a screenshot of the position where it happens? I've been testing like this and is always detected by one or the other: image

I guess we have to make it so it enters both triggers on exactly the same frame.

harokyang commented 5 months ago

Seems you need a lot of objects to reproduce the issue

First drive forward, the pallets is in the side loading area, and marked for loading image

Keep driving forward until part of the bread pallet entered the rear loading area, but still inside the side loading area You can still load the bread pallet at the moment image

Now drive backward and let the bread pallet exit the rear loading area, but still in the side loading area. The bread pallet can't be loaded now image

I can't easily reproduce it if only test with one object

loki79uk commented 5 months ago

I think this may just be a game engine bug.. I tried this:

function UniversalAutoload:ualLoadingTrigger_Callback(triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId)
    if self ~= nil and otherActorId ~= 0 then
        local spec = self.spec_universalAutoload
        local object = UniversalAutoload.getNodeObject(otherActorId)
        if object ~= nil then
            if onStay then print("onStay" .. tostring(object.id)) end
            if UniversalAutoload.getIsValidObject(self, object) then
                if onEnter or onStay then
                    UniversalAutoload.addAvailableObject(self, object, triggerId)
                elseif onLeave then
                    UniversalAutoload.removeAvailableObject(self, object, triggerId)
                end
            end
        end
    end
end

Thinking we will keep adding it using the "onStay" flag, but it is never true. The print("onStay" .. tostring(object.id)) just never happens, ever.

Maybe I need to set some other parameter when creating the trigger to make it trigger this "onStay" event.. I can't try anymore now, but I'll look at it again later!

loki79uk commented 5 months ago

Simply moving the triggers apart seems to help a lot for me. Please try with your test cases and see if it is any better! https://github.com/loki79uk/FS22_UniversalAutoload/releases/tag/v1.5.1.8

harokyang commented 5 months ago

Simply moving the triggers apart seems to help a lot for me. Please try with your test cases and see if it is any better! https://github.com/loki79uk/FS22_UniversalAutoload/releases/tag/v1.5.1.8

I think it's flowless now 👍

loki79uk commented 5 months ago

I think it's flowless now 👍

Great! Thanks for all the testing, and for reporting in the first place.

I think it must be related to how the game engine detects objects in triggers. I noticed that entering is triggered by just the first edge touching the trigger, but leaving seems to happen more like when the centre moves out of the trigger. I could probably improve this by constantly updating the objects inside the trigger, but I expect this would have a significant hit on performance and is probably why GIANTS don't activate the 'onStay' flag either.