local itemname = minetest.registered_aliases["itemname"] or "itemname"
Was just concerned someone could follow along and end up with a heap of globals defined not to mention quoting around a variable/table name which would lead to some fun crashes.
I am new to MT modding and I have been puzzling over this exact example in the book. I understand creating an alias, I think, and I have seen that in mods I am looking at, but the sentence "Mods need to make sure to resolve aliases before dealing directly with item names, as the engine won’t do this." tells me I need to do something important with this itemname = minetest.registered_aliases... but I can't tell when or where I must do it.
Is it used before the item name is needed, to check if there is an alias? An example of where might help.
I've been digging for info on ABM's a little more detailed than ABM == limit use. I'm not sure if some of the info Krock supplied when answering a question could be added to the ABM section or another section? I know it doesn't really fit the modding book but also doesn't fit the API info very well either. Sort of nice technical info to know when your tinkering around with ABM's or rather trying to avoiding using them or make an ABM process more efficient. I thought this was pretty interesting info and I can't think of any other way to try and save it so others can find it more easily.
A few basics for understanding what's happening in the code (entire function).
1) There's some node caching, but the final effect is negligible (why? see below).
2) ABMHandler::apply is called for each active mapblock (next to players, usually)
3) Each node is checked whether it has ABMs assigned to it (3x for-loop)
4) Each ABM is run and checked for its probability (chance value) and neighbour nodes (3x3x3-1 checks)
5) If everything's fine, the Lua callback from the ABM definition is run
So in the worst case there are 1 + 3 + 1 + 3 loops that have to be executed each second. In a test world this takes ~60us to execute it each second. See F6 profiler "SEnv: modify in blocks avg per interval" (average value).
What likely matters here is the amount of code executed in the Lua callback.
Things that make ABMs faster (top = most effective)
Either use LBMs or node timers to replace ABMs (saves up to 8 loops)
Good day rubenwardy,
the german translation is now rebased since 1 month, and up-to-day, but still waits without an answer for a merge. I would be happy about an answer (at least). Thankyou!