Time Nick Message 09:56 TenPlus1 Hi folks 10:00 TenPlus1 Does anyone know a lot about initial_properties in objects ? 10:04 MTDiscord It's documented in the "object properties" section, what do you need? 10:05 TenPlus1 Am looking for the reason it was changed and why 10:05 TenPlus1 going through old pull requests and merged and cannot find initial addition and why it was added 10:07 MTDiscord Ah, that I do not know. But it makes sense from a namespacing perspective to not put the lua entity related stuff (including callbacks) and the properties into the same table. 10:08 TenPlus1 am trying to update my mods to be compatible but keep getting errors about deprecation even when I use initial_properties 10:08 TenPlus1 I'm doing something wrong but the information in lua_api is rather scant 10:09 TenPlus1 either that or it breaks compatibility 10:09 MTDiscord Could you show an example of (1) how you use initial_properties (2) the deprecation warning you're getting? 10:10 TenPlus1 using new 5.7dev run mobs redo and mobs animal, place sheep, boom error straight away 10:10 TenPlus1 2023-09-23 11:10:35: WARNING[Server]: Reading initial object properties directly from an entity definition is deprecated, move it to the 'initial_properties' table instead. (Property 'hp_max' in entity 'mobs_animal:bee') 10:11 TenPlus1 when changing to initial_properties table, it breaks api 10:11 MTDiscord Yes, hp_max is an object property which you have in your entity definition. You should rename the field to _hp_max and replace all self.hp_max with self._hp_max. 10:12 MTDiscord You could also use initial properties for this, esp. if mods expect to read hp_max from there. But that will likely make your code slower and slightly less readable. 10:12 TenPlus1 so renaming all preset object vars to have an underscore before it ? 10:13 MTDiscord no, not quite 10:13 MTDiscord i'll get back to you after breakfast 10:13 TenPlus1 no probs, enjoy and thanks 11:20 MTDiscord So. Basically you have to move properties from the entity definition to initial properties now. Of course this means you can't access them as self.property anymore. You could simply access them as self.initial_properties.property though. 11:21 TenPlus1 yeah I've just changed mobs api to do just that and got it working 11:22 TenPlus1 I'm still curious as to WHY this change was forced when the old way worked fine, and if a mod dev wanted to tidy their variables they could have simple added a table themselves 11:22 MTDiscord Great. As for backwards compat: Is the hp_max property used by any other mods? Do any mods expect entity.hp_max to be the hp max? 11:22 TenPlus1 I'm going to have to go through all mods to test this 11:22 TenPlus1 again, why force a change that will break mods, it's insane 11:23 MTDiscord TenPlus1: btw, per convention, custom entity definition fields should start with an underscore 11:23 TenPlus1 and worlds containing old objects not containing the changes are gonna break new changes 11:24 MTDiscord TenPlus1: Huh? How is this a world issue? As far as I can see, this is only a mod issue, not a world issue. 11:24 MTDiscord I don't think object property serialization was broken. 11:24 TenPlus1 will need to put some bulletproofing into mods that expect the new values to check for the old one's too 11:27 TenPlus1 this is my point though, you use initial_properties to host object variables now, mods need to be tailored to use it, but putting checks for the old values will show deprecation errors 11:28 TenPlus1 many thanks for your help lunatic, will begin testing to see how changes take 11:28 MTDiscord np 11:29 MTDiscord also, i think the change does make sense; self.initial_properties.hp_max makes more sense than self.hp_max - it makes it explicit that you're really reading an initial property here 11:29 MTDiscord I think it is probably possible to find a solution that makes Minetest happy while providing backwards compatibility. It will probably be hacky though. 11:37 MTDiscord Okay. So basically entities use the entity definition as a metatable. You want absent fields (like hp_max) to index initial_properties. You can do that using a metatable on the entity definition, but it would trigger the deprecation warning. HOWEVER you should be able to do local def = minetest.registered_entities["mymod:myentity"]; def.__index = function(_, key) local val = def[key]; if val ~= nil then return val end return 11:37 MTDiscord def.initial_properties[key] --[[TODO add deprecation warning]] end (untested). This will effectively allow you to continue using self. without requiring def. to exist through metatable trickery. 13:22 erle luatic sounds like you have a polyfill mod to publish 15:55 grorp Merging #13829 in 10min 15:55 ShadowBot https://github.com/minetest/minetest/issues/13829 -- Fix error when enabling texture packs in the "Content" tab by grorp 16:21 grorp Done. 18:53 rubenwardy sfan5: how can someone get the latest build on an rpi? I remember you have a ppa or builds or something 22:38 MTDiscord I mean, building minetest is fairly trivial 22:39 MTDiscord There's also linux builds on gitlab (which ase hard to find and iirc don't have jit)