What did you do?
1. Place a non-player character entity inside a car.2. Store a LuaEntity reference to the non-player character entity.
3. Used a script to teleport the car to another surface.
To replicate, load the attached save and run the following command:
Code: Select all
/c game.print("Before teleport, storage.driver.valid="..tostring(storage.driver.valid)); storage.vehicle.teleport({0,0},"surface2"); game.print("After teleport, storage.driver.valid="..tostring(storage.driver.valid).." and storage.vehicle.get_driver().valid="..tostring(storage.vehicle.get_driver().valid))
What happened?
The stored LuaEntity reference is now invalid even though the same non-player character entity still exists in the car.What did you expect to happen instead?
I expected the stored LuaEntity reference to remain valid, since the entity it references still exists.Does it happen always, once, or sometimes?
Always. Note that Lua references to player-controlled characters do remain valid when teleported.Context:
This bug manifests when Vehicle Wagon 2 attempts to teleport an AAI Programmable Vehicles "AI Car" to the hidden storage surface. When it does this, the LuaEntity reference that AAI stores to the non-player AI driver character driving the car becomes invalid even though the AI driver character still exists in the car (same unit_number), and AAI creates a new (second) AI driver character.If this is intentional, then it would be nice to mention it in the documentation for LuaEntity::teleport().