Download (6 KB)
For Luanti 5.0 and above

How do I install this?

VERY simple detection for the running device's operating system. Does NOT detect the operating systems of connected clients on a server - as the mod isn't able to access their machines.

Detects operating system via the mod path string (core.get_modpath), but isn't fully reliable. As certain folk can modify how their parent directories work and activate the needed switches in my mod to misidentify. Additionaly, this mod is unable to tell the difference between Linux distros, as well as Linux vs OpenBSD.

Windows, Android, and Linux detection has been tested. However MacOS, iOS, and iPad haven't been tested, nor has the detection for MultiCraft been tested.

This mod should be utilized in singleplayer settings - where a setting should be activated if the player is on a mobile device (Android, iOS, iPad)

Reviews

Review

Do you recommend this mod?

  • English

    also consider `jit.os`

    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 mod
    os_detector = {
    	os = info.OS,
    	is_multicraft = info.MultiCraft or false, -- maybe use core.get_version() instead if avaliable, or just don't support versions that don't have that
    	is_mobile = info.mobile
    }
    

    instead of what you did in https://codeberg.org/TPH/operating_system_detector/src/branch/master/init.lua#L74

    9 comments