@@ -74,6 +74,19 @@ local function createPoints(turtle, distance, areaSize)
74
74
end
75
75
return pointTable
76
76
end
77
+
78
+ local function countblocks (blockName )
79
+ local count = 0
80
+ local lastBlock
81
+ for _ , block in pairs (turtleEmulator .blocks ) do
82
+ if block .item .name == blockName then
83
+ count = count + 1
84
+ lastBlock = block
85
+ end
86
+ end
87
+ return count
88
+ end
89
+
77
90
local function beforeEach ()
78
91
local geoScannerItem = {
79
92
name = " advancedperipherals:geo_scanner" ,
@@ -127,6 +140,7 @@ local function beforeEach()
127
140
end
128
141
129
142
143
+
130
144
describe (" empty World" , function ()
131
145
before_each (function ()
132
146
beforeEach ()
@@ -160,18 +174,10 @@ describe("World with ores", function()
160
174
--- @cast geoScannerPeripheral GeoScanner
161
175
geoScannerPeripheral .scanEmulator = true
162
176
miningClient .scanStartFacingTo = " X"
177
+ assert .are .equal (15 , countblocks (" minecraft:deepslate_iron_ore" ))
163
178
miningClient :main (createPoints (turtle , 2 , 1 ))
164
- local count = 0
165
- local dirt
166
- for _ , block in pairs (turtleEmulator .blocks ) do
167
- if block .item .name == " minecraft:deepslate_iron_ore" then
168
- count = count + 1
169
- elseif block .item .name == " minecraft:dirt" then
170
- dirt = block
171
- else
172
- error (" unknown block found" )
173
- end
174
- end
179
+ local count = countblocks (" minecraft:deepslate_iron_ore" )
180
+ local dirt = countblocks (" minecraft:dirt" )
175
181
assert .are .equal (0 , count )
176
182
assert .are .equal (Vector .new (0 , 0 , 0 ), turtle .position )
177
183
assert .are .equal (Vector .new (1 , 0 , 0 ), turtle .facing )
0 commit comments