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

RougeAPI

Started by Rougeminner, 05 May 2014 - 01:44 AM
Rougeminner #1
Posted 05 May 2014 - 03:44 AM
Rouge API Collection

This is a collection of all my API's (which is currently two API's). My API's are

The RougeScript API (indev and in need of ideas)
You can download it from my website
http://rougecc.weebly.com

The JS API can be found on the same URL that is above.


PLEASE MAKE SUGGESTIONS


Rougeminner



[indent=7]edit1: There will be a full command library on my website and a help function in computercraft in the next release.[/indent]
Edited on 05 May 2014 - 03:18 AM
MKlegoman357 #2
Posted 05 May 2014 - 11:11 AM
Next time post some working code. At least test it before you make it public.

Note: you can return values from functions using 'return' keyword:


local function add (x, y)
  return x + y
end

print( add( 1 , 2 ) ) -->> 3
oeed #3
Posted 05 May 2014 - 11:24 AM
Could you give a brief outline as to what they do?
Rougeminner #4
Posted 05 May 2014 - 04:40 PM
Yes Oeed i will shortly. and mklegoman thank you for pointing out that problem there where certain lines of code i forgot to mark unusable tell a couple more updates. sorry i will see if i can fix it tonight.

rougeminner
edit1 could you be more specific on which API and what line of code has a problem.
Edited on 05 May 2014 - 02:40 PM
Rougeminner #5
Posted 05 May 2014 - 04:46 PM
I am assuming your problem is in the RS api (RougeScript)
MKlegoman357 #6
Posted 05 May 2014 - 09:58 PM
Umm, don't want to sound too offensive, but half of the API's code has a problem. Lets see:

SpoilerJavaScript API

document

printFile = function(file)
 printer = peripheral.find("printer")
if printer then

n = printer.newPage()
 printer.setPageTitle("This is the ",file," program")
 printer.write(file)
 print("printing ",find," on to paper") --// There is no variable 'find'
sleep(2)
printer.endPage()
else 
print("No Printer on any sides")
end
end

createEvent = function(event)
os.pullEvent(event) --// Won't return event parameters (may be intentional)
end

createEventRaw = function(event)
os.pulleventRaw(event) --// Wrong capitalization/won't return event parameters (may be intentional)
end

open = function(file)
fs.open(file) --// Doesn't specify in what mode to open the file/Won't return the file handle...
--// ...making it unusable for other programs until in-game computer restart
end

RougeScript API:

unit

setWireless = function(boolean,side)
  if boolean == true then
check = peripheral.isPresent(side)
if check == true then
 red = peripheral.getType(side)
 if red == "modem" then 
 rednet.open(side) 
print("Modem is Open")
elseif not red == "modem" then --// Incorrect conditional, should be 'not (red == "modem")', could be just an 'else'
print("There is not a RedNet Modem on the ",side," of this computer")
elseif check == false then
print("There is no Peripheral on the ",side," of the computer")
else
end
end
end

end

--unit.getID()
getID = function()
os.getComputerID() --// Doesn't return the computer ID
end

--unit.getLabel()
getLabel = function()
os.getComputerLabel() --// Doesn't return the computer label
end

--unit.setLabel()
setLabel = function()
os.setComputerLabel() --// resets the computer label, still it's called 'setLabel' for some reason
end

--unit.clock()
clock = function()
os.clock() --// Doesn't return the actual 'os.clock' time value
end

--unit.startTimer()
startTime = function(timeout)
os.startTimer(timeout) --// Starts a timer, but doesn't return it's ID (may be intentional)
end

--unit.time()
getTime = function()
os.time() --// Doesn't return time
end

--unit.getDay()
getDay = function()
os.day() --// Doesn't return day
end

display

getCursorPos = function()
term.cetCursorPos() --// Bad spelling
end

getSize = function()
term.getSize() --// Doesn't return the terminal size
end

scroll = function()
term.scroll() --// Doesn't pass the scrolling direction argument making 'term.scroll' to error
end

redirect = function(target)
term.redirect(target) --// Doesn't return the previous terminal object
end

current = function()
term.current() --// Doesn't return the current terminal object
end

native = function()
term.native() --// Doesn't return the native terminal table
end

I don't actually see why this API would be useful, it's just a function wrapper and doesn't really implement any useful functions. I guess that you wanted to make an API for CC and got so excited that you didn't even tested it and just posted it on forums. I would recommend you to first make some simple programs (for ex.: CC classic - a door lock) and learn Lua a little more.
Edited on 05 May 2014 - 07:59 PM
Rougeminner #7
Posted 05 May 2014 - 11:00 PM
OK thankyou for pointing out the bugs and actually i did test it and above i meant to right
FIRST RELEASE !!!
Rougeminner #8
Posted 05 May 2014 - 11:12 PM
I did test it and i released it for help/for people who know JavaScript like me and i did make up a few commands (document.printFIle())
is still in heavy development (I can't make it work) and i don't have all the free time i wan but i will try to release a fixed version tonight.

Trying to make it work
Rougeminner
Rougeminner #9
Posted 06 May 2014 - 01:55 AM
There Update released Version 0.2 is released on my personal website. Oeed i will meet your suggestion tomorrow night.
Rougeminner
edit1: some commands where temporally removed they will be reimplement ASAP.
Edited on 05 May 2014 - 11:57 PM