Add HTTP lib and globals
This commit is contained in:
parent
c3ee593f86
commit
808c1972a9
@ -4,9 +4,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"tags": ["computercraft", "cc", "minecraft", "lua"],
|
"tags": ["computercraft", "cc", "minecraft", "lua"],
|
||||||
"description": "Bindings for the Lua APIs of the ComputerCraft mod for Minecraft",
|
"description": "Bindings for the Lua APIs of the ComputerCraft mod for Minecraft",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"classPath": "src",
|
"classPath": "src",
|
||||||
"releasenote": "Initial release",
|
"releasenote": "Adds missing HTTP api and globals (in ComputerCraft class)",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"apemanzilla"
|
"apemanzilla"
|
||||||
]
|
]
|
||||||
|
10
src/cc/ComputerCraft.hx
Normal file
10
src/cc/ComputerCraft.hx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package src.cc;
|
||||||
|
|
||||||
|
@:native("_G")
|
||||||
|
extern class ComputerCraft {
|
||||||
|
public static var _CC_DEFAULT_SETTINGS: String;
|
||||||
|
public static function printError(message: String): Void;
|
||||||
|
public static function sleep(seconds: Float): Void;
|
||||||
|
public static function read(?replacement: String): String; // todo: second and third args
|
||||||
|
public static var _HOST: String;
|
||||||
|
}
|
24
src/cc/HTTP.hx
Normal file
24
src/cc/HTTP.hx
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package src.cc;
|
||||||
|
|
||||||
|
import lua.Table;
|
||||||
|
|
||||||
|
@:multiReturn
|
||||||
|
extern class HTTPCheckReturn {
|
||||||
|
public var allowed: Bool;
|
||||||
|
public var error: Null<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern class HTTPResponse {
|
||||||
|
public function close(): Void;
|
||||||
|
public function readLine(): String;
|
||||||
|
public function readAll(): String;
|
||||||
|
public function getResponseCode(): Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:native("http")
|
||||||
|
extern class HTTP {
|
||||||
|
public static function checkURL(url: String): Bool;
|
||||||
|
public static function request(url: String, ?postData: String, ?headers: Table<String, String>): Void;
|
||||||
|
public static function get(url: String, ?headers: Table<String, String>): Null<HTTPResponse>;
|
||||||
|
public static function post(url: String, postData: String, ?header: Table<String, String>): Null<HTTPResponse>;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user