Forum

> > CS2D > Scripts > Function: os.info
Forums overviewCS2D overview Scripts overviewLog in to reply

English Function: os.info

6 replies
To the start Previous 1 Next To the start

old Function: os.info

Mami Tomoe
User Off Offline

Quote
Hello, may I have some documentation on what this function's purpose is?

I found the function digging through the functions available under the
os
table.

Every other function there has a purpose, but this one does not seem to work.
Is it even a function? Is it just broken? What does it do?

1
2
3
4
5
6
7
8
9
10
11
12
debug.getinfo(os.info) =>
{
    ["nups"] = 0,
    ["what"] = "C",
    ["func"] = "<function>",
    ["lastlinedefined"] = -1,
    ["source"] = "=[C]",
    ["currentline"] = -1,
    ["namewhat"] = "",
    ["linedefined"] = -1,
    ["short_src"] = "[C]"
}

When called it returns the error:
LUA ERROR: attempt to index a function value

old Re: Function: os.info

DC
Admin On Online

Quote
It was supposed to return os information e.g. the name of the used operating system but if doesn't work it probably wasn't properly implemented and it's useless. Nobody really cares because nobody really needs it.

old Re: Function: os.info

Mami Tomoe
User Off Offline

Quote
Well I personally could find a use for it, if it were implemented properly.
There are good reasons to to knowing what operating system is being used.

1. Knowing the extension of a file you want to execute (whether
.exe
or no extension).
2. Knowing if you're running in development (Windows) or production (Linux) for a whole lot of reasons (accessing certain databases, and more).
3. Knowing which commands to use with
os.execute
.

Although there are certain workarounds to finding out which OS the server is running on, albeit less efficient and much more complicated.

As for other system information, can't think of any in particular that could be useful, but I'm sure that someone could find a reason to want some.

I'd argue that "nobody cares" about it, because nobody knows about it.
Unless you know how to fiddle around with Lua, you'd be lucky to even stumble upon it, let alone know what it does!

Imagine how many people wanted such functionality (I know I have), and had to do with weird unreliable and sometimes quirky workarounds, when this was right here, (not) ready to be used!

Do the function justice, bring it back to its promised place in the hall of CS2D functions, maybe colour it gold so it stands out, for old times sake, huh?

But, if you feel like this is not worth investing into, then at the very least, it would be nice if that function was removed, as it doesn't serve a purpose.
Let the function rest easy knowing no one will try to use its mangled code any longer.

As it currently stands, I feel unfair to the function.
edited 3×, last 16.12.24 09:33:22 pm

old Re: Function: os.info

MikuAuahDark
User Off Offline

Quote
1 and 2 is kinda similar, so the solution to detect Windows is
local windows = not not package.path:find("\\")
.

I'd argue as to why the server Lua script has to find out the OS name information of the host its running except for telemetry (which is kinda gray area).

old Re: Function: os.info

Mami Tomoe
User Off Offline

Quote
@user MikuAuahDark:
I'd argue that needing to use something as "complicated" as your example is no more than a hack.
Plus, there are valid reasons to knowing the OS used, as I've listed above, and those are only the reasons I personally came across.

old Re: Function: os.info

MikuAuahDark
User Off Offline

Quote
It's not a hack that could stop working in the future. It's how Lua initializes the
package
module on Windows vs. Linux. Also you only have to care if your server runs in Windows or Linux. That's what only CS2D support anyway.

As for #3, it's bit of related to #1 and #2, but in Linux there are slightly more caveat: the
which
command is not always available, while
where
in Windows is 100% guaranteed.

What are examples in particular where
os.info
is useful? Do you have a sample code to demonsrate?

old Re: Function: os.info

Mami Tomoe
User Off Offline

Quote
Whether the function is useful or not is obvious without examples.
It gives you information of which you'd not have an easy way of getting without it.

Whether it is worth implementing is what you should be asking.
I say that it's currently half implemented and that it should be either fully implemented or not implemented at all.

I'd argue for having it being more beneficial than for not.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview