Reflection/Introspection
Posted: Sun Apr 08, 2018 10:25 pm
Q: How do I inspect Lua objects in-game?
The last time I worked in Lua on a game, I made myself a repl that let me live inspect things. So far the only Lua access I've found in Factorio is the ~ console via the /c command, and that doesn't provide access to the "data" object. If there's no in-game access to it, is there a recommended strategy for doing something like this during a module startup.
Specifically: I'm trying to replace the texture filename of the roboport entity and
doesn't doesn't produce a (let alone base.layers[0].filename).
What's the best way to:
- do something equivalent to Python's "dir(data.raw)" or "data.raw.keys()"?
- output that? log? print?
Code: Select all
print(data.raw.item["roboport"])
Specifically: I'm trying to replace the texture filename of the roboport entity and
Code: Select all
data:extend({
...
{
type="roboport",
name="roboport",
...
base = {
layers = {
{
filename = "...",
}
}
}
})
Code: Select all
data.raw.item["roboport"].base
What's the best way to:
- do something equivalent to Python's "dir(data.raw)" or "data.raw.keys()"?
- output that? log? print?