adabots_1.8.1_d1ac6d8b/src/adabots.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Finalization;
with Adabots_Lua_Dispatcher;
with Adabots_Nodetypes;

package Adabots is

   type Turtle is new Ada.Finalization.Limited_Controlled with private;
   type Turtle_Inventory_Slot is range 1 .. 16;
   type Stack_Count is range 0 .. 64;
   type Positive_Stack_Count is range 1 .. 64;
   type Item_Detail is record
      Count : Stack_Count;
      Name  : Ada.Strings.Unbounded.Unbounded_String;
   end record;
   type Tool_Uses_Count is range 0 .. 4000;
   type Tool_Info is record
      Remaining_Uses : Tool_Uses_Count;
      Name  : Ada.Strings.Unbounded.Unbounded_String;
   end record;

   function Create_Dispatcher (Bot_Name : String) return Adabots_Lua_Dispatcher.Lua_Dispatcher;

   function Create_Turtle return Turtle;
   function Create_Turtle (Bot_Name : String) return Turtle;

   -- Movement
   procedure Turn_Right (T : Turtle);
   procedure Turn_Left (T : Turtle);

   function Forward (T : Turtle) return Boolean;
   function Back (T : Turtle) return Boolean;
   function Up (T : Turtle) return Boolean;
   function Down (T : Turtle) return Boolean;

   -- Digging
   function Dig_Down (T : Turtle) return Boolean;
   function Dig_Up (T : Turtle) return Boolean;
   function Dig (T : Turtle) return Boolean;

   -- Placing
   function Place (T : Turtle) return Boolean;
   function Place_Down (T : Turtle) return Boolean;
   function Place_Up (T : Turtle) return Boolean;

   -- Inventory management
   procedure Select_Slot (T : Turtle; Slot : Turtle_Inventory_Slot);
   function Get_Item_Count (T : Turtle; Slot : Turtle_Inventory_Slot) return Stack_Count;
   function Get_Selected_Slot (T : Turtle) return Turtle_Inventory_Slot;
   function Get_Item_Detail (T : Turtle) return Item_Detail;
   function Get_Item_Detail (T : Turtle; Slot : Turtle_Inventory_Slot) return Item_Detail;
   function Get_Current_Tool (T : Turtle) return Tool_Info;

   --  https://tweaked.cc/module/turtle.html#v:drop
   function Drop (T : Turtle; Amount : Stack_Count := 64) return Boolean;
   --  function DropUp (T : Turtle; Amount : Stack_Count := 64) return Boolean;
   --  function DropDown (T : Turtle; Amount : Stack_Count := 64) return Boolean;

   function Detect (T : Turtle) return Boolean;
   function Detect_Down (T : Turtle) return Boolean;
   function Detect_Up (T : Turtle) return Boolean;
   function Detect_Left (T : Turtle) return Boolean;
   function Detect_Right (T : Turtle) return Boolean;

   function Inspect (T : Turtle) return Adabots_Nodetypes.Node;
   function Inspect_Down (T : Turtle) return Adabots_Nodetypes.Node;
   function Inspect_Up (T : Turtle) return Adabots_Nodetypes.Node;

   function Suck (T : Turtle; Amount : Stack_Count := 64) return Boolean;
   function Suck_Down (T : Turtle; Amount : Stack_Count := 64) return Boolean;
   function Suck_Up (T : Turtle; Amount : Stack_Count := 64) return Boolean;

   --  these procedures assert that the function of the same name returned true

   procedure Forward (T : Turtle);
   procedure Back (T : Turtle);
   procedure Up (T : Turtle);
   procedure Down (T : Turtle);

   procedure Dig_Down (T : Turtle);
   procedure Dig_Up (T : Turtle);
   procedure Dig (T : Turtle);

   procedure Place (T : Turtle);
   procedure Place_Down (T : Turtle);
   procedure Place_Up (T : Turtle);

   function Craft (T : Turtle; Amount : Positive_Stack_Count := 1) return Boolean;
   procedure Craft (T : Turtle; Amount : Positive_Stack_Count := 1);

   procedure Drop (T : Turtle; Amount : Stack_Count := 64);

   --   these procedures don't care what the result is

   procedure Maybe_Dig_Down (T : Turtle);
   procedure Maybe_Dig_Up (T : Turtle);
   procedure Maybe_Dig (T : Turtle);
   procedure Maybe_Place (T : Turtle);
   procedure Maybe_Place_Down (T : Turtle);
   procedure Maybe_Place_Up (T : Turtle);

   procedure Suck (T : Turtle; Amount : Stack_Count := 64);
   procedure Suck_Down (T : Turtle; Amount : Stack_Count := 64);
   procedure Suck_Up (T : Turtle; Amount : Stack_Count := 64);

   type Command_Computer is new Ada.Finalization.Limited_Controlled with private;

   function Create_Command_Computer return Command_Computer;
   function Create_Command_Computer (Bot_Name : String) return Command_Computer;

   type Material is
      (Grass,
      Planks,
      Air,
      Glass,
      Ice,
      Gold_Block,
      Sand,
      Bedrock,
      Stone);

   type Relative_Location is record
      X_Offset : Integer := 0;
      Y_Offset : Integer := 0;
      Z_Offset : Integer := 0;
   end record;

   function Image (P : Relative_Location) return String is
      (P.X_Offset'Image & ", " & P.Y_Offset'Image & ", " & P.Z_Offset'Image);

   function "+" (A, B : Relative_Location) return Relative_Location;
   function "-" (A, B : Relative_Location) return Relative_Location;

   type Absolute_Location is record
      X : Integer := 0;
      Y : Integer := 0;
      Z : Integer := 0;
   end record;

   function "+" (A, B : Absolute_Location) return Absolute_Location;

   function "+" (A : Absolute_Location; B : Relative_Location) return Absolute_Location;

   function Set_Block (C : Command_Computer; L : Relative_Location; B : Material) return Boolean;

   procedure Maybe_Set_Block (C : Command_Computer; L : Relative_Location; B : Material);

   procedure Set_Cube
      (C : Command_Computer; First : Relative_Location; Last : Relative_Location; B : Material);

   function Get_Block_Info (C : Command_Computer; L : Absolute_Location) return Material;

private

   type Turtle is new Ada.Finalization.Limited_Controlled with record
      Dispatcher : Adabots_Lua_Dispatcher.Lua_Dispatcher;
   end record;

   function Parse_Item_Details (Table : String) return Item_Detail;
   function Parse_Tool_Selection (Table : String) return Tool_Info;

   type Command_Computer is new Ada.Finalization.Limited_Controlled with record
      Dispatcher : Adabots_Lua_Dispatcher.Lua_Dispatcher;
   end record;

end Adabots;