Minetest logo

IRC log for #minetest-dev, 2020-10-07

| Channels | #minetest-dev index | Today | | Google Search | Plaintext

All times shown according to UTC.

Time Nick Message
06:05 fluxflux joined #minetest-dev
06:40 NetherEran joined #minetest-dev
06:43 proller joined #minetest-dev
07:43 proller joined #minetest-dev
08:00 ShadowNinja joined #minetest-dev
09:08 calcul0n joined #minetest-dev
09:59 NetherEran joined #minetest-dev
10:32 Taoki joined #minetest-dev
11:05 Fixer joined #minetest-dev
12:43 Qiangong2[m] joined #minetest-dev
13:04 ShadowNinja joined #minetest-dev
13:04 basxto joined #minetest-dev
13:05 Fixer joined #minetest-dev
13:09 jas_ joined #minetest-dev
13:19 turtleman joined #minetest-dev
13:31 anon5[m] joined #minetest-dev
13:31 kb1000 joined #minetest-dev
13:31 Kimapr[m] joined #minetest-dev
13:56 djenkins_ joined #minetest-dev
13:57 dennisjenkins joined #minetest-dev
15:05 calcul0n joined #minetest-dev
15:47 proller joined #minetest-dev
15:48 calcul0n_ joined #minetest-dev
16:11 fluxflux joined #minetest-dev
17:29 mizux joined #minetest-dev
18:15 Krock j​osiah_wi: any success?
18:18 Krock #9417  easy review
18:18 ShadowBot https://github.com/minetest/minetest/issues/9417 -- Use "Aux" key name consistently by Wuzzy2
18:28 Miner_48er joined #minetest-dev
18:37 Fixer_ joined #minetest-dev
19:20 homthack joined #minetest-dev
19:33 Andrey01 joined #minetest-dev
19:33 Andrey01 New PR #10471
19:33 ShadowBot https://github.com/minetest/minetest/issues/10471 -- Add `table.len` method. by Andrey2470T
19:37 Krock use-cases?
19:42 Andrey01 read the PR description
19:56 Krock I don't see any use-case there
19:56 Krock it's just demonstrating what the function does, not where it could effectively be used in mods
19:58 MTDiscord <J​ordach> i overuse numerical keys because the # operator exists
19:59 Andrey01 I don`t know, I think elsewhere where getting of table length is used, it is difficult to say
20:00 Krock if length of the table matters, you'd use numeric indexing anyway. for non-numeric keys (mostly strings) you don't care about the amount
20:02 proller joined #minetest-dev
20:02 Andrey01 why do you say you don`t care about the amount? really are there not cases where you need to count amount of fields in an associative arrays?
20:03 MTDiscord <G​reenXenith> There are definitely cases where you care about the amount but index by string because it will lookup faster. In such a case, it is best to have a length key that you increment when adding values.
20:04 Andrey01 just all problem in # operator is it will return incorrect count if counting is implemented in asscociative arrays
20:05 MTDiscord <G​reenXenith> I dont think table.getn is deprecated in 5.1 (it is later though) so for Minetest specifically you can increment an n key yourself in a non-integer-indexed table, so table.getn will work on both your table and numerically indexed tables.
20:06 MTDiscord <G​reenXenith> Or just make your own function to return table.n or #table
20:06 MTDiscord <G​reenXenith> (probably the better option)
20:06 Andrey01 what is table.getn?
20:06 MTDiscord <G​reenXenith> google is your friend
20:06 celeron55 i think it's good practice in Lua to not use a counting len() like that
20:07 Andrey01 here is no such method
20:07 Andrey01 https://www.lua.org/manual/5.4/manual.html#6.6
20:07 MTDiscord <G​reenXenith> it doesnt exist in 5.4
20:08 MTDiscord <J​onathon> https://www.lua.org/pil/19.1.html or https://www.google.com/search?q=table.getn&amp;oq=table.getn&amp;aqs=chrome.0.69i59.2164j0j1&amp;sourceid=chrome&amp;ie=UTF-8
20:09 MTDiscord <G​reenXenith> regardless getn can be replaced with a oneliner functino
20:09 MTDiscord <G​reenXenith> function*
20:10 MTDiscord <G​reenXenith> But if you know the table you are working with has a length key, you dont even need a function
20:13 DS-minetest joined #minetest-dev
20:13 MTDiscord <G​reenXenith> you can also give your table a metatable to count for you and return the value with the # operator
20:16 pgimeno if it is implemented, I would not call it len, maybe count
20:17 DS-minetest G​reenXenith: afaik, the # operator can't be overridden for tables
20:17 MTDiscord <G​reenXenith> __len
20:19 pgimeno doesn't work for me
20:19 MTDiscord <G​reenXenith> works for me
20:19 DS-minetest G​reenXenith: http://www.lua.org/manual/5.1/manual.html#2.8 see the elseif type(op) == "table"
20:19 pgimeno a=setmetatable({},{__len=function() return 9 end}) ; print(#a) gives 0
20:19 MTDiscord <G​reenXenith> thats not how you use setmetatable
20:20 DS-minetest you can only override operators that would otherwise not work
20:20 MTDiscord <G​reenXenith> a={}; setmetatable(a, {__len=function() return 9 end}); print(#a)
20:20 MTDiscord <G​reenXenith> this works
20:20 pgimeno returns 0 for me
20:21 pgimeno are you sure you're using Lua 5.1?
20:21 DS-minetest http://www.lua.org/manual/5.1/manual.html#pdf-setmetatable setmetatable returns the first parameter
20:21 DS-minetest @G​reenXenith
20:22 DS-minetest seems to work for lua5.4
20:22 MTDiscord <G​reenXenith> Yeah thats what ive just figured
20:22 MTDiscord <G​reenXenith> Should work on 5.3 as well
20:22 MTDiscord <G​reenXenith> Minetest should really update
20:22 pgimeno it is implemented in 5.2
20:22 MTDiscord <G​reenXenith> BuT WhY wOuLD i EveR NeEd ThOSe FeATuReS??
20:23 Andrey01 I think it would be better to use function, not overriding an operator
20:23 pgimeno LuaJIT is stuck at 5.1, and it's essential to run servers at a half-decent speed
20:23 MTDiscord <G​reenXenith> the override operator is just for convenience
20:24 MTDiscord <G​reenXenith> the underlying method is still incrementing a length key
20:24 pgimeno __len is implemented in LuaJIT with a compilation option, http://luajit.org/extensions.html (search __len in the page)
20:25 DS-minetest you could set __newindex in the metatable to increase n (first check if it was nil)
20:25 MTDiscord <G​reenXenith> right
20:25 MTDiscord <G​reenXenith> that part of the metatable is still valid
20:31 Fixer joined #minetest-dev
21:34 Kray joined #minetest-dev
22:52 Okazaki joined #minetest-dev
22:53 DS-minetest clipping of boxes doesn't seem to work anymore
22:54 sfan5 huh?
22:56 DS-minetest no wonder, #8676 sets the clip rect to nullptr
22:56 ShadowBot https://github.com/minetest/minetest/issues/8676 -- Add gradients and borders to FormSpec boxes by v-rob
23:07 DS-minetest made a fix: #10473
23:07 ShadowBot https://github.com/minetest/minetest/issues/10473 -- Fix box[]es not being clipped by Desour

| Channels | #minetest-dev index | Today | | Google Search | Plaintext