Computercraft to Opencomputers Compatibility
#1
Posted 18 April 2015 - 09:33 PM
#2
Posted 18 April 2015 - 09:40 PM
#3
Posted 18 April 2015 - 09:59 PM
Creator, on 18 April 2015 - 09:40 PM, said:
Of course it's possible. You'd need to write an abstraction layer, which should actually be quite easy. It just takes a lot of effort.
#4
Posted 18 April 2015 - 10:09 PM
if cc then setfenv(loadstring(yourProg),ccEnv) esle load(yourprog, some args I don't know, OC env) This is pseudocode. Reproducing it may be dangerous
#5
Posted 18 April 2015 - 10:23 PM
This is the same way games allow you to use OpenGl or DirectX, the game developers have their own graphics API which abstracts the actual graphics API calls.
In terms of OC and CC, your abstraction layer would test for which system you are running on
this is done the same way we check for API's in CC
if CC then --#link layer calls to CC func = CC.func else --#link layer calls to OC OC.func end
Edited by Lupus590, 18 April 2015 - 10:25 PM.
#6
Posted 18 April 2015 - 11:03 PM
local TerminalCCImpl = {}
local TerminalOCImpl = {}
function TerminalCCImpl.write(text)
term.write(text)
end
function TerminalOCImpl.write(text)
--# dunno, never used oc
end
Terminal = CC and TerminalCCImpl or TerminalOCImpl
--# Repeat for all the other functions...
--# This allows code like this to be written:
Terminal.write("Hello World!")
#7
Posted 18 April 2015 - 11:11 PM
term = cc and ccterm or octerm
where ccterm is the table that holds the cc functions
#8
Posted 18 April 2015 - 11:14 PM
Creator, on 18 April 2015 - 11:11 PM, said:
term = cc and ccterm or octerm
where ccterm is the table that holds the cc functions
That's what my code is doing...
#9
Posted 18 April 2015 - 11:18 PM
Also, due to the differences in lua version, there almost certainly will be some compatibility problems in some areas.
#10
Posted 18 April 2015 - 11:21 PM
But, I have no CC compatibility layer for OC. I started working on it, but ran out of free time.
#11
Posted 18 April 2015 - 11:26 PM
#12
Posted 19 April 2015 - 04:52 PM
I'm gonna have to check that out!
#13
Posted 21 April 2015 - 03:20 AM
Is it possible to make OC network cards compatible with CC wireless modems or even moarperipherals bitnet towers???
#14
Posted 21 April 2015 - 05:03 AM
terrariola, on 21 April 2015 - 03:20 AM, said:
Is it possible to make OC network cards compatible with CC wireless modems or even moarperipherals bitnet towers???
I don't know how OC's network cards work, but if you can use tgem to send a string to another computer and there is an event system, then you can write a compatebility layer.
#15
Posted 21 April 2015 - 06:55 AM
check the trailer video
Edit: trailer says yes
Also wiki says:
"Switch and Access Point blocks act as CC peripherals that emulate the CC modem API."
http://ocdoc.cil.li/crossmod_interoperation
Edited by Lupus590, 21 April 2015 - 07:02 AM.
#16
Posted 21 April 2015 - 09:37 AM
I know that this answer isn't helpful as I am just saying to write an abstraction layer, but I have yet to see a good abstraction layer in this topic. Since I am real Java lunatic lately I dont find Lua efficient enough to do it, because it does not provide some sort of interface by default which makes sure you can call the correct method on both abstraction layers.
However, a first start is that you need to know on which platform you are so you can return the correct implementation for that platform, and frankly I dont know how to do it since I dont know OC at all. You could check for the global API's and try to determine whether it is CC or OC.
Both implementations of the abstraction should contain both the same functions, nothing more or nothing less. Otherwise the abstraction is useless!
Well, after me ranting a bit... Good luck!
#17
Posted 21 April 2015 - 04:58 PM
Engineer, on 21 April 2015 - 09:37 AM, said:
Regarding that, CC1.74pr20 defines the global _CC_VERSION.
So you could do...
if __CC_VERSION then --# cc else --# opencomps end
While this is a very reliable method, it won't work with versions prior to CC1.74pr20, of course.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











