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

Add A New Api(java)

Started by Russoul, 28 October 2013 - 12:39 PM
Russoul #1
Posted 28 October 2013 - 01:39 PM
I need to create API (java) , like os, rednet, etc . Not a peripheral or turtleupgrade . How can i do it ?
Lyqyd #2
Posted 28 October 2013 - 04:26 PM
You could look through the ComputerCraft API, but I'm fairly sure to be able to mount up a directory on a computer, you need to have a peripheral and it needs to be attached to that computer. If your API doesn't need to be java-side, you could just use a resource pack to load it up into rom.
MKlegoman357 #3
Posted 28 October 2013 - 04:49 PM
Actualy, os API is half written in Lua and rednet API is fully written in Lua. What kind of API you want to create? If you want it to interact with the world then you would have to make a mod or use already made mod like OpenPeripherals.

You can also easily create an API in Lua like this:

We make a new file (program) and call it terminal:

function clear ()
  term.clear()
  term.setCursorPos(1, 1)
end

function resetColors (tc, bc)
  term.setBackgroundColor(bc or colors.black)
  term.setTextColor(tc or colors.white)
end

function reset (tc, bc)
  resetColors(tc, bc)
  clear()
end

notice: all functions that are going to be used outside the API have to be global.

Next we load it in our program and then use it:


os.loadAPI("terminal")

terminal.reset(colors.lightGray, colors.gray)

print("This is light gray text in gray background!")
brett122798 #4
Posted 28 October 2013 - 07:54 PM
Yeah, does this require the use of Java? If so, you can decompile the CC jar and add whatever you'd like.
theoriginalbit #5
Posted 28 October 2013 - 11:32 PM
If so, you can decompile the CC jar and add whatever you'd like.
And then never distribute it to anyone.
Russoul #6
Posted 29 October 2013 - 01:38 AM
API should interact with minecraft thread (mod, like openperipheral) . Actually what I need : ihostedperipheral interface in cc api has callmethod method that provides with icomputeraccess . I need to create JAVA API which will act like peripheral that is included in every pc from start, like os .
theoriginalbit #7
Posted 29 October 2013 - 01:47 AM
APIs available from OpenPeripheral first require a peripheral connected to the computer. There is no way to add a Java API without a peripheral attached to the computer.
Russoul #8
Posted 29 October 2013 - 04:33 AM
Ok. Can someone help with turtleupgrades ?
brett122798 #9
Posted 29 October 2013 - 12:13 PM
If so, you can decompile the CC jar and add whatever you'd like.
And then never distribute it to anyone.
Well yes, of course.

Ok. Can someone help with turtleupgrades ?
What do you need help with, specifically?