Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
3f5f304297 | |||
f45660c7bd | |||
699c9a2ad2 | |||
a941f3bbe2 | |||
bf80b391df | |||
61ee283113 | |||
f98698cb4e | |||
3862552b57 | |||
7799de0865 | |||
94c3101f50 | |||
f9243dbcd2 | |||
fb98910116 | |||
758c0633c8 | |||
e764c1a25c | |||
29c42f5a0b | |||
![]() |
f252f6d587 | ||
![]() |
dcad97c81b | ||
![]() |
3faf729045 | ||
![]() |
0066b81461 | ||
![]() |
f8a788f91c | ||
![]() |
74fbbfff72 | ||
![]() |
b10b9e9d75 | ||
![]() |
f745e01464 | ||
![]() |
808c1972a9 |
@ -1,3 +1,3 @@
|
|||||||
# computercraft-haxelib
|
# cctweaked-haxelib
|
||||||
|
|
||||||
This is a minimal set of externs for the Lua APIs of ComputerCraft for the [haxe programming language](https://haxe.org). It's available through haxelib as `computercraft`. Only Lua is supported as a platform.
|
This is a minimal set of externs for the Lua APIs of CC: Tweaked for the [haxe programming language](https://haxe.org). It's available through haxelib as `cctweaked`. Only Lua is supported as a platform.
|
2
build.hxml
Normal file
2
build.hxml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
--lua main.lua
|
||||||
|
--class-path src
|
18
haxelib.json
18
haxelib.json
@ -1,13 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "computercraft",
|
"name": "cctweaked",
|
||||||
"url": "https://github.com/apemanzilla/computercraft-haxelib",
|
"url": "https://github.com/CCTweakedHaxePrograms/cctweaked-haxelib",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"tags": ["computercraft", "cc", "minecraft", "lua"],
|
"tags": ["computercraft", "cc", "minecraft", "lua", "cctweaked"],
|
||||||
"description": "Bindings for the Lua APIs of the ComputerCraft mod for Minecraft",
|
"description": "Bindings for the Lua APIs of the CC: Tweaked mod for Minecraft",
|
||||||
"version": "1.0.0",
|
"version": "2.2.0",
|
||||||
"classPath": "src",
|
"classPath": "src",
|
||||||
"releasenote": "Initial release",
|
"releasenote": "Adds many missing apis added by CC: Tweaked",
|
||||||
"contributors": [
|
"contributors": ["RGFTheCoder", "apemanzilla"]
|
||||||
"apemanzilla"
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
|
@ -6,24 +6,26 @@ typedef Color = Int;
|
|||||||
|
|
||||||
@:native("colors")
|
@:native("colors")
|
||||||
extern class Colors {
|
extern class Colors {
|
||||||
public static function combine(colors: Rest<Color>): Color;
|
public static function combine(colors:Rest<Color>):Color;
|
||||||
public static function subtract(from: Color, colors: Rest<Color>): Color;
|
public static function subtract(from:Color, colors:Rest<Color>):Color;
|
||||||
public static function test(it: Color, check: Color): Bool;
|
public static function test(it:Color, check:Color):Bool;
|
||||||
|
|
||||||
public static var white: Color;
|
public static var white:Color;
|
||||||
public static var orange: Color;
|
public static var orange:Color;
|
||||||
public static var magenta: Color;
|
public static var magenta:Color;
|
||||||
public static var lightBlue: Color;
|
public static var lightBlue:Color;
|
||||||
public static var yellow: Color;
|
public static var yellow:Color;
|
||||||
public static var lime: Color;
|
public static var lime:Color;
|
||||||
public static var pink: Color;
|
public static var pink:Color;
|
||||||
public static var gray: Color;
|
public static var gray:Color;
|
||||||
public static var lightGray: Color;
|
public static var grey:Color;
|
||||||
public static var cyan: Color;
|
public static var lightGray:Color;
|
||||||
public static var purple: Color;
|
public static var lightGrey:Color;
|
||||||
public static var blue: Color;
|
public static var cyan:Color;
|
||||||
public static var brown: Color;
|
public static var purple:Color;
|
||||||
public static var green: Color;
|
public static var blue:Color;
|
||||||
public static var red: Color;
|
public static var brown:Color;
|
||||||
public static var black: Color;
|
public static var green:Color;
|
||||||
|
public static var red:Color;
|
||||||
|
public static var black:Color;
|
||||||
}
|
}
|
||||||
|
@ -4,29 +4,29 @@ import lua.Table;
|
|||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class CommandExecutionResult {
|
extern class CommandExecutionResult {
|
||||||
var successful: Bool;
|
var successful:Bool;
|
||||||
var output: Table<Int, String>;
|
var output:Table<Int, String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class BlockPosition {
|
extern class BlockPosition {
|
||||||
var x: Int;
|
var x:Int;
|
||||||
var y: Int;
|
var y:Int;
|
||||||
var z: Int;
|
var z:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern class BlockInfo {
|
extern class BlockInfo {
|
||||||
var name: String;
|
var name:String;
|
||||||
var metadata: Int;
|
var metadata:Int;
|
||||||
var state: Dynamic;
|
var state:Dynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:native("commands")
|
@:native("commands")
|
||||||
extern class Commands {
|
extern class Commands {
|
||||||
public static function exec(command: String): CommandExecutionResult;
|
public static function exec(command:String):CommandExecutionResult;
|
||||||
public static function execAsync(command: String): Int;
|
public static function execAsync(command:String):Int;
|
||||||
public static function list(): Table<Int, String>;
|
public static function list():Table<Int, String>;
|
||||||
public static function getBlockPosition(): BlockPosition;
|
public static function getBlockPosition():BlockPosition;
|
||||||
public static function getBlockInfo(x: Int, y: Int, z: Int): BlockInfo;
|
public static function getBlockInfos(x1:Int, y1:Int, z1:Int, x2:Int, y2:Int, z2:Int):Table<Int, BlockInfo>;
|
||||||
public static function getBlockInfos(x1: Int, y1: Int, z1: Int, x2: Int, y2: Int, z2: Int): Table<Int, BlockInfo>;
|
public static function getBlockInfo(x:Int, y:Int, z:Int):BlockInfo;
|
||||||
}
|
}
|
||||||
|
14
src/cc/ComputerCraft.hx
Normal file
14
src/cc/ComputerCraft.hx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package cc;
|
||||||
|
|
||||||
|
import lua.Table;
|
||||||
|
|
||||||
|
@:native("_G")
|
||||||
|
extern class ComputerCraft {
|
||||||
|
public static function sleep(time:Float):Void; // Time is seconds ceil'd to the closest 0.05 or 1/20th
|
||||||
|
public static function write(text:String):Void;
|
||||||
|
public static function print(text:String):Void;
|
||||||
|
public static function printError(message:String):Void;
|
||||||
|
public static function read(?replaceChar:String, ?history:Table<Int, String>, ?completeFn:String->Table<Int, String>, ?defaultValue:String):String;
|
||||||
|
public static var _HOST:String;
|
||||||
|
public static var _CC_DEFAULT_SETTINGS:String;
|
||||||
|
}
|
@ -2,15 +2,15 @@ package cc;
|
|||||||
|
|
||||||
@:native("disk")
|
@:native("disk")
|
||||||
extern class Disk {
|
extern class Disk {
|
||||||
public static function isPresent(side: String): Bool;
|
public static function isPresent(side:String):Bool;
|
||||||
public static function hasData(side: String): Bool;
|
public static function getLabel(side:String):String;
|
||||||
public static function getMountPath(side: String): String;
|
public static function setLabel(side:String, label:String):Void;
|
||||||
public static function setLabel(side: String, label: String): Void;
|
public static function hasData(side:String):Bool;
|
||||||
public static function getLabel(side: String): String;
|
public static function getMountPath(side:String):String;
|
||||||
public static function getID(side: String): Int;
|
public static function hasAudio(side:String):Bool;
|
||||||
public static function hasAudio(side: String): Bool;
|
public static function getAudioTitle(side:String):String;
|
||||||
public static function getAudioTitle(side: String): String;
|
public static function playAudio(side:String):Void;
|
||||||
public static function playAudio(side: String): Void;
|
public static function stopAudio(side:String):Void;
|
||||||
public static function stopAudio(side: String): Void;
|
public static function eject(side:String):Void;
|
||||||
public static function eject(side: String): Void;
|
public static function getID(side:String):Int;
|
||||||
}
|
}
|
||||||
|
@ -2,39 +2,65 @@ package cc;
|
|||||||
|
|
||||||
import lua.Table;
|
import lua.Table;
|
||||||
|
|
||||||
@:enum
|
enum abstract OpenFileMode(String) {
|
||||||
abstract OpenFileMode(String) {
|
|
||||||
var Read = "r";
|
var Read = "r";
|
||||||
var Write = "w";
|
var Write = "w";
|
||||||
var Append = "a";
|
var Append = "a";
|
||||||
|
var BinaryRead = "rb";
|
||||||
|
var BinaryWrite = "wb";
|
||||||
|
var BinaryAppend = "ab";
|
||||||
}
|
}
|
||||||
|
|
||||||
@:luaDotMethod
|
@:luaDotMethod
|
||||||
extern class FileHandle {
|
extern class FileHandle {
|
||||||
public function close(): Void;
|
public function readLine(?withTrailing:Bool):Null<String>;
|
||||||
public function readLine(): String;
|
public function readAll():Null<String>;
|
||||||
public function readAll(): String;
|
/**
|
||||||
public function write(data: String): Void;
|
Returns Int or if `count` is given it returns a string.
|
||||||
public function writeLine(data: String): Void;
|
**/
|
||||||
public function flush(): Void;
|
public function read(?count:Int):Null<Dynamic>; // TODO: better type
|
||||||
|
public function write(data:String):Void;
|
||||||
|
public function writeLine(data:String):Void;
|
||||||
|
public function flush():Void;
|
||||||
|
public function seek(?whence:String, ?offset:Int):Int;
|
||||||
|
public function close():Void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern class FileAttributes {
|
||||||
|
var size:Int;
|
||||||
|
var isDir:Bool;
|
||||||
|
var isReadOnly:Bool;
|
||||||
|
var created:Int;
|
||||||
|
var modified:Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:lua
|
||||||
@:native("fs")
|
@:native("fs")
|
||||||
extern class FileSystem {
|
extern class FileSystem {
|
||||||
public static function list(path: String): Table<Int, String>;
|
public static function isDriveRoot(path:String):Bool;
|
||||||
public static function exists(path: String): Bool;
|
public static function complete(path:String, location:String, ?include_files:Bool, ?include_dirs:Bool):Bool;
|
||||||
public static function isDir(path: String): Bool;
|
public static function list(path:String):Table<Int, String>;
|
||||||
public static function isReadOnly(path: String): Bool;
|
public static function combine(base:String, part:String):String;
|
||||||
public static function getDrive(path: String): String;
|
public static function getName(path:String):String;
|
||||||
public static function getSize(path: String): Int;
|
public static function getDir(path:String):String;
|
||||||
public static function getFreeSpace(path: String): Int;
|
public static function getSize(path:String):Int;
|
||||||
public static function makeDir(path: String): Void;
|
public static function exists(path:String):Bool;
|
||||||
public static function move(from: String, to: String): Void;
|
public static function isDir(path:String):Bool;
|
||||||
public static function copy(from: String, to: String): Void;
|
public static function isReadOnly(path:String):Bool;
|
||||||
public static function delete(path: String): Void;
|
public static function makeDir(path:String):Void;
|
||||||
public static function combine(base: String, part: String): String;
|
public static function move(from:String, to:String):Void;
|
||||||
public static function open(path: String, mode: OpenFileMode): FileHandle;
|
public static function copy(from:String, to:String):Void;
|
||||||
public static function find(pattern: String): Table<Int, String>;
|
public static function delete(path:String):Void;
|
||||||
public static function getDir(path: String): String;
|
public static function open(path:String, mode:OpenFileMode):FileHandle;
|
||||||
// todo: complete()
|
// public static function open(path:String, mode:"r"):ReadFileHandle;
|
||||||
}
|
// public static function open(path:String, mode:"w"):WriteFileHandle;
|
||||||
|
// public static function open(path:String, mode:"a"):WriteFileHandle;
|
||||||
|
// public static function open(path:String, mode:"rb"):BinaryReadFileHandle;
|
||||||
|
// public static function open(path:String, mode:"wb"):BinaryWriteFileHandle;
|
||||||
|
// public static function open(path:String, mode:"ab"):BinaryWriteFileHandle;
|
||||||
|
public static function getDrive(path:String):String;
|
||||||
|
public static function getFreeSpace(path:String):Int;
|
||||||
|
public static function find(pattern:String):Table<Int, String>;
|
||||||
|
public static function getCapacity(path:String):Null<Int>;
|
||||||
|
public static function attributes(path:String):FileAttributes;
|
||||||
|
}
|
||||||
|
@ -2,12 +2,13 @@ package cc;
|
|||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class GPSLocation {
|
extern class GPSLocation {
|
||||||
var x: Float;
|
var x:Float;
|
||||||
var y: Float;
|
var y:Float;
|
||||||
var z: Float;
|
var z:Float;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:native("gps")
|
@:native("gps")
|
||||||
extern class GPS {
|
extern class GPS {
|
||||||
public static function locate(?timeout: Float, ?debug: Bool): GPSLocation;
|
public static var CHANNEL_GPS:Int;
|
||||||
}
|
public static function locate(?timeout:Float, ?debug:Bool):GPSLocation;
|
||||||
|
}
|
||||||
|
53
src/cc/HTTP.hx
Normal file
53
src/cc/HTTP.hx
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package cc;
|
||||||
|
|
||||||
|
import lua.Table;
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class HTTPCheckReturn {
|
||||||
|
public var allowed:Bool;
|
||||||
|
public var error:Null<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class SocketMessageReturn {
|
||||||
|
public var message:String;
|
||||||
|
public var binary:Bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:luaDotMethod
|
||||||
|
extern class HTTPResponse {
|
||||||
|
public function getResponseCode():Int;
|
||||||
|
public function getResponseHeaders():Table<String, String>;
|
||||||
|
public function readLine(?withTrailing:Bool):Null<String>;
|
||||||
|
public function readAll():Null<String>;
|
||||||
|
public function read(?count:Int):Null<String>;
|
||||||
|
public function seek(?whence:String, ?offset:Int):Void;
|
||||||
|
public function close():Void;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:luaDotMethod
|
||||||
|
extern class Websocket {
|
||||||
|
public function recieve(?timeout:Float):Null<SocketMessageReturn>;
|
||||||
|
public function send(message:String, ?binary:Float):Void;
|
||||||
|
public function close():Void;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Request {
|
||||||
|
var url:String;
|
||||||
|
var body:Null<String>;
|
||||||
|
var headers:Null<Table<String, String>>;
|
||||||
|
var binary:Null<Bool>;
|
||||||
|
var method:Null<String>;
|
||||||
|
var redirect:Null<Bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:native("http")
|
||||||
|
extern class HTTP {
|
||||||
|
public static function request(url:String, ?body:String, ?headers:Table<String, String>, ?binary:Bool):Void;
|
||||||
|
public static function get(url:String, ?headers:Table<String, String>, ?binary:Bool):Null<HTTPResponse>;
|
||||||
|
public static function post(url:String, postData:String, ?header:Table<String, String>, ?binary:Bool):Null<HTTPResponse>;
|
||||||
|
public static function checkURLAsync(url:String):Bool;
|
||||||
|
public static function checkURL(url:String):Bool;
|
||||||
|
public static function websocket(url:String, ?headers:Table<String, String>):Websocket;
|
||||||
|
public static function websocketAsync(url:String, ?headers:Table<String, String>):Void;
|
||||||
|
}
|
@ -4,9 +4,9 @@ import lua.Table;
|
|||||||
|
|
||||||
@:native("help")
|
@:native("help")
|
||||||
extern class Help {
|
extern class Help {
|
||||||
public static function path(): String;
|
public static function path():String;
|
||||||
public static function setPath(path: String): Void;
|
public static function setPath(path:String):Void;
|
||||||
public static function lookup(topic: String): String;
|
public static function lookup(topic:String):String;
|
||||||
public static function topics(): Table<Int, String>;
|
public static function topics():Table<Int, String>;
|
||||||
public static function completeTopic(prefix: String): Table<Int, String>;
|
public static function completeTopic(prefix:String):Table<Int, String>;
|
||||||
}
|
}
|
||||||
|
40
src/cc/IO.hx
Normal file
40
src/cc/IO.hx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package cc;
|
||||||
|
|
||||||
|
import lua.HaxeIterator;
|
||||||
|
|
||||||
|
@:enum
|
||||||
|
abstract OpenFileMode(String) {
|
||||||
|
var Read = "r";
|
||||||
|
var Write = "w";
|
||||||
|
var Append = "a";
|
||||||
|
var BinaryRead = "rb";
|
||||||
|
var BinaryWrite = "wb";
|
||||||
|
var BinaryAppend = "ab";
|
||||||
|
}
|
||||||
|
|
||||||
|
@:enum
|
||||||
|
abstract FileType(String) {
|
||||||
|
var File = "file";
|
||||||
|
var ClosedFile = "closed file";
|
||||||
|
}
|
||||||
|
|
||||||
|
extern class LLFileHandle {
|
||||||
|
public static function close():Null<Bool>;
|
||||||
|
public static function flush():Void;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:native("io")
|
||||||
|
extern class IO {
|
||||||
|
public static var stdin:LLFileHandle;
|
||||||
|
public static var stdout:LLFileHandle;
|
||||||
|
public static var stderr:LLFileHandle;
|
||||||
|
public static function close(?file:LLFileHandle):Void;
|
||||||
|
public static function flush():Void;
|
||||||
|
public static function input(?file:String):LLFileHandle;
|
||||||
|
public static function lines(?file:String):HaxeIterator<String>;
|
||||||
|
public static function open(filename:String, ?mode:OpenFileMode):LLFileHandle;
|
||||||
|
public static function output(?file:String):LLFileHandle;
|
||||||
|
public static function read():Null<String>;
|
||||||
|
public static function type(obj:Any):Null<FileType>;
|
||||||
|
public static function write(text:String):Void;
|
||||||
|
}
|
236
src/cc/Keys.hx
236
src/cc/Keys.hx
@ -2,126 +2,126 @@ package cc;
|
|||||||
|
|
||||||
@:native("keys")
|
@:native("keys")
|
||||||
extern class Keys {
|
extern class Keys {
|
||||||
public static function getName(code: Int): String;
|
public static function getName(code:Int):String;
|
||||||
public static inline function getCode(name: String): Int {
|
public static inline function getCode(name:String):Int {
|
||||||
// i know this is bad please don't judge me
|
// i know this is bad please don't judge me
|
||||||
return (cast Keys)[cast name];
|
return (cast Keys)[cast name];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static var a: Int;
|
public static var a:Int;
|
||||||
public static var c: Int;
|
public static var c:Int;
|
||||||
public static var b: Int;
|
public static var b:Int;
|
||||||
public static var e: Int;
|
public static var e:Int;
|
||||||
public static var pageUp: Int;
|
public static var pageUp:Int;
|
||||||
public static var g: Int;
|
public static var g:Int;
|
||||||
public static var f: Int;
|
public static var f:Int;
|
||||||
public static var i: Int;
|
public static var i:Int;
|
||||||
public static var h: Int;
|
public static var h:Int;
|
||||||
public static var k: Int;
|
public static var k:Int;
|
||||||
public static var j: Int;
|
public static var j:Int;
|
||||||
public static var space: Int;
|
public static var space:Int;
|
||||||
public static var l: Int;
|
public static var l:Int;
|
||||||
public static var o: Int;
|
public static var o:Int;
|
||||||
public static var n: Int;
|
public static var n:Int;
|
||||||
public static var q: Int;
|
public static var q:Int;
|
||||||
public static var f1: Int;
|
public static var f1:Int;
|
||||||
public static var s: Int;
|
public static var s:Int;
|
||||||
// public static var return: Int;
|
// public static var return: Int;
|
||||||
public static var f5: Int;
|
public static var f5:Int;
|
||||||
public static var seven: Int;
|
public static var seven:Int;
|
||||||
public static var w: Int;
|
public static var w:Int;
|
||||||
public static var numPadEnter: Int;
|
public static var numPadEnter:Int;
|
||||||
public static var y: Int;
|
public static var y:Int;
|
||||||
public static var x: Int;
|
public static var x:Int;
|
||||||
public static var numPad6: Int;
|
public static var numPad6:Int;
|
||||||
public static var z: Int;
|
public static var z:Int;
|
||||||
public static var backslash: Int;
|
public static var backslash:Int;
|
||||||
public static var rightBracket: Int;
|
public static var rightBracket:Int;
|
||||||
public static var f9: Int;
|
public static var f9:Int;
|
||||||
public static var yen: Int;
|
public static var yen:Int;
|
||||||
public static var left: Int;
|
public static var left:Int;
|
||||||
public static var numPadSubtract: Int;
|
public static var numPadSubtract:Int;
|
||||||
public static var noconvert: Int;
|
public static var noconvert:Int;
|
||||||
public static var leftCtrl: Int;
|
public static var leftCtrl:Int;
|
||||||
public static var rightCtrl: Int;
|
public static var rightCtrl:Int;
|
||||||
public static var numPad2: Int;
|
public static var numPad2:Int;
|
||||||
public static var insert: Int;
|
public static var insert:Int;
|
||||||
public static var delete: Int;
|
public static var delete:Int;
|
||||||
public static var f4: Int;
|
public static var f4:Int;
|
||||||
public static var grave: Int;
|
public static var grave:Int;
|
||||||
public static var leftAlt: Int;
|
public static var leftAlt:Int;
|
||||||
public static var numPad8: Int;
|
public static var numPad8:Int;
|
||||||
public static var numLock: Int;
|
public static var numLock:Int;
|
||||||
public static var four: Int;
|
public static var four:Int;
|
||||||
public static var rightAlt: Int;
|
public static var rightAlt:Int;
|
||||||
public static var pause: Int;
|
public static var pause:Int;
|
||||||
public static var numPad0: Int;
|
public static var numPad0:Int;
|
||||||
public static var numPadEquals: Int;
|
public static var numPadEquals:Int;
|
||||||
public static var enter: Int;
|
public static var enter:Int;
|
||||||
public static var down: Int;
|
public static var down:Int;
|
||||||
public static var eight: Int;
|
public static var eight:Int;
|
||||||
public static var f11: Int;
|
public static var f11:Int;
|
||||||
public static var six: Int;
|
public static var six:Int;
|
||||||
public static var r: Int;
|
public static var r:Int;
|
||||||
public static var rightShift: Int;
|
public static var rightShift:Int;
|
||||||
public static var t: Int;
|
public static var t:Int;
|
||||||
public static var u: Int;
|
public static var u:Int;
|
||||||
public static var pageDown: Int;
|
public static var pageDown:Int;
|
||||||
public static var nine: Int;
|
public static var nine:Int;
|
||||||
public static var zero: Int;
|
public static var zero:Int;
|
||||||
public static var capsLock: Int;
|
public static var capsLock:Int;
|
||||||
public static var p: Int;
|
public static var p:Int;
|
||||||
public static var leftBracket: Int;
|
public static var leftBracket:Int;
|
||||||
public static var underscore: Int;
|
public static var underscore:Int;
|
||||||
public static var scollLock: Int;
|
public static var scollLock:Int;
|
||||||
public static var minus: Int;
|
public static var minus:Int;
|
||||||
public static var f14: Int;
|
public static var f14:Int;
|
||||||
public static var m: Int;
|
public static var m:Int;
|
||||||
public static var cimcumflex: Int;
|
public static var cimcumflex:Int;
|
||||||
public static var one: Int;
|
public static var one:Int;
|
||||||
public static var up: Int;
|
public static var up:Int;
|
||||||
public static var equals: Int;
|
public static var equals:Int;
|
||||||
public static var d: Int;
|
public static var d:Int;
|
||||||
public static var f7: Int;
|
public static var f7:Int;
|
||||||
public static var apostrophe: Int;
|
public static var apostrophe:Int;
|
||||||
public static var numPad9: Int;
|
public static var numPad9:Int;
|
||||||
public static var f15: Int;
|
public static var f15:Int;
|
||||||
public static var stop: Int;
|
public static var stop:Int;
|
||||||
public static var f10: Int;
|
public static var f10:Int;
|
||||||
public static var numPad7: Int;
|
public static var numPad7:Int;
|
||||||
public static var numPad3: Int;
|
public static var numPad3:Int;
|
||||||
public static var comma: Int;
|
public static var comma:Int;
|
||||||
public static var numPadAdd: Int;
|
public static var numPadAdd:Int;
|
||||||
public static var tab: Int;
|
public static var tab:Int;
|
||||||
public static var numPad4: Int;
|
public static var numPad4:Int;
|
||||||
public static var f3: Int;
|
public static var f3:Int;
|
||||||
public static var kana: Int;
|
public static var kana:Int;
|
||||||
public static var numPad1: Int;
|
public static var numPad1:Int;
|
||||||
public static var right: Int;
|
public static var right:Int;
|
||||||
public static var numPadDecimal: Int;
|
public static var numPadDecimal:Int;
|
||||||
public static var f2: Int;
|
public static var f2:Int;
|
||||||
public static var leftShift: Int;
|
public static var leftShift:Int;
|
||||||
public static var backspace: Int;
|
public static var backspace:Int;
|
||||||
public static var convert: Int;
|
public static var convert:Int;
|
||||||
public static var end: Int;
|
public static var end:Int;
|
||||||
public static var three: Int;
|
public static var three:Int;
|
||||||
public static var kanji: Int;
|
public static var kanji:Int;
|
||||||
public static var v: Int;
|
public static var v:Int;
|
||||||
public static var colon: Int;
|
public static var colon:Int;
|
||||||
public static var semiColon: Int;
|
public static var semiColon:Int;
|
||||||
public static var two: Int;
|
public static var two:Int;
|
||||||
public static var f13: Int;
|
public static var f13:Int;
|
||||||
public static var multiply: Int;
|
public static var multiply:Int;
|
||||||
public static var period: Int;
|
public static var period:Int;
|
||||||
public static var ax: Int;
|
public static var ax:Int;
|
||||||
public static var slash: Int;
|
public static var slash:Int;
|
||||||
public static var f6: Int;
|
public static var f6:Int;
|
||||||
public static var at: Int;
|
public static var at:Int;
|
||||||
public static var numPadDivide: Int;
|
public static var numPadDivide:Int;
|
||||||
public static var numPad5: Int;
|
public static var numPad5:Int;
|
||||||
public static var f12: Int;
|
public static var f12:Int;
|
||||||
public static var f8: Int;
|
public static var f8:Int;
|
||||||
public static var home: Int;
|
public static var home:Int;
|
||||||
public static var five: Int;
|
public static var five:Int;
|
||||||
public static var numPadComma: Int;
|
public static var numPadComma:Int;
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import haxe.extern.Rest;
|
|||||||
|
|
||||||
@:native("multishell")
|
@:native("multishell")
|
||||||
extern class Multishell {
|
extern class Multishell {
|
||||||
public static function getCurrent(): Int;
|
public static function getCurrent():Int;
|
||||||
public static function getCount(): Int;
|
public static function getCount():Int;
|
||||||
public static function launch(environment: Table<Dynamic, Dynamic>, path: String, args: Rest<String>): Int;
|
public static function launch(environment:Table<Dynamic, Dynamic>, path:String, args:Rest<String>):Int;
|
||||||
public static function setFocus(id: Int): Void;
|
public static function setFocus(id:Int):Void;
|
||||||
public static function setTitle(id: Int, title: String): Void;
|
public static function setTitle(id:Int, title:String):Void;
|
||||||
public static function getTitle(id: Int): String;
|
public static function getTitle(id:Int):String;
|
||||||
public static function getFocus(): Int;
|
public static function getFocus():Int;
|
||||||
}
|
}
|
||||||
|
48
src/cc/OS.hx
48
src/cc/OS.hx
@ -6,33 +6,35 @@ import haxe.extern.Rest;
|
|||||||
|
|
||||||
@:native("os")
|
@:native("os")
|
||||||
extern class OS {
|
extern class OS {
|
||||||
public static function version(): String;
|
public static function version():String;
|
||||||
public static function getComputerID(): Int;
|
public static function getComputerID():Int;
|
||||||
public static function getComputerLabel(): String;
|
public static function getComputerLabel():String;
|
||||||
public static function setComputerLabel(label: String): Void;
|
public static function setComputerLabel(label:String):Void;
|
||||||
public static function run(environment: Table<Dynamic, Dynamic>, path: String, args: Rest<String>): Bool;
|
public static function run(environment:Table<Dynamic, Dynamic>, path:String, args:Rest<String>):Bool;
|
||||||
public static function loadAPI(path: String): Bool;
|
public static function loadAPI(path:String):Bool;
|
||||||
public static function unloadAPI(path: String): Void;
|
public static function unloadAPI(path:String):Void;
|
||||||
public static function queueEvent(type: String, data: Rest<Dynamic>): Void;
|
public static function queueEvent(type:String, data:Rest<Dynamic>):Void;
|
||||||
public static function clock(): Float;
|
public static function clock():Float;
|
||||||
public static function startTimer(timeout: Int): Int;
|
public static function startTimer(timeout:Float):Int;
|
||||||
public static function cancelTimer(id: Int): Void;
|
public static function cancelTimer(id:Int):Void;
|
||||||
public static function time(): Float;
|
public static function time():Float;
|
||||||
public static function sleep(timeout: Float): Void;
|
public static function sleep(timeout:Float):Void;
|
||||||
public static function day(): Int;
|
public static function day():Int;
|
||||||
public static function setAlarm(time: Float): Int;
|
public static function setAlarm(time:Float):Int;
|
||||||
public static function cancelAlarm(id: Int): Void;
|
public static function cancelAlarm(id:Int):Void;
|
||||||
public static function shutdown(): Void;
|
public static function shutdown():Void;
|
||||||
public static function reboot(): Void;
|
public static function reboot():Void;
|
||||||
|
public static function date(?format:String,?time:Int):Dynamic;
|
||||||
|
public static function epoch(?args:String):Int;
|
||||||
|
|
||||||
@:native("pullEvent") private static function _pullEvent(?type: String): Dynamic;
|
@:native("pullEvent") private static function _pullEvent(?type:String):Dynamic;
|
||||||
@:native("pullEventRaw") private static function _pullEventRaw(?type: String): Dynamic;
|
@:native("pullEventRaw") private static function _pullEventRaw(?type:String):Dynamic;
|
||||||
|
|
||||||
public static inline function pullEvent(?type: String): ArrayAccess<Dynamic> {
|
public static inline function pullEvent(?type:String):Table<Int, Dynamic> {
|
||||||
return cast TableTools.pack(_pullEvent(type));
|
return cast TableTools.pack(_pullEvent(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static inline function pullEventRaw(?type: String): ArrayAccess<Dynamic> {
|
public static inline function pullEventRaw(?type:String):Table<Int, Dynamic> {
|
||||||
return cast TableTools.pack(_pullEventRaw(type));
|
return cast TableTools.pack(_pullEventRaw(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ typedef Image = Table<Int, Table<Int, Int>>;
|
|||||||
|
|
||||||
@:native("paintutils")
|
@:native("paintutils")
|
||||||
extern class PaintUtils {
|
extern class PaintUtils {
|
||||||
public static function loadImage(path: String): Image;
|
public static function loadImage(path:String):Image;
|
||||||
public static function drawImage(image: Image, x: Int, y: Int): Void;
|
public static function drawImage(image:Image, x:Int, y:Int):Void;
|
||||||
public static function drawPixel(x: Int, y: Int, ?color: Color): Void;
|
public static function drawPixel(x:Int, y:Int, ?color:Color):Void;
|
||||||
public static function drawLine(startX: Int, startY: Int, endX: Int, endY: Int, ?color: Color): Void;
|
public static function drawLine(startX:Int, startY:Int, endX:Int, endY:Int, ?color:Color):Void;
|
||||||
public static function drawBox(startX: Int, startY: Int, endX: Int, endY: Int, ?color: Color): Void;
|
public static function drawBox(startX:Int, startY:Int, endX:Int, endY:Int, ?color:Color):Void;
|
||||||
public static function drawFilledBox(startX: Int, startY: Int, endX: Int, endY: Int, ?color: Color): Void;
|
public static function drawFilledBox(startX:Int, startY:Int, endX:Int, endY:Int, ?color:Color):Void;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ import haxe.extern.Rest;
|
|||||||
|
|
||||||
@:native("parallel")
|
@:native("parallel")
|
||||||
extern class Parallel {
|
extern class Parallel {
|
||||||
public static function waitForAny(f1: Function, funcs: Rest<Function>): Int;
|
public static function waitForAny(f1:Function, funcs:Rest<Function>):Int;
|
||||||
public static function waitForAll(f1: Function, funcs: Rest<Function>): Int;
|
public static function waitForAll(f1:Function, funcs:Rest<Function>):Int;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package cc;
|
package cc;
|
||||||
|
|
||||||
|
import lua.TableTools;
|
||||||
import lua.Table;
|
import lua.Table;
|
||||||
import haxe.Constraints;
|
|
||||||
import haxe.extern.Rest;
|
import haxe.extern.Rest;
|
||||||
|
|
||||||
@:native("peripheral")
|
@:native("peripheral")
|
||||||
extern class Peripheral {
|
extern class Peripheral {
|
||||||
public static function isPresent(name: String): Bool;
|
public static function isPresent(name:String):Bool;
|
||||||
public static function getType(name: String): String;
|
public static function getMethods(name:String):Table<Int,String>;
|
||||||
public static function getMethods(name: String): Table<String, Function>;
|
public static function call<T>(name:String, method:String, args:Rest<Dynamic>):T;
|
||||||
public static function call<T>(name: String, method: String, args: Rest<Dynamic>): T;
|
public static function wrap<T>(name:String):T;
|
||||||
public static function wrap<T>(name: String): T;
|
public static function find<T>(type:String, ?filter:(String, T) -> Bool):Table<Int, T>;
|
||||||
public static function find<T>(type: String, ?filter: (String, T) -> Bool): Table<Int, T>;
|
public static function getNames():Table<Int, String>;
|
||||||
public static function getNames(): Table<Int, String>;
|
|
||||||
}
|
@:native("getType") private static function _getType(name:String): Dynamic;
|
||||||
|
|
||||||
|
public static inline function getType(name:String): Table<Int,String>{
|
||||||
|
return cast TableTools.pack(_getType(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
13
src/cc/Pocket.hx
Normal file
13
src/cc/Pocket.hx
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package cc;
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class PocketActionResult {
|
||||||
|
public var successful:Bool;
|
||||||
|
public var error:String;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:native("pocket")
|
||||||
|
extern class Pocket {
|
||||||
|
public static function equipBack(): PocketActionResult;
|
||||||
|
public static function unequipBack(): PocketActionResult;
|
||||||
|
}
|
@ -6,30 +6,30 @@ import lua.TableTools;
|
|||||||
typedef MessageData = Dynamic;
|
typedef MessageData = Dynamic;
|
||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class ReceivedMessage<T : MessageData> {
|
extern class ReceivedMessage<T:MessageData> {
|
||||||
public var senderID: Int;
|
public var senderID:Int;
|
||||||
public var message: T;
|
public var message:T;
|
||||||
public var distance: Float;
|
public var distance:Float;
|
||||||
public var protocol: String;
|
public var protocol:String;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:native("rednet")
|
@:native("rednet")
|
||||||
extern class Rednet {
|
extern class Rednet {
|
||||||
public static function open(modem: String): Void;
|
public static function open(modem:String):Void;
|
||||||
public static function close(modem: String): Void;
|
public static function close(modem:String):Void;
|
||||||
public static function send(to: Int, data: MessageData, ?protocol: String): Void;
|
public static function send(to:Int, data:MessageData, ?protocol:String):Void;
|
||||||
public static function broadcast(data: MessageData, ?protocol: String): Void;
|
public static function broadcast(data:MessageData, ?protocol:String):Void;
|
||||||
public static function receive<T : MessageData>(?protocol: String, ?timeout: Int): ReceivedMessage<T>;
|
public static function receive<T:MessageData>(?protocol:String, ?timeout:Int):ReceivedMessage<T>;
|
||||||
public static function isOpen(modem: String): Bool;
|
public static function isOpen(modem:String):Bool;
|
||||||
public static function host(protocol: String, hostname: String): Void;
|
public static function host(protocol:String, hostname:String):Void;
|
||||||
public static function unhost(protocol: String, hostname: String): Void;
|
public static function unhost(protocol:String, hostname:String):Void;
|
||||||
|
|
||||||
@:native("lookup")
|
@:native("lookup")
|
||||||
private static function _lookup(protocol: String, ?hostname: String): Dynamic;
|
private static function _lookup(protocol:String, ?hostname:String):Dynamic;
|
||||||
|
|
||||||
public static inline function lookup(protocol: String, ?hostname: String): Table<Int, Int> {
|
public static inline function lookup(protocol:String, ?hostname:String):Table<Int, Int> {
|
||||||
return TableTools.pack(_lookup(protocol, hostname));
|
return TableTools.pack(_lookup(protocol, hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function run(): Void;
|
public static function run():Void;
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,15 @@ import cc.Colors;
|
|||||||
|
|
||||||
@:native("redstone")
|
@:native("redstone")
|
||||||
extern class Redstone {
|
extern class Redstone {
|
||||||
public static function getSides(): Table<Int, String>;
|
public static function getSides():Table<Int, String>;
|
||||||
public static function getInput(side: String): Bool;
|
public static function getInput(side:String):Bool;
|
||||||
public static function setOutput(side: String, state: Bool): Void;
|
public static function setOutput(side:String, state:Bool):Void;
|
||||||
public static function getOutput(side: String): Bool;
|
public static function getOutput(side:String):Bool;
|
||||||
public static function getAnalogInput(side: String): Int;
|
public static function getAnalogInput(side:String):Int;
|
||||||
public static function setAnalogOutput(side: String, strength: Int): Void;
|
public static function setAnalogOutput(side:String, strength:Int):Void;
|
||||||
public static function getAnalogOutput(side: String): Int;
|
public static function getAnalogOutput(side:String):Int;
|
||||||
public static function getBundledInput(side: String): Color;
|
public static function getBundledInput(side:String):Color;
|
||||||
public static function setBundledOutput(side: String, state: Color): Void;
|
public static function setBundledOutput(side:String, state:Color):Void;
|
||||||
public static function getBundledOutput(side: String): Color;
|
public static function getBundledOutput(side:String):Color;
|
||||||
public static function testBundledInput(side: String, value: Color): Bool;
|
public static function testBundledInput(side:String, value:Color):Bool;
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ typedef SettingData = Dynamic;
|
|||||||
|
|
||||||
@:native("settings")
|
@:native("settings")
|
||||||
extern class Settings {
|
extern class Settings {
|
||||||
public static function set(name: String, value: SettingData): Void;
|
public static function set(name:String, value:SettingData):Void;
|
||||||
public static function get(name: String, ?defaultValue: SettingData): SettingData;
|
public static function get(name:String, ?defaultValue:SettingData):SettingData;
|
||||||
public static function unset(name: String): Void;
|
public static function unset(name:String):Void;
|
||||||
public static function clear(): Void;
|
public static function clear():Void;
|
||||||
public static function getNames(): Table<Int, String>;
|
public static function getNames():Table<Int, String>;
|
||||||
public static function load(path: String): Bool;
|
public static function load(path:String):Bool;
|
||||||
public static function save(path: String): Bool;
|
public static function save(path:String):Bool;
|
||||||
}
|
}
|
||||||
|
@ -5,20 +5,20 @@ import haxe.extern.Rest;
|
|||||||
|
|
||||||
@:native("shell")
|
@:native("shell")
|
||||||
extern class Shell {
|
extern class Shell {
|
||||||
public static function exit(): Void;
|
public static function exit():Void;
|
||||||
public static function dir(): String;
|
public static function dir():String;
|
||||||
public static function setDir(path: String): Void;
|
public static function setDir(path:String):Void;
|
||||||
public static function path(): String;
|
public static function path():String;
|
||||||
public static function setPath(path: String): Void;
|
public static function setPath(path:String):Void;
|
||||||
public static function resolve(localPath: String): String;
|
public static function resolve(localPath:String):String;
|
||||||
public static function resolveProgram(name: String): String;
|
public static function resolveProgram(name:String):String;
|
||||||
public static function aliases(): Table<String, String>;
|
public static function aliases():Table<String, String>;
|
||||||
public static function setAlias(alias: String, program: String): Void;
|
public static function setAlias(alias:String, program:String):Void;
|
||||||
public static function clearAlias(alias: String): Void;
|
public static function clearAlias(alias:String):Void;
|
||||||
public static function programs(?showHidden: Bool): Table<Int, String>;
|
public static function programs(?showHidden:Bool):Table<Int, String>;
|
||||||
public static function getRunningProgram(): String;
|
public static function getRunningProgram():String;
|
||||||
public static function run(command: String, args: Rest<String>): Bool;
|
public static function run(command:String, args:Rest<String>):Bool;
|
||||||
public static function openTab(command: String, args: Rest<String>): Int;
|
public static function openTab(command:String, args:Rest<String>):Int;
|
||||||
public static function switchTab(tabID: Int): Void;
|
public static function switchTab(tabID:Int):Void;
|
||||||
// todo: completion functions
|
// todo: completion functions
|
||||||
}
|
}
|
||||||
|
@ -4,51 +4,52 @@ import cc.Colors;
|
|||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class TerminalPosition {
|
extern class TerminalPosition {
|
||||||
public var x: Int;
|
public var x:Int;
|
||||||
public var y: Int;
|
public var y:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class TerminalSize {
|
extern class TerminalSize {
|
||||||
public var width: Int;
|
public var width:Int;
|
||||||
public var height: Int;
|
public var height:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@:luaDotMethod
|
||||||
extern class TerminalObject {
|
extern class TerminalObject {
|
||||||
public function write(text: String): Void;
|
public function write(text:String):Void;
|
||||||
public function blit(text: String, colors: String, background: String): Void;
|
public function blit(text:String, colors:String, background:String):Void;
|
||||||
public function clear(): Void;
|
public function clear():Void;
|
||||||
public function clearLine(): Void;
|
public function clearLine():Void;
|
||||||
public function getCursorPos(): TerminalPosition;
|
public function getCursorPos():TerminalPosition;
|
||||||
public function setCursorPos(x: Int, y: Int): Void;
|
public function setCursorPos(x:Int, y:Int):Void;
|
||||||
public function setCursorBlink(value: Bool): Void;
|
public function setCursorBlink(value:Bool):Void;
|
||||||
public function isColor(): Bool;
|
public function isColor():Bool;
|
||||||
public function getSize(): TerminalSize;
|
public function getSize():TerminalSize;
|
||||||
public function scroll(lines: Int): Void;
|
public function scroll(lines:Int):Void;
|
||||||
public function setTextColor(color: Color): Void;
|
public function setTextColor(color:Color):Void;
|
||||||
public function getTextColor(): Color;
|
public function getTextColor():Color;
|
||||||
public function setBackgroundColor(color: Color): Void;
|
public function setBackgroundColor(color:Color):Void;
|
||||||
public function getBackgroundColor(): Color;
|
public function getBackgroundColor():Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:native("term")
|
@:native("term")
|
||||||
extern class Term {
|
extern class Term {
|
||||||
public static function write(text: String): Void;
|
public static function write(text:String):Void;
|
||||||
public static function blit(text: String, colors: String, background: String): Void;
|
public static function blit(text:String, colors:String, background:String):Void;
|
||||||
public static function clear(): Void;
|
public static function clear():Void;
|
||||||
public static function clearLine(): Void;
|
public static function clearLine():Void;
|
||||||
public static function getCursorPos(): TerminalPosition;
|
public static function getCursorPos():TerminalPosition;
|
||||||
public static function setCursorPos(x: Int, y: Int): Void;
|
public static function setCursorPos(x:Int, y:Int):Void;
|
||||||
public static function setCursorBlink(value: Bool): Void;
|
public static function setCursorBlink(value:Bool):Void;
|
||||||
public static function isColor(): Bool;
|
public static function isColor():Bool;
|
||||||
public static function getSize(): TerminalSize;
|
public static function getSize():TerminalSize;
|
||||||
public static function scroll(lines: Int): Void;
|
public static function scroll(lines:Int):Void;
|
||||||
public static function setTextColor(color: Color): Void;
|
public static function setTextColor(color:Color):Void;
|
||||||
public static function getTextColor(): Color;
|
public static function getTextColor():Color;
|
||||||
public static function setBackgroundColor(color: Color): Void;
|
public static function setBackgroundColor(color:Color):Void;
|
||||||
public static function getBackgroundColor(): Color;
|
public static function getBackgroundColor():Color;
|
||||||
|
|
||||||
public static function redirect(target: TerminalObject): TerminalObject;
|
public static function redirect(target:TerminalObject):TerminalObject;
|
||||||
public static function current(): TerminalObject;
|
public static function current():TerminalObject;
|
||||||
public static function native(): TerminalObject;
|
public static function native():TerminalObject;
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@ typedef TextUtilsSerializable = Dynamic;
|
|||||||
|
|
||||||
@:native("textutils")
|
@:native("textutils")
|
||||||
extern class TextUtils {
|
extern class TextUtils {
|
||||||
public static function slowWrite(text: String, ?rate: Float): Void;
|
public static function slowWrite(text:String, ?rate:Float):Void;
|
||||||
public static function slowPrint(text: String, ?rate: Float): Void;
|
public static function slowPrint(text:String, ?rate:Float):Void;
|
||||||
public static function formatTime(time: Float, ?twentyFourHour: Bool): String;
|
public static function formatTime(time:Float, ?twentyFourHour:Bool):String;
|
||||||
// todo: tabulate, paged tabulate
|
// todo: tabulate, paged tabulate
|
||||||
public static function pagedPrint(text: String, freeLines: Int): Int;
|
public static function pagedPrint(text:String, freeLines:Int):Int;
|
||||||
public static function serialize(data: TextUtilsSerializable): String;
|
public static function serialize(data:TextUtilsSerializable):String;
|
||||||
public static function unserialize<T : TextUtilsSerializable>(from: String): T;
|
public static function unserialize<T:TextUtilsSerializable>(from:String):T;
|
||||||
public static function serializeJSON(data: TextUtilsSerializable, ?unquoteKeys: Bool): String;
|
public static function serializeJSON(data:TextUtilsSerializable, ?unquoteKeys:Bool):String;
|
||||||
public static function urlEncode(data: String): String;
|
public static function urlEncode(data:String):String;
|
||||||
// todo: complete
|
// todo: complete
|
||||||
}
|
}
|
||||||
|
108
src/cc/Turtle.hx
108
src/cc/Turtle.hx
@ -4,71 +4,71 @@ import haxe.extern.EitherType;
|
|||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class TurtleActionResult {
|
extern class TurtleActionResult {
|
||||||
public var successful: Bool;
|
public var successful:Bool;
|
||||||
public var error: String;
|
public var error:String;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern class TurtleItemDetail {
|
extern class TurtleItemDetail {
|
||||||
public var name: String;
|
public var name:String;
|
||||||
public var damage: Int;
|
public var damage:Int;
|
||||||
public var count: Int;
|
public var count:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern class TurtleBlockDetail {
|
extern class TurtleBlockDetail {
|
||||||
public var name: String;
|
public var name:String;
|
||||||
public var metadata: Int;
|
public var tags:lua.Table<String, Bool>;
|
||||||
public var state: Dynamic;
|
public var state:Dynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:multiReturn
|
@:multiReturn
|
||||||
extern class TurtleInspectResult {
|
extern class TurtleInspectResult {
|
||||||
public var successful: Bool;
|
public var successful:Bool;
|
||||||
public var result: EitherType<String, TurtleBlockDetail>;
|
public var result:EitherType<String, TurtleBlockDetail>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:native("turtle")
|
@:native("turtle")
|
||||||
extern class Turtle {
|
extern class Turtle {
|
||||||
public static function craft(qty: Int): TurtleActionResult;
|
public static function craft(qty:Int):TurtleActionResult;
|
||||||
public static function forward(): TurtleActionResult;
|
public static function forward():TurtleActionResult;
|
||||||
public static function back(): TurtleActionResult;
|
public static function back():TurtleActionResult;
|
||||||
public static function up(): TurtleActionResult;
|
public static function up():TurtleActionResult;
|
||||||
public static function down(): TurtleActionResult;
|
public static function down():TurtleActionResult;
|
||||||
public static function turnLeft(): TurtleActionResult;
|
public static function turnLeft():TurtleActionResult;
|
||||||
public static function turnRight(): TurtleActionResult;
|
public static function turnRight():TurtleActionResult;
|
||||||
public static function select(slot: Int): Bool;
|
public static function select(slot:Int):Bool;
|
||||||
public static function getSelectedSlot(): Int;
|
public static function getSelectedSlot():Int;
|
||||||
public static function getItemCount(?slot: Int): Int;
|
public static function getItemCount(?slot:Int):Int;
|
||||||
public static function getItemSpace(?slot: Int): Int;
|
public static function getItemSpace(?slot:Int):Int;
|
||||||
public static function getItemDetail(?slot: Int): TurtleItemDetail;
|
public static function getItemDetail(?slot:Int):TurtleItemDetail;
|
||||||
public static function equipLeft(): TurtleActionResult;
|
public static function equipLeft():TurtleActionResult;
|
||||||
public static function equipRight(): TurtleActionResult;
|
public static function equipRight():TurtleActionResult;
|
||||||
public static function attack(): TurtleActionResult;
|
public static function attack():TurtleActionResult;
|
||||||
public static function attackUp(): TurtleActionResult;
|
public static function attackUp():TurtleActionResult;
|
||||||
public static function attackDown(): TurtleActionResult;
|
public static function attackDown():TurtleActionResult;
|
||||||
public static function dig(): TurtleActionResult;
|
public static function dig():TurtleActionResult;
|
||||||
public static function digUp(): TurtleActionResult;
|
public static function digUp():TurtleActionResult;
|
||||||
public static function digDown(): TurtleActionResult;
|
public static function digDown():TurtleActionResult;
|
||||||
public static function place(?signText: String): TurtleActionResult;
|
public static function place(?signText:String):TurtleActionResult;
|
||||||
public static function placeUp(): TurtleActionResult;
|
public static function placeUp():TurtleActionResult;
|
||||||
public static function placeDown(): TurtleActionResult;
|
public static function placeDown():TurtleActionResult;
|
||||||
public static function detect(): Bool;
|
public static function detect():Bool;
|
||||||
public static function detectUp(): Bool;
|
public static function detectUp():Bool;
|
||||||
public static function detectDown(): Bool;
|
public static function detectDown():Bool;
|
||||||
public static function inspect(): TurtleInspectResult;
|
public static function inspect():TurtleInspectResult;
|
||||||
public static function inspectUp(): TurtleInspectResult;
|
public static function inspectUp():TurtleInspectResult;
|
||||||
public static function inspectDown(): TurtleInspectResult;
|
public static function inspectDown():TurtleInspectResult;
|
||||||
public static function compare(): Bool;
|
public static function compare():Bool;
|
||||||
public static function compareUp(): Bool;
|
public static function compareUp():Bool;
|
||||||
public static function compareDown(): Bool;
|
public static function compareDown():Bool;
|
||||||
public static function compareTo(slot: Int): Bool;
|
public static function compareTo(slot:Int):Bool;
|
||||||
public static function drop(?count: Int): TurtleActionResult;
|
public static function drop(?count:Int):TurtleActionResult;
|
||||||
public static function dropUp(?count: Int): TurtleActionResult;
|
public static function dropUp(?count:Int):TurtleActionResult;
|
||||||
public static function dropDown(?count: Int): TurtleActionResult;
|
public static function dropDown(?count:Int):TurtleActionResult;
|
||||||
public static function suck(?amount: Int): TurtleActionResult;
|
public static function suck(?amount:Int):TurtleActionResult;
|
||||||
public static function suckUp(?amount: Int): TurtleActionResult;
|
public static function suckUp(?amount:Int):TurtleActionResult;
|
||||||
public static function suckDown(?amount: Int): TurtleActionResult;
|
public static function suckDown(?amount:Int):TurtleActionResult;
|
||||||
public static function refuel(?qty: Int): TurtleActionResult;
|
public static function refuel(?qty:Int):TurtleActionResult;
|
||||||
public static function getFuelLevel(): Int;
|
public static function getFuelLevel():Int;
|
||||||
public static function getFuelLimit(): Int;
|
public static function getFuelLimit():Int;
|
||||||
public static function transferTo(to: Int, ?qty: Int): Bool;
|
public static function transferTo(to:Int, ?qty:Int):Bool;
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,15 @@ package cc;
|
|||||||
|
|
||||||
@:native("vector")
|
@:native("vector")
|
||||||
extern class Vector {
|
extern class Vector {
|
||||||
@:native("new") public static function create(x: Int, y: Int, z: Int): Vector;
|
@:native("new") public static function create(x:Int, y:Int, z:Int):Vector;
|
||||||
|
|
||||||
public function add(other: Vector): Vector;
|
public function add(other:Vector):Vector;
|
||||||
public function sub(other: Vector): Vector;
|
public function sub(other:Vector):Vector;
|
||||||
public function mul(n: Float): Vector;
|
public function mul(n:Float):Vector;
|
||||||
public function dot(other: Vector): Float;
|
public function dot(other:Vector):Float;
|
||||||
public function cross(other: Vector): Float;
|
public function cross(other:Vector):Float;
|
||||||
public function length(): Float;
|
public function length():Float;
|
||||||
public function normalize(): Vector;
|
public function normalize():Vector;
|
||||||
public function round(): Vector;
|
public function round():Vector;
|
||||||
@:native("tostring") public function toString(): String;
|
@:native("tostring") public function toString():String;
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import cc.Term;
|
|||||||
@:native("window")
|
@:native("window")
|
||||||
@:luaDotMethod
|
@:luaDotMethod
|
||||||
extern class Window extends TerminalObject {
|
extern class Window extends TerminalObject {
|
||||||
public static function create(parent: TerminalObject, x: Int, y: Int, width: Int, height: Int, ?visible: Bool): Window;
|
public static function create(parent:TerminalObject, x:Int, y:Int, width:Int, height:Int, ?visible:Bool):Window;
|
||||||
|
|
||||||
public function setVisible(visible: Bool): Void;
|
public function setVisible(visible:Bool):Void;
|
||||||
public function redraw(): Void;
|
public function redraw():Void;
|
||||||
public function restoreCursor(): Void;
|
public function restoreCursor():Void;
|
||||||
public function getPosition(): TerminalPosition;
|
public function getPosition():TerminalPosition;
|
||||||
public function reposition(x: Int, y: Int, ?width: Int, ?height: Int): Void;
|
public function reposition(x:Int, y:Int, ?width:Int, ?height:Int):Void;
|
||||||
}
|
}
|
||||||
|
15
src/cc/periphs/Command.hx
Normal file
15
src/cc/periphs/Command.hx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class CommandResult {
|
||||||
|
var success:Bool;
|
||||||
|
var failMessage:Null<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern class Command {
|
||||||
|
public function getCommand():String;
|
||||||
|
|
||||||
|
public function setCommand(command:String):Void;
|
||||||
|
|
||||||
|
public function runCommand():CommandResult;
|
||||||
|
}
|
10
src/cc/periphs/Computer.hx
Normal file
10
src/cc/periphs/Computer.hx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
extern class Computer {
|
||||||
|
public function turnOn():Void; // Turn the other computer on.
|
||||||
|
public function shutdown():Void; // Shutdown the other computer.
|
||||||
|
public function reboot():Void; // Reboot or turn on the other computer.
|
||||||
|
public function getID():Int; // Get the other computer's ID.
|
||||||
|
public function isOn():Bool; // Determine if the other computer is on.
|
||||||
|
public function getLabel():Null<String>; // Get the other computer's label.
|
||||||
|
}
|
15
src/cc/periphs/Disk.hx
Normal file
15
src/cc/periphs/Disk.hx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
extern class Disk {
|
||||||
|
public function isDiskPresent():Bool; // Returns whether a disk is currently inserted in the drive.
|
||||||
|
public function getDiskLabel():Null<String>; // Returns the label of the disk in the drive if available.
|
||||||
|
public function setDiskLabel(?label:String):Void; // Sets or clears the label for a disk.
|
||||||
|
public function hasData():Bool; // Returns whether a disk with data is inserted.
|
||||||
|
public function getMountPath():Null<String>; // Returns the mount path for the inserted disk.
|
||||||
|
public function hasAudio():Bool; // Returns whether a disk with audio is inserted.
|
||||||
|
public function getAudioTitle():Null<String>; // Returns the title of the inserted audio disk.
|
||||||
|
public function playAudio():Void; // Plays the audio in the inserted disk, if available.
|
||||||
|
public function stopAudio():Void; // Stops any audio that may be playing.
|
||||||
|
public function ejectDisk():Void; // Ejects any disk that may be in the drive.
|
||||||
|
public function getDiskID():Int; // Returns the ID of the disk inserted in the drive.
|
||||||
|
}
|
6
src/cc/periphs/EnergyStorage.hx
Normal file
6
src/cc/periphs/EnergyStorage.hx
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
extern class EnergyStorage {
|
||||||
|
public function getEnergy():Int; // Get the energy of this block.
|
||||||
|
public function getEnergyCapacity():Int; // Get the maximum amount of energy this block can store.
|
||||||
|
}
|
9
src/cc/periphs/FluidStorage.hx
Normal file
9
src/cc/periphs/FluidStorage.hx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
import lua.Table;
|
||||||
|
|
||||||
|
extern class FluidStorage {
|
||||||
|
public function tanks():Table<Int, Table<String, Any>>;
|
||||||
|
public function pushFluid(toName:String, ?limit:Float, ?fluidName:String):Float;
|
||||||
|
public function pullFluid(fromName:String, ?limit:Float, ?fluidName:String):Float;
|
||||||
|
}
|
29
src/cc/periphs/ItemStorage.hx
Normal file
29
src/cc/periphs/ItemStorage.hx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
import lua.Table;
|
||||||
|
|
||||||
|
interface ReducedItemInfo {
|
||||||
|
public var count:Int;
|
||||||
|
public var name:String;
|
||||||
|
public var nbt:Null<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DetailedItemInfo extends ReducedItemInfo {
|
||||||
|
public var displayName:String;
|
||||||
|
public var tag:Null<String>;
|
||||||
|
public var maxCount:Int;
|
||||||
|
public var tags:Table<String, Bool>;
|
||||||
|
public var durability:Null<Float>;
|
||||||
|
public var damage:Null<Int>;
|
||||||
|
public var maxDamage:Null<Int>;
|
||||||
|
public var enchantments:Null<Array<{displayName:String, level:Int, name:String}>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern class ItemStorage {
|
||||||
|
public function size():Int; // Get the size of this inventory.
|
||||||
|
public function list():Table<Int, ReducedItemInfo>; // List all items in this inventory.
|
||||||
|
public function getItemDetail(slot:Int):DetailedItemInfo; // Get detailed information about an item.
|
||||||
|
public function pushItems(toName:String, fromSlot:Int, ?limit:Int, ?toSlot:Int):Int; // Push items from one inventory to another connected one.
|
||||||
|
public function pullItems(fromName:String, fromSlot:Int, ?limit:Int, ?toSlot:Int):Int; // Pull items from a connected inventory into this one.
|
||||||
|
public function getItemLimit(slot:Int):Int; // Get the maximum number of items which can be stored in this slot.
|
||||||
|
}
|
17
src/cc/periphs/Modem.hx
Normal file
17
src/cc/periphs/Modem.hx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
import lua.Table;
|
||||||
|
|
||||||
|
@:luaDotMethod extern class Modem {
|
||||||
|
public function open(channel:Int):Void; // Open a channel on a modem.
|
||||||
|
public function isOpen(channel:Int):Bool; // Check if a channel is open.
|
||||||
|
public function close(channel:Int):Void; // Close an open channel, meaning it will no longer receive messages.
|
||||||
|
public function closeAll():Void; // Close all open channels.
|
||||||
|
public function transmit(channel:Int, replyChannel:Int, payload:Any):Void; // Sends a modem message on a certain channel.
|
||||||
|
public function isWireless():Bool; // Determine if this is a wired or wireless modem.
|
||||||
|
public function getNamesRemote():Table<Int, String>; // List all remote peripherals on the wired network.
|
||||||
|
public function isPresentRemote(name:String):Bool; // Determine if a peripheral is available on this wired network.
|
||||||
|
public function getTypeRemote(name:String):String; // Get the type of a peripheral is available on this wired network.
|
||||||
|
public function getMethodsRemote(name:String):Table<Int, String>; // Get all available methods for the remote peripheral with the given name.
|
||||||
|
public function getNameLocal():String; // Returns the network name of the current computer, if the modem is on.
|
||||||
|
}
|
48
src/cc/periphs/Monitor.hx
Normal file
48
src/cc/periphs/Monitor.hx
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
import cc.Term.TerminalSize;
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class Position {
|
||||||
|
var x:Int;
|
||||||
|
var y:Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef Color = Int;
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class ColorData {
|
||||||
|
var r:Float;
|
||||||
|
var g:Float;
|
||||||
|
var b:Float;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:luaDotMethod extern class Monitor {
|
||||||
|
public function setTextScale(scale:Float):Void; // Set the scale of this monitor.
|
||||||
|
public function getTextScale():Float; // Get the monitor's current text scale.
|
||||||
|
public function write(text:String):Void; // Write text at the current cursor position, moving the cursor to the end of the text.
|
||||||
|
public function scroll(y:Int):Void; // Move all positions up (or down) by y pixels.
|
||||||
|
public function getCursorPos():Position; // Get the position of the cursor.
|
||||||
|
public function setCursorPos(x:Int, y:Int):Void; // et the position of the cursor.
|
||||||
|
public function getCursorBlink():Bool; // Checks if the cursor is currently blinking.
|
||||||
|
public function setCursorBlink(blink:Bool):Void; // Sets whether the cursor should be visible (and blinking) at the current cursor position.
|
||||||
|
public function getSize():TerminalSize; // Get the size of the terminal.
|
||||||
|
public function clear():Void; // Clears the terminal, filling it with the current background colour.
|
||||||
|
public function clearLine():Void; // Clears the line the cursor is currently on, filling it with the current background colour.
|
||||||
|
public function getTextColour():Color; // Return the colour that new text will be written as.
|
||||||
|
public function getTextColor():Color; // Return the colour that new text will be written as.
|
||||||
|
public function setTextColour(colour:Color):Void; // Set the colour that new text will be written as.
|
||||||
|
public function setTextColor(colour:Color):Void; // Set the colour that new text will be written as.
|
||||||
|
public function getBackgroundColour():Color; // Return the current background colour.
|
||||||
|
public function getBackgroundColor():Color; // Return the current background colour.
|
||||||
|
public function setBackgroundColour(colour:Color):Void; // Set the current background colour.
|
||||||
|
public function setBackgroundColor(colour:Color):Void; // Set the current background colour.
|
||||||
|
public function isColour():Bool; // Determine if this terminal supports colour.
|
||||||
|
public function isColor():Bool; // Determine if this terminal supports colour.
|
||||||
|
public function blit(text:String, textColour:String,
|
||||||
|
backgroundColour:String):Void; // Writes text to the terminal with the specific foreground and background characters.
|
||||||
|
public function setPaletteColour(index:Color, packedColour:Int):Void; // Set the palette for a specific colour.
|
||||||
|
public function setPaletteColor(index:Color, packedColour:Int):Void; // Set the palette for a specific colour.
|
||||||
|
public function getPaletteColour(colour:Color):ColorData; // Get the current palette for a specific colour.
|
||||||
|
public function getPaletteColor(colour:Color):ColorData; // Get the current palette for a specific colour.
|
||||||
|
}
|
19
src/cc/periphs/Printer.hx
Normal file
19
src/cc/periphs/Printer.hx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class PagePosition {
|
||||||
|
var x:Int;
|
||||||
|
var y:Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern class Printer {
|
||||||
|
public function write(text:String):Void; // Writes text to the current page.
|
||||||
|
public function getCursorPos():PagePosition; // Returns the current position of the cursor on the page.
|
||||||
|
public function setCursorPos(x:Int, y:Int):Void; // Sets the position of the cursor on the page.
|
||||||
|
public function getPageSize():PagePosition; // Returns the size of the current page.
|
||||||
|
public function newPage():Bool; // Starts printing a new page.
|
||||||
|
public function endPage():Bool; // Finalizes printing of the current page and outputs it to the tray.
|
||||||
|
public function setPageTitle(?title:String):Void; // Sets the title of the current page.
|
||||||
|
public function getInkLevel():Float; // Returns the amount of ink left in the printer.
|
||||||
|
public function getPaperLevel():Int; // Returns the amount of paper left in the printer.
|
||||||
|
}
|
6
src/cc/periphs/Speaker.hx
Normal file
6
src/cc/periphs/Speaker.hx
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package cc.periphs;
|
||||||
|
|
||||||
|
extern class Speaker {
|
||||||
|
public function playSound(name:String, ?volume:Float, ?pitch:Float):Bool; // Plays a sound through the speaker.
|
||||||
|
public function playNote(name:String, ?volume:Float, ?pitch:Float):Bool; // Plays a note block note through the speaker.
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user