BIG FORMATING COMMIT

This commit is contained in:
Djeeberjr 2023-07-30 15:55:22 +02:00
parent 088fce0aaa
commit 91972107eb
103 changed files with 1610 additions and 1585 deletions

View File

@ -7,4 +7,3 @@ class Startup {
main.run();
}
}

View File

@ -7,7 +7,6 @@ import kernel.ps.Process;
using tink.CoreApi;
class HelloWorld implements Process {
public function new() {}
public function run(handle:ProcessHandle) {

View File

@ -6,7 +6,8 @@ import lib.CLIAppBase;
class Perf extends CLIAppBase {
public function new() {
registerSyncSubcommand("inspect", (args) -> {
if (args.length < 1) return false;
if (args.length < 1)
return false;
var result = Peripheral.inspect(args[0]);

View File

@ -54,7 +54,6 @@ class Service extends CLIAppBase {
}, "<name>");
registerSyncSubcommand("list", (args) -> {
var list = ServiceManager.listRunning();
for (name in list) {

View File

@ -38,7 +38,8 @@ class Terminal implements Process {
// Add input event handlers
handle.addCallbackLink(this.ctx.onChar.handle(char -> {
if (this.runningPID > 0) return;
if (this.runningPID > 0)
return;
this.input += char;
this.requestRender();
}));
@ -47,11 +48,13 @@ class Terminal implements Process {
handle.addCallbackLink(this.ctx.onKey.handle(e -> {
switch (e.keyCode) {
case 259: // Backspace
if (this.runningPID > 0) return;
if (this.runningPID > 0)
return;
this.input = this.input.substr(0, this.input.length - 1);
this.requestRender();
case 257: // Enter
if (this.runningPID > 0) return;
if (this.runningPID > 0)
return;
this.backlog.push("> " + this.input);
var command = this.input;
this.input = "";

View File

@ -40,5 +40,4 @@ class Turtle extends CLIAppBase {
return false;
}
}
}

View File

@ -59,8 +59,7 @@ class ResManager implements Process {
private function persist() {
var store = new KVStore("export");
var saveExports: Array<{name: String, addr: String, type: String}> =
[for (k => v in this.exports) {name: k, addr: v.getAddr(), type: v.getType()}];
var saveExports:Array<{name:String, addr:String, type:String}> = [for (k => v in this.exports) {name: k, addr: v.getAddr(), type: v.getType()}];
store.set("exports", saveExports);
@ -86,6 +85,5 @@ class ResManager implements Process {
handle.writeLine('Loaded export: ${export.name} on ${export.addr}');
}
}
}

View File

@ -41,11 +41,16 @@ class PFClient implements Process {
var childre:Array<UIElement> = [
new TextElement('Acc: ${acc}'),
new TextElement('Pos: X:${pos.x} Y:${pos.y} Z:${pos.z}'),
new TextElement('UPDATE', { style: {bgColor: Gray}, uiEvents: {onClick: () -> {
new TextElement('UPDATE', {
style: {bgColor: Gray},
uiEvents: {
onClick: () -> {
kernel.gps.GPS.locate().handle((pos) -> {
this.requestRender();
});
}}}),
}
}
}),
];
this.root.setChildren(childre);

View File

@ -12,12 +12,16 @@ class EndOfLoop {
public static function endOfLoop(func:Void->Void) {
backlog.push(func);
if (!isQueued) { OS.queueEvent("endofloop", null); }
if (!isQueued) {
OS.queueEvent("endofloop", null);
}
}
@:allow(kernel.KernelEvents)
private static function run() {
for (func in backlog) { func(); }
for (func in backlog) {
func();
}
backlog = [];
isQueued = false;
}

View File

@ -14,11 +14,9 @@ import lib.Debug;
import kernel.ui.WindowManager;
import kernel.peripherals.Peripherals.Peripheral;
import kernel.net.Net;
import kernel.DCEHack; // Important for DCE hack
class Init {
@:allow(kernel.KernelEvents)
private static var mainEvent:MainEvent;

View File

@ -19,6 +19,7 @@ class KernelEvents {
Depends on: (Nothing)
**/
public static var onAlarm(default, null):Signal<Int>;
public static var onChar(default, null):Signal<String>;
public static var onDisk(default, null):Signal<String>;
public static var onDiskEject(default, null):Signal<String>;
@ -147,7 +148,6 @@ class KernelEvents {
}
public static function shutdown() {
// clearing screens
for (screen in Peripheral.getAllScreens()) {
screen.reset();
@ -253,35 +253,65 @@ class KernelEvents {
@:allow(lib.Debug)
private static function printListenerCount() {
if (onAlarmTrigger.getLength() > 0) Log.debug("onAlarm: " + onAlarmTrigger.getLength());
if (onCharTrigger.getLength() > 0) Log.debug("onChar: " + onCharTrigger.getLength());
if (onDiskTrigger.getLength() > 0) Log.debug("onDisk: " + onDiskTrigger.getLength());
if (onDiskEjectTrigger.getLength() > 0) Log.debug("onDiskEject: " + onDiskEjectTrigger.getLength());
if (onHttpCheckTrigger.getLength() > 0) Log.debug("onHttpCheck: " + onHttpCheckTrigger.getLength());
if (onHttpFailureTrigger.getLength() > 0) Log.debug("onHttpFailure: " + onHttpFailureTrigger.getLength());
if (onHttpSuccessTrigger.getLength() > 0) Log.debug("onHttpSuccess: " + onHttpSuccessTrigger.getLength());
if (onKeyTrigger.getLength() > 0) Log.debug("onKey: " + onKeyTrigger.getLength());
if (onKeyUpTrigger.getLength() > 0) Log.debug("onKeyUp: " + onKeyUpTrigger.getLength());
if (onModemMessageTrigger.getLength() > 0) Log.debug("onModemMessage: " + onModemMessageTrigger.getLength());
if (onMonitorResizeTrigger.getLength() > 0) Log.debug("onMonitorResize: " + onMonitorResizeTrigger.getLength());
if (onMonitorTouchTrigger.getLength() > 0) Log.debug("onMonitorTouch: " + onMonitorTouchTrigger.getLength());
if (onMouseClickTrigger.getLength() > 0) Log.debug("onMouseClick: " + onMouseClickTrigger.getLength());
if (onMouseDragTrigger.getLength() > 0) Log.debug("onMouseDrag: " + onMouseDragTrigger.getLength());
if (onMouseScrollTrigger.getLength() > 0) Log.debug("onMouseScroll: " + onMouseScrollTrigger.getLength());
if (onMouseUpTrigger.getLength() > 0) Log.debug("onMouseUp: " + onMouseUpTrigger.getLength());
if (onPasteTrigger.getLength() > 0) Log.debug("onPaste: " + onPasteTrigger.getLength());
if (onPeripheralTrigger.getLength() > 0) Log.debug("onPeripheral: " + onPeripheralTrigger.getLength());
if (onPeripheralDetachTrigger.getLength() > 0) Log.debug("onPeripheralDetach: " + onPeripheralDetachTrigger.getLength());
if (onRedstoneTrigger.getLength() > 0) Log.debug("onRedstone: " + onRedstoneTrigger.getLength());
if (onSpeakerAudioEmptyTrigger.getLength() > 0) Log.debug("onSpeakerAudioEmpty: " + onSpeakerAudioEmptyTrigger.getLength());
if (onTaskCompleteTrigger.getLength() > 0) Log.debug("onTaskComplete: " + onTaskCompleteTrigger.getLength());
if (onTermResizeTrigger.getLength() > 0) Log.debug("onTermResize: " + onTermResizeTrigger.getLength());
if (onTerminateTrigger.getLength() > 0) Log.debug("onTerminate: " + onTerminateTrigger.getLength());
if (onTimerTrigger.getLength() > 0) Log.debug("onTimer: " + onTimerTrigger.getLength());
if (onTurtleInventoryTrigger.getLength() > 0) Log.debug("onTurtleInventory: " + onTurtleInventoryTrigger.getLength());
if (onWebsocketCloseTrigger.getLength() > 0) Log.debug("onWebsocketClose: " + onWebsocketCloseTrigger.getLength());
if (onWebsocketFailureTrigger.getLength() > 0) Log.debug("onWebsocketFailure: " + onWebsocketFailureTrigger.getLength());
if (onWebsocketMessageTrigger.getLength() > 0) Log.debug("onWebsocketMessage: " + onWebsocketMessageTrigger.getLength());
if (onWebsocketSuccessTrigger.getLength() > 0) Log.debug("onWebsocketSuccess: " + onWebsocketSuccessTrigger.getLength());
if (onAlarmTrigger.getLength() > 0)
Log.debug("onAlarm: " + onAlarmTrigger.getLength());
if (onCharTrigger.getLength() > 0)
Log.debug("onChar: " + onCharTrigger.getLength());
if (onDiskTrigger.getLength() > 0)
Log.debug("onDisk: " + onDiskTrigger.getLength());
if (onDiskEjectTrigger.getLength() > 0)
Log.debug("onDiskEject: " + onDiskEjectTrigger.getLength());
if (onHttpCheckTrigger.getLength() > 0)
Log.debug("onHttpCheck: " + onHttpCheckTrigger.getLength());
if (onHttpFailureTrigger.getLength() > 0)
Log.debug("onHttpFailure: " + onHttpFailureTrigger.getLength());
if (onHttpSuccessTrigger.getLength() > 0)
Log.debug("onHttpSuccess: " + onHttpSuccessTrigger.getLength());
if (onKeyTrigger.getLength() > 0)
Log.debug("onKey: " + onKeyTrigger.getLength());
if (onKeyUpTrigger.getLength() > 0)
Log.debug("onKeyUp: " + onKeyUpTrigger.getLength());
if (onModemMessageTrigger.getLength() > 0)
Log.debug("onModemMessage: " + onModemMessageTrigger.getLength());
if (onMonitorResizeTrigger.getLength() > 0)
Log.debug("onMonitorResize: " + onMonitorResizeTrigger.getLength());
if (onMonitorTouchTrigger.getLength() > 0)
Log.debug("onMonitorTouch: " + onMonitorTouchTrigger.getLength());
if (onMouseClickTrigger.getLength() > 0)
Log.debug("onMouseClick: " + onMouseClickTrigger.getLength());
if (onMouseDragTrigger.getLength() > 0)
Log.debug("onMouseDrag: " + onMouseDragTrigger.getLength());
if (onMouseScrollTrigger.getLength() > 0)
Log.debug("onMouseScroll: " + onMouseScrollTrigger.getLength());
if (onMouseUpTrigger.getLength() > 0)
Log.debug("onMouseUp: " + onMouseUpTrigger.getLength());
if (onPasteTrigger.getLength() > 0)
Log.debug("onPaste: " + onPasteTrigger.getLength());
if (onPeripheralTrigger.getLength() > 0)
Log.debug("onPeripheral: " + onPeripheralTrigger.getLength());
if (onPeripheralDetachTrigger.getLength() > 0)
Log.debug("onPeripheralDetach: " + onPeripheralDetachTrigger.getLength());
if (onRedstoneTrigger.getLength() > 0)
Log.debug("onRedstone: " + onRedstoneTrigger.getLength());
if (onSpeakerAudioEmptyTrigger.getLength() > 0)
Log.debug("onSpeakerAudioEmpty: " + onSpeakerAudioEmptyTrigger.getLength());
if (onTaskCompleteTrigger.getLength() > 0)
Log.debug("onTaskComplete: " + onTaskCompleteTrigger.getLength());
if (onTermResizeTrigger.getLength() > 0)
Log.debug("onTermResize: " + onTermResizeTrigger.getLength());
if (onTerminateTrigger.getLength() > 0)
Log.debug("onTerminate: " + onTerminateTrigger.getLength());
if (onTimerTrigger.getLength() > 0)
Log.debug("onTimer: " + onTimerTrigger.getLength());
if (onTurtleInventoryTrigger.getLength() > 0)
Log.debug("onTurtleInventory: " + onTurtleInventoryTrigger.getLength());
if (onWebsocketCloseTrigger.getLength() > 0)
Log.debug("onWebsocketClose: " + onWebsocketCloseTrigger.getLength());
if (onWebsocketFailureTrigger.getLength() > 0)
Log.debug("onWebsocketFailure: " + onWebsocketFailureTrigger.getLength());
if (onWebsocketMessageTrigger.getLength() > 0)
Log.debug("onWebsocketMessage: " + onWebsocketMessageTrigger.getLength());
if (onWebsocketSuccessTrigger.getLength() > 0)
Log.debug("onWebsocketSuccess: " + onWebsocketSuccessTrigger.getLength());
}
}

View File

@ -27,6 +27,7 @@ class KernelSettings {
public static var hostname(get, set):String;
private static var _hostname:String = get("hostname");
private static inline function get_hostname():String {
return _hostname;
}
@ -40,6 +41,7 @@ class KernelSettings {
public static var siteController(get, set):NetworkID;
private static var _siteController:NetworkID = get("siteController");
private static function get_siteController():NetworkID {
return _siteController;
}

View File

@ -5,7 +5,6 @@ import cc.FileSystem.FileHandle;
using tink.CoreApi;
abstract ReadHandle(FileHandle) from FileHandle {
public inline function new(handle:FileHandle) {
this = handle;
}
@ -28,7 +27,6 @@ abstract ReadHandle(FileHandle) from FileHandle {
}
abstract WriteHandle(FileHandle) from FileHandle {
public inline function new(handle:FileHandle) {
this = handle;
}
@ -51,7 +49,6 @@ abstract WriteHandle(FileHandle) from FileHandle {
}
abstract ReadBinaryHandle(FileHandle) from FileHandle {
public inline function new(handle:FileHandle) {
this = handle;
}
@ -82,7 +79,6 @@ abstract ReadBinaryHandle(FileHandle) from FileHandle {
}
abstract WriteBinaryHandle(FileHandle) from FileHandle {
public inline function new(handle:FileHandle) {
this = handle;
}

View File

@ -73,7 +73,8 @@ class GPS {
}
private static function persistCachedPositon() {
if (cachedPosition == null) return;
if (cachedPosition == null)
return;
var kvstore = new KVStore("gps");
kvstore.set("cpos", cachedPosition);
@ -114,7 +115,6 @@ class GPS {
posAccuracy = 2;
return;
}
}
private static function sendPositionRequest() {
@ -125,20 +125,25 @@ class GPS {
private static function handlePackage(pack:Package<Noise>, dist:Float, iface:INetworkInterface) {
switch (pack.type) {
case GPSRequest:
if (!shouldRespond) return;
if (posAccuracy < 2) return;
if (cachedPosition == null) return;
if (!shouldRespond)
return;
if (posAccuracy < 2)
return;
if (cachedPosition == null)
return;
var response = new Package(Net.networkID, pack.fromID, pack.msgID, GPSResponse(cachedPosition), null, 0);
iface.send(pack.fromID, Net.networkID, response);
case GPSResponse(pos):
if (lastPositionResponse.contains({pos:pos,dist:dist})) return; // Ignore duplicate responses
if (lastPositionResponse.contains({pos: pos, dist: dist}))
return; // Ignore duplicate responses
lastPositionResponse.push({pos: pos, dist: dist});
// TODO: wait for a few seconds before calculating the position, so we can get more responses
if (lastPositionResponse.length < 4) return; // We need at least 3 responses to calculate the position
if (lastPositionResponse.length < 4)
return; // We need at least 3 responses to calculate the position
var calculatedPosition = calculatePosition();
@ -148,7 +153,8 @@ class GPS {
lastPositionResponse = []; // Reset the response array
if (calculatedPosition == null) return;
if (calculatedPosition == null)
return;
cachedPosition = calculatedPosition;
posAccuracy = 3;
@ -158,7 +164,8 @@ class GPS {
}
private static function calculatePosition():Null<Pos3> {
if (lastPositionResponse.length < 3) return null;
if (lastPositionResponse.length < 3)
return null;
// do a simple trilateration with the last 3 responses for now
var p1 = lastPositionResponse[0].pos;
@ -171,7 +178,8 @@ class GPS {
var result = trilateration(p1, p2, p3, r1, r2, r3);
if (result.a.close(result.b)) return result.a;
if (result.a.close(result.b))
return result.a;
// If we have more than 3 responses, we can use the 4th response to determine which of the two positions is correct
// TODO: if this is a pocket computer we cant use this since it can move freely
@ -184,12 +192,15 @@ class GPS {
return null; // The two positions are essentially the same, so we cant determine which one is correct
}
if (err1 < err2) return result.a;
if (err2 < err1) return result.b;
if (err1 < err2)
return result.a;
if (err2 < err1)
return result.b;
}
// last resort, just use the position that is closest to a whole number (whithin a resonable margin of error)
if (!shouldDoWholeNumberCheck) return null;
if (!shouldDoWholeNumberCheck)
return null;
// TODO: mark the position as not so accurate if we use this method

View File

@ -40,7 +40,8 @@ class INS {
@:allow(kernel.turtle.Turtle)
private static function turnLeft() {
if (heading == null) return;
if (heading == null)
return;
if (heading.x == 0 && heading.z == -1) {
heading = {x: -1, y: 0, z: 0};
} else if (heading.x == -1 && heading.z == 0) {
@ -54,7 +55,8 @@ class INS {
@:allow(kernel.turtle.Turtle)
private static function turnRight() {
if (heading == null) return;
if (heading == null)
return;
if (heading.x == 0 && heading.z == -1) {
heading = {x: 1, y: 0, z: 0};
} else if (heading.x == -1 && heading.z == 0) {
@ -80,7 +82,6 @@ class INS {
public static function align():Promise<Noise> {
Log.info("Aligning INS");
return new Promise<Noise>((resolve, reject) -> {
if (Turtle.instance.getFuelLevel() < 2) {
Log.warn("Not enough fuel to align");
reject(new Error("Not enough fuel to align"));
@ -124,7 +125,6 @@ class INS {
resolve(Noise);
});
});
return null;
});
@ -200,5 +200,4 @@ class INS {
private static function rotatePos3ToLeft(pos3:Pos3):Pos3 {
return rotatePos3ToRight(rotatePos3ToRight(rotatePos3ToRight(pos3)));
}
}

View File

@ -3,7 +3,6 @@ package kernel.http;
using lua.Table;
class HTTPFailure {
public final reason:String;
public final statusCode:Null<StatusCode>;
public final headers:Map<String, String>;

View File

@ -3,7 +3,6 @@ package kernel.http;
using lua.Table;
class HTTPResponse {
public final statusCode:StatusCode;
public final headers:Map<String, String>;
public final body:String;

View File

@ -1,6 +1,7 @@
package kernel.net;
import kernel.net.Package.GenericPackage;
using tink.CoreApi;
/**

View File

@ -2,6 +2,7 @@ package kernel.net;
import kernel.net.Package.GenericPackage;
import kernel.log.Log;
using tink.CoreApi;
/**

View File

@ -21,6 +21,7 @@ class Net {
Depends on: KernelEvents
**/
public static inline final BRODCAST_PORT:Int = 65533;
public static inline final MESSAGE_TIMEOUT:Int = 3;
public static inline final DEFAULT_TTL:Int = 10;
@ -120,7 +121,6 @@ class Net {
private static function forwardPackage(pack:GenericPackage) {
if (pack.ttl == 0) {
if (pack.type.match(Data(_))) {
// If the package is a data package and the ttl hits 0
// we send a "died" message to the sender
@ -201,7 +201,6 @@ class Net {
var timeout:Timer = null;
responseBus[pack.msgID] = ((reponse:Outcome<GenericPackage, Error>) -> {
switch reponse {
case Success(pack):
resolve(pack);
@ -282,7 +281,8 @@ class Net {
};
for (modem in Peripheral.getAllModems()) {
if (!modem.isWireless()) continue;
if (!modem.isWireless())
continue;
modem.send(Net.BRODCAST_PORT, networkID, pack);
}
}

View File

@ -20,7 +20,6 @@ class Routing {
/**
Depends on: Peripheral
**/
public static inline final UPDATE_WAIT_TIME:Float = 1;
public static var onNewNeigbor(default, null):Signal<Int>;

View File

@ -169,7 +169,6 @@ class BigReactor implements IPeripheral {
// getEnergyStats
// getCoolantFluidStats
// getHotFluidStats
// TODO: need research
// isMethodAvailable(method: String): Bool
// mbGetMaximumCoordinate(): Pos3

View File

@ -1,6 +1,7 @@
package kernel.peripherals;
import cc.Peripheral;
using tink.CoreApi;
class Drive implements IPeripheral {

View File

@ -90,18 +90,19 @@ class Peripheral {
public static function getScreen(addr:String):Null<Screen> {
var addr = safeGetAddr(addr, Screen.TYPE_NAME);
if (addr == null) return null;
if (addr == null)
return null;
return new Screen(addr);
}
public static function getAllScreens():Array<Screen> {
return [for (addr in findAddrByType(Screen.TYPE_NAME)) new Screen(addr)];
}
public static function getModem(addr:String):Null<Modem> {
var addr = safeGetAddr(addr, Modem.TYPE_NAME);
if (addr == null) return null;
if (addr == null)
return null;
return new Modem(addr);
}
@ -111,7 +112,8 @@ class Peripheral {
public static function getDrive(addr:String):Null<Drive> {
var addr = safeGetAddr(addr, Drive.TYPE_NAME);
if (addr == null) return null;
if (addr == null)
return null;
return new Drive(addr);
}
@ -126,7 +128,8 @@ class Peripheral {
public static function getPrinter(addr:String):Null<Printer> {
var addr = safeGetAddr(addr, Printer.TYPE_NAME);
if (addr == null) return null;
if (addr == null)
return null;
return new Printer(addr);
}
@ -136,7 +139,8 @@ class Peripheral {
public static function getEnergyStorage(addr:String):Null<EnergyStorage> {
var addr = safeGetAddr(addr, EnergyStorage.TYPE_NAME);
if (addr == null) return null;
if (addr == null)
return null;
return new EnergyStorage(addr);
}
@ -146,7 +150,8 @@ class Peripheral {
public static function getComputer(addr:String):Null<Computer> {
var addr = safeGetAddr(addr, Computer.TYPE_NAME);
if (addr == null) return null;
if (addr == null)
return null;
return new Computer(addr);
}

View File

@ -23,9 +23,7 @@ class Printer implements IPeripheral {
return TYPE_NAME;
}
public function write(text: String){
}
public function write(text:String) {}
public function getCurserPos():Pos {
return new Pos({x: 0, y: 0});

View File

@ -69,7 +69,6 @@ class Redstone implements IPeripheral implements IExportable {
this.onChangeTrigger.trigger(null);
}
});
}
public function getAddr():String {

View File

@ -4,6 +4,7 @@ import kernel.ps.ProcessManager.PID;
import kernel.ui.WindowContext;
import kernel.ui.WindowManager;
import haxe.ds.ReadOnlyArray;
using tink.CoreApi;
typedef HandleConfig = {
@ -47,12 +48,15 @@ class ProcessHandle {
this.hasExited = true;
this.dispose();
EndOfLoop.endOfLoop(() ->{this.closeFutureResolev(success);});
EndOfLoop.endOfLoop(() -> {
this.closeFutureResolev(success);
});
ProcessManager.removeProcess(this.pid);
}
public function write(message:String):Void {
if (this.hasExited) return;
if (this.hasExited)
return;
if (this.config.onWrite != null) {
this.config.onWrite.invoke(message);
}

View File

@ -35,5 +35,4 @@ class Service {
public function stop() {
ProcessManager.kill(this.pid);
}
}

View File

@ -137,5 +137,4 @@ class ServiceManager {
var srv = services.get(name);
return srv.ps;
}
}

View File

@ -36,42 +36,48 @@ class Turtle {
public function forward():Outcome<Noise, String> {
var r = cc.Turtle.forward();
var r2 = conterToOutcome(r);
if (r2.isSuccess()) INS.moveForward();
if (r2.isSuccess())
INS.moveForward();
return r2;
}
public function back():Outcome<Noise, String> {
var r = cc.Turtle.back();
var r2 = conterToOutcome(r);
if (r2.isSuccess()) INS.moveBackward();
if (r2.isSuccess())
INS.moveBackward();
return r2;
}
public function up():Outcome<Noise, String> {
var r = cc.Turtle.up();
var r2 = conterToOutcome(r);
if (r2.isSuccess()) INS.moveUp();
if (r2.isSuccess())
INS.moveUp();
return r2;
}
public function down():Outcome<Noise, String> {
var r = cc.Turtle.down();
var r2 = conterToOutcome(r);
if (r2.isSuccess()) INS.moveDown();
if (r2.isSuccess())
INS.moveDown();
return r2;
}
public function turnLeft():Outcome<Noise, String> {
var r = cc.Turtle.turnLeft();
var r2 = conterToOutcome(r);
if (r2.isSuccess()) INS.turnRight();
if (r2.isSuccess())
INS.turnRight();
return r2;
}
public function turnRight():Outcome<Noise, String> {
var r = cc.Turtle.turnRight();
var r2 = conterToOutcome(r);
if (r2.isSuccess()) INS.turnRight();
if (r2.isSuccess())
INS.turnRight();
return r2;
}

View File

@ -101,11 +101,13 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
//
public inline function write(text:String) {
if (enabled) target.write(text);
if (enabled)
target.write(text);
}
public inline function scroll(y:Int) {
if (enabled) target.scroll(y);
if (enabled)
target.scroll(y);
}
public inline function getCursorPos():Pos {
@ -113,7 +115,8 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
}
public inline function setCursorPos(x:Int, y:Int) {
if (enabled) target.setCursorPos(x, y);
if (enabled)
target.setCursorPos(x, y);
}
public inline function getCursorBlink():Bool {
@ -121,7 +124,8 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
}
public inline function setCursorBlink(blink:Bool) {
if (enabled) target.setCursorBlink(blink);
if (enabled)
target.setCursorBlink(blink);
}
public inline function getSize():Vec2<Int> {
@ -129,11 +133,13 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
}
public inline function clear() {
if (enabled) target.clear();
if (enabled)
target.clear();
}
public inline function clearLine() {
if (enabled) target.clearLine();
if (enabled)
target.clearLine();
}
public inline function getTextColor():Color {
@ -141,7 +147,8 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
}
public inline function setTextColor(color:Color) {
if (enabled) target.setTextColor(color);
if (enabled)
target.setTextColor(color);
}
public inline function getBackgroundColor():Color {
@ -149,7 +156,8 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
}
public inline function setBackgroundColor(color:Color) {
if (enabled) target.setBackgroundColor(color);
if (enabled)
target.setBackgroundColor(color);
}
public inline function isColor():Bool {
@ -157,6 +165,7 @@ class StatelessVirtualTermWriter implements VirtualTermWriter {
}
public inline function reset() {
if (enabled) target.reset();
if (enabled)
target.reset();
}
}

View File

@ -35,6 +35,7 @@ interface TermWriteable {
public function getBackgroundColor():Color;
public function setBackgroundColor(color:Color):Void;
public function isColor():Bool;
// public function setPaletteColor(...);
// public function getPaletteColor(color);

View File

@ -15,6 +15,7 @@ class WindowManager {
Depends on: KernelEvents, Peripheral
**/
private static var currentMainContext:WindowContext;
private static final outputMap:Map<String, WindowContext> = new Map();
@:allow(kernel.Init)

View File

@ -35,7 +35,6 @@ abstract class CLIAppBase implements Process {
printHelp();
return handle.close(false);
}
}
private function registerSyncSubcommand(command:String, callback:(Array<String>) -> Bool, synopsis:String = null) {

View File

@ -31,11 +31,7 @@ class HomeContext {
private var selectedOutput:String = "main";
private var selectedOutputIndex:Int = -1;
private final listedApps:Array<String> = [
"terminal",
"log",
"pfclient"
];
private final listedApps:Array<String> = ["terminal", "log", "pfclient"];
public function new() {}
@ -154,14 +150,12 @@ class HomeContext {
workspaceIDs.sort((a, b) -> a - b);
var children:Array<UIElement> = [
for (i in workspaceIDs) new TextElement('Switch to ${i + 1}', {uiEvents: {onClick: this.handleSelectContext.bind(i)}})
for (i in workspaceIDs)
new TextElement('Switch to ${i + 1}', {uiEvents: {onClick: this.handleSelectContext.bind(i)}})
];
for (i in 0...listedApps.length) {
children.push(new TextElement(
'Add ${BinStore.getNameByAlias(listedApps[i])}',
{uiEvents: {onClick: this.spawnPs.bind(listedApps[i])}}
));
children.push(new TextElement('Add ${BinStore.getNameByAlias(listedApps[i])}', {uiEvents: {onClick: this.spawnPs.bind(listedApps[i])}}));
}
children.push(new TextElement('Output: ${selectedOutput}', {uiEvents: {onClick: this.cycleOutput}}));

View File

@ -4,7 +4,6 @@ package lib;
Represents an item in the game.
**/
abstract Item(String) to String {
public inline function new(name:String) {
// Check if the name is valid. in the format `mod:item_name` e.g. `minecraft:apple`
// TODO: implement

View File

@ -10,6 +10,7 @@ import haxe.ds.StringMap;
**/
class KVStore {
private var kvStore:StringMap<Dynamic> = new StringMap();
public final namespace:String;
public function new(namespace:String) {

View File

@ -1,7 +1,6 @@
package lib;
class Rect {
private final tl:Pos;
private final br:Pos;

View File

@ -13,15 +13,12 @@ using tink.CoreApi;
class RessourceNames {
public static function get(name:String, controllerID:NetworkID = -1):Promise<Null<NetworkID>> {
if (controllerID == -1) controllerID = KernelSettings.siteController;
if (controllerID == -1)
controllerID = KernelSettings.siteController;
var payload:GetRequest = {name: name, type: "get"};
return Net.sendAndAwait(
controllerID,
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
payload
).map((res)->{
return Net.sendAndAwait(controllerID, SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO, payload).map((res) -> {
switch (res) {
case Success(pkg):
return Success(pkg.data.netID);
@ -32,47 +29,37 @@ class RessourceNames {
}
public static function register(name:String, netID:NetworkID, controllerID:NetworkID = -1):Promise<Bool> {
if (controllerID == -1) controllerID = KernelSettings.siteController;
if (controllerID == -1)
controllerID = KernelSettings.siteController;
var payload:RegisterRequest = {name: name, netID: netID, type: "register"};
return Net.sendAndAwait(
controllerID,
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
payload
).map((res)->{
return Net.sendAndAwait(controllerID, SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO, payload).map((res) -> {
switch (res) {
case Success(pkg):
return Success(pkg.data.success);
case Failure(error):
return Failure(error);
}
});
}
public static function unregister(name:String, controllerID:NetworkID = -1):Promise<Noise> {
if (controllerID == -1) controllerID = KernelSettings.siteController;
if (controllerID == -1)
controllerID = KernelSettings.siteController;
var payload:UnregisterRequest = {name: name, type: "unregister"};
return Net.sendAndAwait(
controllerID,
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
payload
);
return Net.sendAndAwait(controllerID, SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO, payload);
}
public static function list(controllerID:NetworkID = -1):Promise<Array<String>> {
if (controllerID == -1) controllerID = KernelSettings.siteController;
if (controllerID == -1)
controllerID = KernelSettings.siteController;
var payload:ListRequest = {type: "list"};
return Net.sendAndAwait(
controllerID,
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
payload
).map(res->{
return Net.sendAndAwait(controllerID, SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO, payload).map(res -> {
switch (res) {
case Success(pkg):
return Success(pkg.data);

View File

@ -23,6 +23,5 @@ class Import {
return Failure(error);
}
});
}
}

View File

@ -16,7 +16,6 @@ class Request {
this.operation = operation;
}
/**
Example:
"myfield[2]@myid"

View File

@ -7,7 +7,6 @@ import kernel.turtle.Turtle;
using tink.CoreApi;
class TurtleExecuter {
private var instructions:Array<TurtleInstruction>;
public function new(instructions:Array<TurtleInstruction>) {

View File

@ -67,13 +67,11 @@ class TurtleExt {
var inv = getInventory(t);
// For each item in the inventory
for (k1 => v1 in inv) {
if (v1.free == 0 || v1.count == 0) {
continue;
}
for (k2 => v2 in inv) {
if (k2 == k1) {
continue;
}
@ -88,11 +86,7 @@ class TurtleExt {
break;
}
}
}
}
}
}

View File

@ -3,7 +3,6 @@ package lib.turtle;
// Check usage of NativeStringTools
// here https://api.haxe.org/lua/NativeStringTools.html
// and here http://lua-users.org/wiki/StringLibraryTutorial
import kernel.turtle.Types.TurtleSlot;
import kernel.turtle.Turtle;
import lua.NativeStringTools;
@ -14,10 +13,7 @@ using tink.CoreApi;
Save a set of turtle instructions to a string and execute them.
**/
class TurtleInstructionParser {
public function new() {
}
public function new() {}
public function encode(instructions:Array<TurtleInstruction>):String {
var s = "";
@ -108,18 +104,7 @@ class TurtleInstructionParser {
}
private var cmdMap:Map<String, TurtleInstruction> = [
"a" => Forward,
"b" => Back,
"c" => TurnLeft,
"d" => TurnRight,
"e" => Up,
"f" => Down,
"g" => Dig(Front),
"h" => Dig(Up),
"i" => Dig(Down),
"j" => Place(Front),
"k" => Place(Up),
"l" => Place(Down),
"a" => Forward, "b" => Back, "c" => TurnLeft, "d" => TurnRight, "e" => Up, "f" => Down, "g" => Dig(Front), "h" => Dig(Up), "i" => Dig(Down),
"j" => Place(Front), "k" => Place(Up), "l" => Place(Down),
];
}

View File

@ -191,7 +191,6 @@ class CanvasKeyValueIterator {
this.index = this.nextIndex;
this.nextIndex = nextValidPixel();
return rtn;
}
}

View File

@ -2,11 +2,10 @@ package macros;
import haxe.macro.Context;
import haxe.macro.Expr;
using Lambda;
class DCEHack {
public static final classes:Array<haxe.macro.Type> = [];
macro static public function dceInclude():Array<Field> {

View File

@ -2,6 +2,7 @@ package macros;
import haxe.macro.Context;
import haxe.macro.Expr;
using Lambda;
class Exporter {
@ -11,7 +12,8 @@ class Exporter {
var getExp = [];
for (field in fields) {
if (field.meta == null) continue;
if (field.meta == null)
continue;
var s = "";
for (meta in field.meta) {
@ -25,7 +27,8 @@ class Exporter {
}
}
if (s == "") continue;
if (s == "")
continue;
switch (field.kind) {
case FFun(f):
@ -74,4 +77,3 @@ class Exporter {
return fields;
}
}

View File

@ -2,6 +2,7 @@ package macros.rpc;
import haxe.macro.Context;
import haxe.macro.Expr;
using Lambda;
class RPC {
@ -17,8 +18,10 @@ class RPC {
}
for (field in fields) {
if (field.meta == null) continue;
if (field.meta.exists((i) -> i.name == "rpc") == false) continue;
if (field.meta == null)
continue;
if (field.meta.exists((i) -> i.name == "rpc") == false)
continue;
switch (field.kind) {
case FFun(f):
@ -53,8 +56,10 @@ class RPC {
var fields = Context.getLocalClass().get().fields.get();
for (field in fields) {
if (field.meta == null) continue;
if (!field.meta.has("rpc")) continue;
if (field.meta == null)
continue;
if (!field.meta.has("rpc"))
continue;
switch (field.kind) {
case FMethod(k):

View File

@ -7,7 +7,9 @@ using tink.CoreApi;
abstract class RPCBase {
public final id:NetworkID;
private final _proto:String;
public function new(id:NetworkID, proto:String) {
this.id = id;
this._proto = proto;