friendlier exploratoration: additional fields, or override __tostring / __serialize, on userdata
Posted: Mon Aug 05, 2019 2:04 am
When I'm poking around in-game trying things out, or whatever, I frequently dump the results of some API operation to the game console using `game.print` and `serpent.line`.
Right now I then follow that with a loop over the values extracting `.name` because the representation of any API object is
It would be possible to augment this to be a tiny bit friendlier, in several possible ways. This would make it a little easier to interactively investigate the API through in-game stuff. Not exactly earth-shattering,
...or something similar. Nothing dynamic or even all that interesting, but just knowing that this is a LuaEntity, is useful, and getting the "most common fields" would often save me time and trouble extracting those couple fields when, eg, doing a get_entities in an area or whatever.
Right now I then follow that with a loop over the values extracting `.name` because the representation of any API object is
Code: Select all
{__self = "userdata: 0x...."}
set an extra field or two on construction with static values
Code: Select all
{__self="userdata: 0x...", _instance="LuaEntity", _type="accumulator", _name="fred"}