From 8339c69eccf27abb5c7e04cdb32624c79f730ac7 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 11 Apr 2022 01:00:23 +0200 Subject: [PATCH] turtle init stuff --- src/kernel/Init.hx | 5 +++++ src/kernel/turtle/Turtle.hx | 11 +++++++++-- src/kernel/turtle/Types.hx | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/kernel/Init.hx b/src/kernel/Init.hx index 53f92d4..fe976aa 100644 --- a/src/kernel/Init.hx +++ b/src/kernel/Init.hx @@ -1,5 +1,6 @@ package kernel; +import kernel.turtle.Turtle; import haxe.MainLoop; import kernel.net.Routing; import cc.OS; @@ -18,6 +19,10 @@ class Init { MainTerm.instance = new MainTerm(); Log.init(); + if (Turtle.isTurtle()){ + Turtle.instance = new Turtle(); + } + Routing.instance = new Routing(); Net.instance = new Net(); diff --git a/src/kernel/turtle/Turtle.hx b/src/kernel/turtle/Turtle.hx index 80f55af..be1e6f3 100644 --- a/src/kernel/turtle/Turtle.hx +++ b/src/kernel/turtle/Turtle.hx @@ -4,9 +4,16 @@ import kernel.turtle.Types; using tink.CoreApi; -typedef TurtleSlot = Int; - class Turtle { + public static var instance:Turtle; + + @:allow(kernel.Init) + private function new() { + if (!Turtle.isTurtle()){ + Log.warn("Tried to initialize Turtle, but it is not available."); + } + } + public static function isTurtle():Bool { return true; // TODO: Implement } diff --git a/src/kernel/turtle/Types.hx b/src/kernel/turtle/Types.hx index 0d80521..928eaea 100644 --- a/src/kernel/turtle/Types.hx +++ b/src/kernel/turtle/Types.hx @@ -22,3 +22,5 @@ typedef ItemInspect = { public var damage:Int; public var count:Int; } + +typedef TurtleSlot = Int;