From 96c65958468c8c6f32100583309c7f229a696305 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Tue, 12 Apr 2022 01:02:04 +0200 Subject: [PATCH] make turtle slot 0 based in kernel --- src/kernel/turtle/Turtle.hx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/kernel/turtle/Turtle.hx b/src/kernel/turtle/Turtle.hx index be1e6f3..ae8d34a 100644 --- a/src/kernel/turtle/Turtle.hx +++ b/src/kernel/turtle/Turtle.hx @@ -6,6 +6,7 @@ using tink.CoreApi; class Turtle { public static var instance:Turtle; + public static var MAX_SLOTS(default, null):Int = 15; @:allow(kernel.Init) private function new() { @@ -109,7 +110,7 @@ class Turtle { public function selectSlot(slot:TurtleSlot):Outcome { // TODO: slot in bounds? - var r = cc.Turtle.select(slot); + var r = cc.Turtle.select(slot + 1); return (r) ? Outcome.Success(null) : Outcome.Failure("Slot out of bounds"); } @@ -117,13 +118,13 @@ class Turtle { public function getItemCount(?slot:TurtleSlot):Int { // TODO: slot in bounds? - return cc.Turtle.getItemCount(slot); + return cc.Turtle.getItemCount(slot + 1); } public function getItemSpace(?slot:TurtleSlot):Int { // TODO: slot in bounds? - return cc.Turtle.getItemSpace(slot); + return cc.Turtle.getItemSpace(slot + 1); } public function detect(dir:InteractDirections):Bool { @@ -196,16 +197,16 @@ class Turtle { } public function compareSlot(otherSlot:TurtleSlot):Bool { - return cc.Turtle.compareTo(otherSlot); + return cc.Turtle.compareTo(otherSlot + 1); } public function transferToSlot(to:TurtleSlot, ?count:Int):Outcome { - var r = cc.Turtle.transferTo(to, count); + var r = cc.Turtle.transferTo(to + 1, count); return r ? Outcome.Success(null) : Outcome.Failure(null); } public function getSelectedSlot():TurtleSlot { - return cc.Turtle.getSelectedSlot(); + return cc.Turtle.getSelectedSlot() - 1; } public function getFuelLimit():Int { @@ -245,7 +246,7 @@ class Turtle { } public function getItemDetail(?detailed:Bool = false, ?slot:TurtleSlot):Option { - var r = cc.Turtle.getItemDetail(slot); // FIXME: can take detailed as flag. Has to be fixed upstream + var r = cc.Turtle.getItemDetail(slot + 1); // FIXME: can take detailed as flag. Has to be fixed upstream if (r == null) { return None;