Invalid QualityID Error When Calling `get_max_wire_distance()` in Factorio 2.0
Posted: Wed Jan 14, 2026 12:21 pm
Description:
I'm encountering a persistent error when calling the `get_max_wire_distance()` method on `LuaEntityPrototype` objects in Factorio 2.0. I've tried multiple approaches but all are failing with the same error.
Environment:
- Factorio Version: 2.0.72
Problem:
When calling `prototype:get_max_wire_distance()` (where prototype is a valid `LuaEntityPrototype` for an electric pole), I get the error:
Invalid QualityID: expected LuaQualityPrototype or string.
Old Code (Working in 1.1):
New Code Attempts (All Failing in 2.0):
I've tried the following approaches, all resulting in the same "Invalid QualityID" error:
1. No parameters:
2. Passing nil:
3. Passing quality string:
4. Passing valid LuaQualityPrototype:
Debug Information:
- `prototypes.quality` exists and contains valid quality prototypes
- `prototypes.quality["normal"]` returns `[LuaQualityPrototype: normal (quality)]`
- All calls to `get_max_wire_distance()` fail with the same error regardless of parameter type
- The entity prototype is valid (it's `big-electric-pole`)
Current Workaround:
I've implemented a temporary workaround using hardcoded default values, but this is not ideal:
Question:
Has anyone successfully called `get_max_wire_distance()` in Factorio 2.0? What's the correct way to pass the QualityID parameter? Is there a change in the API that I'm missing?
Any help or insights would be greatly appreciated!
I'm encountering a persistent error when calling the `get_max_wire_distance()` method on `LuaEntityPrototype` objects in Factorio 2.0. I've tried multiple approaches but all are failing with the same error.
Environment:
- Factorio Version: 2.0.72
Problem:
When calling `prototype:get_max_wire_distance()` (where prototype is a valid `LuaEntityPrototype` for an electric pole), I get the error:
Invalid QualityID: expected LuaQualityPrototype or string.
Old Code (Working in 1.1):
Code: Select all
-- Factorio 1.1 implementation
local prototype = game.entity_prototypes[name]
local reach = prototype.max_wire_distance
I've tried the following approaches, all resulting in the same "Invalid QualityID" error:
1. No parameters:
Code: Select all
local prototype = prototypes.entity[name]
local reach = prototype:get_max_wire_distance()
Code: Select all
local reach = prototype:get_max_wire_distance(nil)
Code: Select all
local reach = prototype:get_max_wire_distance("normal")
Code: Select all
local quality = prototypes.quality["normal"] -- This is a valid LuaQualityPrototype object
local reach = prototype:get_max_wire_distance(quality)
- `prototypes.quality` exists and contains valid quality prototypes
- `prototypes.quality["normal"]` returns `[LuaQualityPrototype: normal (quality)]`
- All calls to `get_max_wire_distance()` fail with the same error regardless of parameter type
- The entity prototype is valid (it's `big-electric-pole`)
Current Workaround:
I've implemented a temporary workaround using hardcoded default values, but this is not ideal:
Code: Select all
local default_distances = {
["small-electric-pole"] = 7.5,
["medium-electric-pole"] = 9,
["big-electric-pole"] = 18,
["substation"] = 18
}
local reach = default_distances[name] or 10
Has anyone successfully called `get_max_wire_distance()` in Factorio 2.0? What's the correct way to pass the QualityID parameter? Is there a change in the API that I'm missing?
Any help or insights would be greatly appreciated!