jit.os - Works only on luajit, but that is what 99.9% of luanti users have (i wish luanti didn't support lua5.1)
This is a cool way to detect what operating system the server has too, just not as simple as checking jit.os
as for the API i am kinda confused why you use functions to get stuff, i think i would do:
-- info from the source code of this modos_detector={os=info.OS,is_multicraft=info.MultiCraftorfalse,-- maybe use core.get_version() instead if avaliable, or just don't support versions that don't have thatis_mobile=info.mobile}
Huh interesting, jit.os is a thing? I'll give it a lookie. Do you know what the home folder or what the filepath is?
It's on purpose so I don't have to metatable it to prevent rewriting. Of course someone can just rewrite the functions... Could debate a metatable there too
Do you know what the home folder or what the filepath is?
no, but why would a mod need to know that? to store something outside of a mod, use core.get_mod_data_path() i guess
i think the only relevant thing might be where minetest is installed, in that case core.get_mod_data_path() .. "/.."
It's on purpose so I don't have to metatable it to prevent rewriting. Of course someone can just rewrite the functions... Could debate a metatable there too
you don't have to prevent rewriting, and you shouldn't, if that is for trusted mods, then they should use it in a way where it couldn't cause harm no matter what happened to the table
but if you really wanted to prevent rewriting then you would have to set a metatable on _G to prevent defining a new OS_detector table (side note: why not just call it os_detector, much nicer)
I'd rather no mod be able to overwrite it, as much as that's not really a concern to go with... Other than that, I just like the appeal and it might be a fad I drop at some point
jit.os
- Works only on luajit, but that is what 99.9% of luanti users have (i wish luanti didn't support lua5.1)This is a cool way to detect what operating system the server has too, just not as simple as checking
jit.os
as for the API i am kinda confused why you use functions to get stuff, i think i would do:
instead of what you did in https://codeberg.org/TPH/operating_system_detector/src/branch/master/init.lua#L74
Ooo I'd convert this into a thread
Huh interesting,
jit.os
is a thing? I'll give it a lookie. Do you know what the home folder or what the filepath is?It's on purpose so I don't have to metatable it to prevent rewriting. Of course someone can just rewrite the functions... Could debate a metatable there too
yeah same
see also https://luajit.org
no, but why would a mod need to know that? to store something outside of a mod, use
core.get_mod_data_path()
i guess i think the only relevant thing might be where minetest is installed, in that casecore.get_mod_data_path() .. "/.."
you don't have to prevent rewriting, and you shouldn't, if that is for trusted mods, then they should use it in a way where it couldn't cause harm no matter what happened to the table
but if you really wanted to prevent rewriting then you would have to set a metatable on
_G
to prevent defining a newOS_detector
table (side note: why not just call itos_detector
, much nicer)danke
it's what I do to detect the OS
I'd like to if I can, besides the functions shouldn't be much on performance - as awkward as they are loool
Huh, _G?
and yeah good point I could do that, renaming
uhh sorry i edited my message: you don't have to prevent rewriting, even if a trusted mod is using that
yeah you don't need to care about performance at all with this, and i don't think you have a reason to prevent rewriting
Eh I'd prefer to prevent rewriting if I can.
why
I'd rather no mod be able to overwrite it, as much as that's not really a concern to go with... Other than that, I just like the appeal and it might be a fad I drop at some point