Adds mechanics to make vehicles behave as planes. [Takeoff/Landing, Runway Requirement]
Mods introducing new content into the game.
Transportation of the player, be it vehicles or teleporters.
Hi - I just wanted to say thank you for updating this mod, I love the immersive aircraft realism component. I wanted to file a bug report that I had when landing any plane in the mod. I am not sure if this bug was there before or not as I just tried out the mod today. Here is the lua traceback, looks like something happening with the inventory indexing? Thank you for your help and support of the mod.
Error while running event AircraftRealism::on_tick (ID 0)
Index out of inventory bounds.
stack traceback:
__AircraftRealism__/logic/planeTakeoffLanding.lua:8: in function 'insertItems'
__AircraftRealism__/logic/planeTakeoffLanding.lua:28: in function 'transitionPlane'
__AircraftRealism__/logic/planeTakeoffLanding.lua:123: in function 'planeLand'
__AircraftRealism__/logic/planeManager.lua:49: in function 'checkPlanes'
__AircraftRealism__/control.lua:13: in function <__AircraftRealism__/control.lua:8>
stack traceback:
[C]: in function '__index'
__AircraftRealism__/logic/planeTakeoffLanding.lua:8: in function 'insertItems'
__AircraftRealism__/logic/planeTakeoffLanding.lua:28: in function 'transitionPlane'
__AircraftRealism__/logic/planeTakeoffLanding.lua:123: in function 'planeLand'
__AircraftRealism__/logic/planeManager.lua:49: in function 'checkPlanes'
__AircraftRealism__/control.lua:13: in function <__AircraftRealism__/control.lua:8>
Hi, thanks for filing a bug report, you are right in that it is trying to transfer items to a non existent inventory,
Can you list the mods that you have installed? That may be the source of the problem since it appears to work fine for me
My guess is that one of your mods modified the size of the cargo inventory of the plane to be different when they are airborne and landed, thus it tried to index a slot that exists on one plane, but not on the other.
Sure no problem and thanks for your prompt reply, you are awesome! The main mod set I use is the AAI mod-pack, which I know heavily modifies all vehicles to have additional signal properties and likely additional 'ghost' slots to use the controller features/etc (though I have not dug into the code of that mod). I also have a few content things like extra sounds and alien biomes but I doubt those would be the issue. I can give you a full list if it is helpful. I will later try disabling AAI mods and see if that resolves the issue. If there is incompatibility with AAI mod set I would understand, it is a rather complex mod pack and overhauls a lot of things, but I like the additional complexity and even wanted to see if I could try and automate an airplane!
[Update] - in trying to support my own debugging, I have found that AAI mods classify the 'cargo plane' entity as a hauler type vehicle which adds special transfer code for the automatic industries. I tried excluding the cargo plane from the mod's added programmable feature set but that did not seem to have an effect (still crashes on landing). I'll keep trying to debug too, and thanks for your continued help!
Thanks for your debugging efforts, I have written a quick fix which will check the size of both inventories and will prevent the index from running out of range.
This appears to work for me in mitigating the crash but I am not sure if it is entirely compatible, here I have it attached if you want to give it a try and let me know if it fixes the issue.
Thanks, this fixed seemed to work for the gunship and the fortress aircraft, but I still receive a similar (but not identical) crash when landing with the cargo plane:
Error while running event AircraftRealism::on_tick (ID 0)
__AircraftRealism__/logic/planeTakeoffLanding.lua:37: attempt to compare nil with number
stack traceback:
__AircraftRealism__/logic/planeTakeoffLanding.lua:37: in function 'transitionPlane'
__AircraftRealism__/logic/planeTakeoffLanding.lua:123: in function 'planeLand'
__AircraftRealism__/logic/planeManager.lua:49: in function 'checkPlanes'
__AircraftRealism__/control.lua:13: in function <__AircraftRealism__/control.lua:8>
Thank you tremendously for your help.
Ah, this one is it trying to select a non existent weapon on the cargo plane, got that one fixed, hopefully this is the last one, I updated the link above
Hi haih_ys - Thanks for your continued support! This check might need nested logic, because I think according to the trace it finds a non-existent weapon and then immediately tries to run the validation check.
Error while running event AircraftRealism::on_tick (ID 0)
__AircraftRealism__/logic/planeTakeoffLanding.lua:38: attempt to compare nil with number
stack traceback:
__AircraftRealism__/logic/planeTakeoffLanding.lua:38: in function 'transitionPlane'
__AircraftRealism__/logic/planeTakeoffLanding.lua:124: in function 'planeLand'
__AircraftRealism__/logic/planeManager.lua:49: in function 'checkPlanes'
__AircraftRealism__/control.lua:13: in function <__AircraftRealism__/control.lua:8>
I also realized that AAI sets their vehicles to have only 1 gun per vehicle (and hard sets the index in the AAI Programmable Vehicles mod), which I am not sure exactly why but am going to ask in their discord. This is probably why they are not playing nice together.
[Update]
I think I found the problem, in the AAI mod he created a forced exception for the Aircraft vehicles:
-- aircraft mod
if data.raw.car["cargo-plane"] then
-- hauler types should not have guns
data.raw.car["cargo-plane"].guns = nil
end
-- more than 2 variants is excessive
if data.raw.car["gunship"] then
data.raw.car["gunship"].guns = { "aircraft-machine-gun", "aircraft-rocket-launcher"}
end
if data.raw.car["jet"] then
data.raw.car["jet"].guns = { "aircraft-machine-gun", "napalm-launcher"}
end
if data.raw.car["flying-fortress"] then
data.raw.car["flying-fortress"].guns = { "aircraft-cannon", "flying-fortress-rocket-launcher"}
end
I'm going to try and remove that code and use the exclude-vehicles flag for AAI and see if everything gets resolved.
Ah, I think I know why it crashes now, it checks the gun index, but there is actually no gun index on the NEW plane, which therefore causes it to crash.
I actually was unable to reproduce the crash with the AAI mods installed, which is strange, would you please list all your mods for me so I can install it too?
In the meantime, would you please try changing the following:
- Line 37, planeTakeoffLanding.lua
from
if utils.getTableLength(newPlane.prototype.guns) and -- Ensure it actually has weapons
to
if newPlane.selected_gun_index and
This should check for nil in both of the variables being compared, so it should not produce an error
I have made that change and I am able to go through the landing sequence without a crash. Thanks for your help.
For reference as you asked, my full mod list is:
All mods tagged "AAI" by Earendel (inc. vehicles, industry, signals, etc)
Aircraft
Alien Biomes + HD Terrain
Asphalt Roads + Dectorio
Bullet Trails
EvoGUI + YARM
FARL + Beautiful Bridge Railway
Shortcuts
To-Do List
Soundpack Alerts and Sirens
Speaker Signals + Speaker Signals 2
Alright that sounds great, now that it is fixed I'll send an update and mark this as closed