This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Hiran's profile picture

Window API under CC1.58 & earlier

Started by Hiran, 01 October 2014 - 10:44 PM
Hiran #1
Posted 02 October 2014 - 12:44 AM
Window api appeared in CC1.6 but will it work if I copy its file to 1.58 version? I need that info for my newest idea :)/>
Lyqyd #2
Posted 02 October 2014 - 01:11 AM
Similar APIs have been used since well before 1.58, so unless it depends on CC1.6-specific features from the Java side of things, it should probably work fine.
natedogith1 #3
Posted 02 October 2014 - 01:14 AM
It should work fine, though you might need to remove the code that checks if parent == term (the code bellow), since I don't think earlier versions of CC had term.current

	if parent == term then
		error( "term is not a recommended window parent, try term.current() instead", 2 )
	end
Hiran #4
Posted 02 October 2014 - 09:47 AM
It should work fine, though you might need to remove the code that checks if parent == term (the code bellow), since I don't think earlier versions of CC had term.current

	if parent == term then
		error( "term is not a recommended window parent, try term.current() instead", 2 )
	end
Is there any way to check which version of CC im working with?
And after analyzing window API i went like :o/> I can use OOP here :)/> Give me some time and you will see really powerful button API with PDA support and whatnot :)/>
theoriginalbit #5
Posted 02 October 2014 - 10:29 AM
indeed there is. os.version will do the trick. In Lua you can compare strings in some powerful ways

local version = os.version()
if version < "CraftOS 1.6" then
  --# Version before CC 1.6
elseif version > "CraftOS 1.6" then
  --# Version after CC 1.6
else
  --# ComputerCraft 1.6
end
you could also just check if certain APIs are nil too.