Time |
Nick |
Message |
04:00 |
|
MTDiscord joined #minetest-dev |
04:26 |
|
servantofTestato joined #minetest-dev |
06:04 |
|
calcul0n__ joined #minetest-dev |
06:16 |
|
Charleston314 joined #minetest-dev |
06:16 |
|
YuGiOhJCJ joined #minetest-dev |
06:31 |
|
vampirefrog joined #minetest-dev |
07:42 |
|
runs joined #minetest-dev |
08:25 |
|
tekakutli joined #minetest-dev |
08:36 |
|
calcul0n joined #minetest-dev |
09:40 |
|
appguru joined #minetest-dev |
09:56 |
|
TenPlus1 joined #minetest-dev |
09:56 |
TenPlus1 |
Hi folks |
10:00 |
TenPlus1 |
Does anyone know a lot about initial_properties in objects ? |
10:04 |
MTDiscord |
<luatic> 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 |
<luatic> 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 |
<luatic> 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 |
<luatic> 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 |
<luatic> 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 |
<luatic> no, not quite |
10:13 |
MTDiscord |
<luatic> i'll get back to you after breakfast |
10:13 |
TenPlus1 |
no probs, enjoy and thanks |
10:43 |
|
tekakutli joined #minetest-dev |
10:44 |
|
tekakutli joined #minetest-dev |
10:44 |
|
tekakutli joined #minetest-dev |
10:45 |
|
tekakutli joined #minetest-dev |
11:04 |
|
Desour joined #minetest-dev |
11:20 |
MTDiscord |
<luatic> 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 |
<luatic> 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 |
<luatic> 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 |
<luatic> 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 |
<luatic> 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 |
<luatic> np |
11:29 |
MTDiscord |
<luatic> 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 |
<luatic> 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 |
<luatic> 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.<property> without requiring def.<property> to exist through metatable trickery. |
12:07 |
|
Desour joined #minetest-dev |
13:22 |
erle |
luatic sounds like you have a polyfill mod to publish |
15:44 |
|
grorp joined #minetest-dev |
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. |
16:33 |
|
ivanbu joined #minetest-dev |
18:53 |
rubenwardy |
sfan5: how can someone get the latest build on an rpi? I remember you have a ppa or builds or something |
21:06 |
|
grorp left #minetest-dev |
22:32 |
|
panwolfram joined #minetest-dev |
22:38 |
MTDiscord |
<mistere_123> I mean, building minetest is fairly trivial |
22:39 |
MTDiscord |
<mistere_123> There's also linux builds on gitlab (which ase hard to find and iirc don't have jit) |
23:02 |
|
sugarbeet joined #minetest-dev |