541 posts
Location
Melbourne, Australia
Posted 07 March 2015 - 12:20 AM
I hate writing programs, then have people from older versions trying to use them then they start complaining, for example, if I had ComputerCraft 1.65 installed I would like it to say "CraftOS 1.65" rather than "CraftOS 1.6"
350 posts
Posted 07 March 2015 - 12:23 AM
I tottally support this. And even if the CraftOS version doesn't change, at leas adding a variable with the current computercraft mod version.
871 posts
Posted 07 March 2015 - 12:56 AM
I would support this. In the past, I've done something similar to this to get the craftOS version number…
function getCraftOSVersion()
local str=""
local redir={
write=function(s) str=str..s end,
setCursorPos = function() end,
setCursorBlink= function() end,
setTextColor=function() end,
setBackgroundColor=function() end,
}
for k,v in pairs(term.current()) do
if redir[k]==nil then
redir[k]=v
end
end
local prev=term.redirect(redir)
shell.run("shell","exit")
term.redirect(prev)
return str:match("CraftOS ([%d%.]+)")
end
Not at a computer where I can test this atm, so may have derps, but you get the idea. Obviously, it's an ugly hack, but that I've gone to such lengths before just illustrates why os.version() would be nice!
1426 posts
Location
Does anyone put something serious here?
Posted 07 March 2015 - 08:53 AM
Not at a computer where I can test this atm, so may have derps, but you get the idea. Obviously, it's an ugly hack, but that I've gone to such lengths before just illustrates why os.version() would be nice!
Well
os.version does exist, though I agree it would be nice to get the sub-version as well, though generally I test to see if a feature is supported rather than if the current version supports it.
Edited on 07 March 2015 - 07:54 AM
871 posts
Posted 07 March 2015 - 12:38 PM
derp. I may be imagining it, but I would swear back in … probably 2012 or early 2013, when I was concerned with this, it wasn't yet a thing. XD
59 posts
Posted 07 March 2015 - 04:50 PM
derp. I may be imagining it, but I would swear back in … probably 2012 or early 2013, when I was concerned with this, it wasn't yet a thing. XD
I've got code from 2012 that has it in it, its been around longer then turtles.
I fully support this. There are enough changes between say 1.6 and 1.65 for it to indicate the difference.
871 posts
Posted 07 March 2015 - 06:47 PM
derp. I may be imagining it, but I would swear back in … probably 2012 or early 2013, when I was concerned with this, it wasn't yet a thing. XD
I've got code from 2012 that has it in it, its been around longer then turtles.
I fully support this. There are enough changes between say 1.6 and 1.65 for it to indicate the difference.
Ah. Well, then.
Sorry, but this information has changed this from something I would support, to something that's not going to happen, at least, not in the ways you're imagining/wishing. There will
not be an update to all past versions to add this function. At best, it would apply going forward, and honestly, I think dan200 generally tries to update the craftos version every update that has changes to the built-in APIs or events anyway? If he has missed doing so in a version, I'm sure it was an oversight, but one it's too late to fix now. Next time a beta releases, this should be the sort of thing people test and report in the beta test thread.
1140 posts
Location
Kaunas, Lithuania
Posted 07 March 2015 - 08:19 PM
I agree with SquidDev, that you should just be checking if a feature exists, it became like a CC's way of checking the version and with Lua it looks pretty nice:
if not window then
error("Requires ComputerCraft 1.6 or higher")
end
524 posts
Location
Cambridge, England
Posted 10 March 2015 - 01:17 PM
os.version() returns the current CraftOS version. The version of CraftOS always goes up when ComputerCraft itself passes a minor version number (ie: 1.6 -> 1.7). Currently ComputerCraft is version 1.73 and CraftOS is 1.7. I could add a value similar to the lua __VERSION constant to get the precise version, but as earlier posts have mentions, you're better off just directly checking for the existence of the functions/apis you need.