-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathabilities.lua
More file actions
834 lines (766 loc) · 20.8 KB
/
abilities.lua
File metadata and controls
834 lines (766 loc) · 20.8 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
local api = robot.internal_api
local S = api.translator
core.register_craftitem(api.config.god_item, {
description = "God Ability",
inventory_image = 'robot_god_ability_item.png',
groups = {
not_in_creative_inventory = 1
}
})
local directionParamValues = {
front = function (nodeinfo)
return {
direction = nodeinfo.direction(),
frontpos = nodeinfo.front(),
}
end,
up = function (nodeinfo)
local ns = nodeinfo.robot_set()
return {
direction = {x=0,y=1,z=0},
frontpos = vector.add(ns[1].pos(), {x=0,y=1,z=0})
}
end,
down = function (nodeinfo)
local ns = nodeinfo.robot_set()
return {
direction = {x=0,y=-1,z=0},
frontpos = vector.add(ns[#ns].pos(), {x=0,y=-1,z=0})
}
end,
['up-front'] = function (nodeinfo)
local ns = nodeinfo.robot_set()
local direction = vector.add({x=0,y=1,z=0}, nodeinfo.direction())
return {
direction = direction,
frontpos = vector.add(ns[1].pos(), direction),
}
end,
['down-front'] = function (nodeinfo)
local ns = nodeinfo.robot_set()
local direction = vector.add({x=0,y=-1,z=0}, nodeinfo.direction())
return {
direction = direction,
frontpos = vector.add(ns[#ns].pos(), direction)
}
end,
}
local parseDirectionParam = function (nodeinfo, dir, def)
if not dir then dir = def or 'front' end
if type(dir) ~= 'string' then
error('looking dir must be a string', 2)
return
end
if not directionParamValues[dir] then
error(("direction '%s' is invalid"):format(dir), 2)
return
end
return directionParamValues[dir](nodeinfo)
end
-- [[ Turn ]]
robot.add_ability({
ability = 'turn',
item = function()
if core.get_modpath('rhotator') then
return 'rhotator:screwdriver'
elseif core.get_modpath('screwdriver') then
return 'screwdriver:screwdriver'
end
return "default:acacia_bush_leaves"
end,
description = S("Rotate the robot 90 degrees"),
command_example = "robot.turn(<anticlockwise true | false/nil>)",
done_by = { head = true, legs = true },
act_on = 'all',
depends_on = 'any',
action = function (nodeinfo, _part, anticlockwise)
local ns = nodeinfo.robot_set()
for _, n in ipairs(ns) do
local node = n.node()
n.set_node({
param2 = anticlockwise
and (node.param2-1)%4
or (node.param2+1)%4
})
end
end
})
-- [[ Move ]]
robot.add_ability({
ability = 'move',
item = function ()
if core.get_modpath('carts') then
return "carts:cart"
end
return "default:acacia_bush_sapling"
end,
description = S("Move one block forwards"),
done_by = { head = true, legs = true },
act_on = 'all',
depends_on = 'any',
action = function (nodeinfo, _part)
local ns = nodeinfo.robot_set()
local meta = nodeinfo.meta()
local owner = meta:get_string('player_name')
local above = vector.add(ns[1].pos(), {x=0, y=1, z=0})
if api.any_has_ability(nodeinfo, 'push') then
-- ### Step 1: Push nodes in front ###
local moved = false
for _,n in ipairs(ns) do
local new_pos = n.front()
local success, stack, oldstack = mesecon.mvps_push(new_pos, n.direction(), api.config.max_push, owner)
if not success then
if moved then
core.check_for_falling(n.pos())
core.check_for_falling(above)
end
if stack == "protected" then
error("protected area in the way", 2)
return
end
error("blocked", 2)
return
end
mesecon.mvps_move_objects(new_pos, n.direction(), oldstack)
api.move_robot(n, new_pos)
moved = true
end
-- ### Step 4: Let things fall ###
if moved then
core.check_for_falling(ns[#ns].pos())
core.check_for_falling(above)
end
else
local can_move = true
for _,n in ipairs(ns) do
local frontpos = n.front()
if core.is_protected(frontpos, owner) then
error("protected area in the way", 2)
return
end
if not api.can_move_to(frontpos) then
can_move = false
break
end
end
if not can_move then
error("blocked", 2)
return
end
-- ### Step 2: Move the movestone ###
for _,n in ipairs(ns) do
local new_pos = n.front()
api.move_robot(n, new_pos)
end
-- ### Step 4: Let things fall ###
core.check_for_falling(ns[#ns].pos())
core.check_for_falling(above)
end
end
})
-- [[ Climb ]]
robot.add_ability({
ability = 'climb',
item = function ()
if core.get_modpath('mesecons_pistons') then
return 'mesecons_pistons:piston_normal_off'
end
return "default:acacia_bush_stem"
end,
description = S("Climb up and forwards one block"),
done_by = { head = true, legs = true },
act_on = 'all',
depends_on = 'any',
action = function (nodeinfo, _part)
local ns = nodeinfo.robot_set()
local lastinfo = ns[#ns]
local meta = nodeinfo.meta()
local owner = meta:get_string('player_name')
for _, n in ipairs(ns) do
local uppos = vector.add(n.front(), {x=0,y=1,z=0})
if core.is_protected(uppos, owner) then
error("protected area in the way", 2)
return
elseif not api.can_move_to(uppos) then
error("blocked", 2)
return
end
end
local under_node = core.get_node(lastinfo.front())
local under_node_def = core.registered_nodes[under_node.name]
if not under_node_def.walkable then
error("no support", 2)
return
end
-- TODO: ray trace to make sure the hitbox isn't blocking?
for _, n in ipairs(ns) do
n.set_pos(vector.add(n.front(), {x=0,y=1,z=0}))
end
end
})
-- [[ Look ]]
robot.add_ability({
ability = "look",
item = function ()
if core.get_modpath('mesecons_detector') then
return 'mesecons_detector:node_detector_off'
elseif core.get_modpath('binoculars') then
return "binoculars:binoculars"
end
return "default:acacia_leaves"
end,
description = S("Get the name of the node in front of the robot"),
command_example = "node_name = robot.look(<dir 'up' | 'front'/nil | 'down' | 'up-front' | 'down-front'>)",
done_by = { head = true },
act_on = 'first',
depends_on = 'self',
action = function (nodeinfo, part, dir)
local hasability = api.any_has_ability(nodeinfo, 'look')
if not hasability then return end
local actorinfo = hasability
if part then
actorinfo = nodeinfo.parts()[part] or hasability
end
local dirPos = parseDirectionParam(actorinfo, dir, 'front')
return core.get_node(dirPos.frontpos).name
end,
runtime_unique = function (part, dir)
return part..dir
end,
runtime = true
})
-- [[ Locate ]]
robot.add_ability({
ability = "locate",
item = function ()
if core.get_modpath('orienteering') then
return 'orienteering:gps'
elseif core.get_modpath('map') then
return 'map:mapping_kit'
end
return "default:acacia_sapling"
end,
act_on = 'last',
depends_on = 'any',
description = S("Get the position of the robot"),
command_example = "node_pos = robot.locate()",
done_by = { head = true },
action = function (nodeinfo, part)
local hasability = api.any_has_ability(nodeinfo, 'locate')
if not hasability then return end
local actorinfo = hasability
if part then
actorinfo = nodeinfo.parts()[part] or hasability
end
local pos = actorinfo.pos()
return {
x = pos.x,
y = pos.y,
z = pos.z,
}
end,
runtime = true
})
-- [[ Speak ]]
robot.add_ability({
ability = "speak",
item = function ()
if core.get_modpath('homedecor') then
return 'homedecor:speaker_driver'
end
return "default:pine_sapling"
end,
act_on = 'last',
depends_on = 'any',
description = S("Send chat messages to the owner"),
command_example = "robot.speak('Hello!')",
done_by = { head = true },
action = function (nodeinfo, part, message)
local hasability = api.any_has_ability(nodeinfo, 'speak')
if not hasability then return end
local meta = nodeinfo.meta()
local owner = meta:get_string('player_name')
core.chat_send_player(owner, "[robot] "..message)
return nil
end,
runtime = true
})
local function is_default_method(obj, key)
local method = obj[key]
return (key == 'on_place' and method == core.item_place)
or core.noneitemdef_default[key] == method
or core.tooldef_default[key] == method
or core.craftitemdef_default[key] == method
or core.nodedef_default[key] == method
end
-- [[ Place ]]
robot.add_ability({
ability = 'place',
disabled = not core.get_modpath('dispenser'),
item = 'dispenser:dispenser',
act_on = 'first',
depends_on = 'self',
description = S("Place a block down"),
command_example = "robot.place(<dir 'up' | 'front'/nil | 'down' | 'up-front' | 'down-front'>)",
done_by = { head = true, body = true },
action = function (nodeinfo, part, dir)
local hasability = api.any_has_ability(nodeinfo, 'place')
if not hasability then return end
local actorinfo = hasability
if part then
actorinfo = nodeinfo.parts()[part] or hasability
end
local dirPos = parseDirectionParam(actorinfo, dir, 'front')
local direction = dirPos.direction
local frontpos = dirPos.frontpos
if dir == 'down' then
if not api.any_has_ability(nodeinfo, 'climb') then
error('requires climb ability to place block below', 2)
return
end
frontpos = vector.add(dirPos.frontpos, {x=0,y=1,z=0})
end
local meta = actorinfo.meta()
local owner = meta:get_string('player_name')
if core.is_protected(frontpos, owner) then
error("protected area in the way", 2)
return
end
local ns = nodeinfo.robot_set()
local ordered_set = {}
for _,n in ipairs(ns) do
if n.info().part == part then
table.insert(ordered_set, 1, n)
else
table.insert(ordered_set, n)
end
end
local inv_info
local next_index
local next_stack
local item_name
local def
local empty = true
for _,n in ipairs(ordered_set) do
local list = n.inv():get_list('main')
for index, stack in ipairs(list) do
if not stack:is_empty() then
next_index = index
next_stack = stack
item_name = next_stack:get_name()
def = core.registered_items[item_name]
empty = false
if def and def.on_place and (def.type == 'node' or not is_default_method(def, 'on_place')) then
inv_info = n
break
end
end
end
if inv_info then break end
end
if empty then
error("inventory empty", 2)
return
end
if not inv_info then
error("no placable item", 2)
return
end
local player_opts = {
front = frontpos,
dir = direction,
index = next_index
}
local fuel_used
if dir == 'down' then
for i, n in ipairs(ns) do
local uppos = vector.add(n.pos(), {x=0,y=1,z=0})
if core.is_protected(uppos, owner) then
error("protected area in the way", 2)
return
elseif i == 1 and not api.can_move_to(uppos) then
error("blocked", 2)
return
end
end
for _, n in ipairs(ns) do
local uppos = vector.add(n.pos(), {x=0,y=1,z=0})
api.move_robot(n, uppos)
end
fuel_used = 2
end
player_opts.pos = actorinfo.pos()
player_opts.meta = inv_info.meta()
next_stack = inv_info.inv():get_stack('main', next_index)
local player = dispenser.actions.fake_player(next_stack, player_opts)
if not player then
error("player not logged in", 2)
return
end
local result = def.on_place(next_stack, player, {
type="node",
under=frontpos,
above=frontpos
})
core.check_for_falling(frontpos)
if result then
inv_info.inv():set_stack('main', next_index, result)
end
return nil, fuel_used
end
})
-- [[ Use ]]
robot.add_ability({
ability = 'use',
disabled = not core.get_modpath('dispenser'),
item = function ()
if core.get_modpath('bones') then
return "bones:bones"
end
return "default:acacia_tree"
end,
act_on = 'first',
depends_on = 'self',
description = S("Use an item (not a tool)"),
command_example = "robot.use(<dir 'up' | 'front'/nil | 'down' | 'up-front' | 'down-front'>)",
done_by = { head = true, body = true },
action = function (nodeinfo, part, dir)
local hasability = api.any_has_ability(nodeinfo, 'use')
if not hasability then return end
local actorinfo = hasability
if part then
actorinfo = nodeinfo.parts()[part] or hasability
end
local dirPos = parseDirectionParam(actorinfo, dir, 'front')
local ordered_set = {}
for _,n in ipairs(nodeinfo.robot_set()) do
if n.info().part == part then
table.insert(ordered_set, 1, n)
else
table.insert(ordered_set, n)
end
end
local inv_info
local next_stack
local next_index
local item_name
local def
local empty = true
for _,n in ipairs(ordered_set) do
local node_inv = n.inv()
local list = node_inv:get_list('main')
for index,stack in ipairs(list) do
if not stack:is_empty() then
next_stack = stack
next_index = index
item_name = next_stack:get_name()
def = core.registered_items[item_name]
empty = false
if def and def.on_use then
inv_info = n
break
end
end
end
if inv_info then break end
end
if empty then
error("inventory empty", 2)
return
end
if not inv_info then
error("no usable item", 2)
return
end
local player = dispenser.actions.fake_player(next_stack, {
front = dirPos.frontpos,
dir = dirPos.direction,
pos = actorinfo.pos(),
meta = inv_info.meta(),
index = next_index
})
if not player then
error("player not logged in", 2)
return
end
local result = def.on_use(next_stack, player, {
type="node",
under=dirPos.frontpos,
above=vector.add(dirPos.frontpos, {x=0,y=1,z=0})
})
if result then
inv_info.inv():set_stack('main', next_index, result)
end
end
})
-- [[ Switch ]]
robot.add_ability({
ability = 'switch',
disabled = not core.get_modpath('tubelib'),
item = function ()
if core.get_modpath('tubelib') then
return 'tubelib:button'
end
return "default:acacia_wood"
end,
act_on = 'first',
depends_on = 'self',
description = S("Switch a tubelib machine on and off"),
command_example = "robot.switch(<mode 'on' | 'off' | 'toggle'/nil>, <dir 'up' | 'front'/nil | 'down' | 'up-front' | 'down-front'>)",
done_by = { head = true, body = true },
action = function (nodeinfo, part, mode, dir)
local hasability = api.any_has_ability(nodeinfo, 'switch')
if not hasability then return end
local actorinfo = hasability
if part then
actorinfo = nodeinfo.parts()[part] or hasability
end
local dirPos = parseDirectionParam(actorinfo, dir, 'front')
local tube_meta = core.get_meta(dirPos.frontpos)
local state = tube_meta:get_int("tubelib_state")
if not state then return end
local on_or_off = ((mode == "on" or mode == "off") and mode)
or (state == tubelib.STOPPED and "on" or "off")
local number = tubelib.get_node_number(dirPos.frontpos)
if not number or number == "" then return end
local meta = actorinfo.meta()
local owner = meta:get_string('player_name')
tubelib.send_message(number, owner, nil, on_or_off, nil)
end
})
-- [[ Push ]]
robot.add_ability({
ability = 'push',
disabled = not core.get_modpath('mesecons_mvps'),
item = function ()
if core.get_modpath('mesecons_movestones') then
return "mesecons_movestones:movestone"
end
return "default:apple"
end,
act_on = 'all',
depends_on = 'any',
done_by = { legs = true, body = true },
description = S("Push a block when moving forwards")
})
-- [[ Carry ]]
robot.add_ability({
ability = 'carry',
item = function ()
if core.get_modpath('unified_inventory') then
return 'unified_inventory:bag_large'
elseif core.get_modpath('default') then
return 'default:chest'
end
return "default:aspen_leaves"
end,
act_on = 'self',
depends_on = 'self',
description = S("Expand the item inventory"),
done_by = { legs = true, body = true },
updates_formspec = true,
modifier = function(nodeinfo, player_name)
local info = nodeinfo.info()
local inv = nodeinfo.inv()
local new_size = api.tier(info.tier).form_size*2
if api.has_ability(nodeinfo, 'fuel_swap') then
new_size = new_size - 4
inv:set_size('fuel', inv:get_size('fuel') + 3)
end
inv:set_size('main', new_size)
end,
un_modifier = function(nodeinfo, player_name)
local info = nodeinfo.info()
local inv = nodeinfo.inv()
local new_size = api.tier(info.tier).inventory_size
if api.has_ability(nodeinfo, 'fuel_swap') then
new_size = new_size - 1
local new_fuel_size = inv:get_size('fuel') - 3
local fuel_list = inv:get_list('fuel')
for i,stack in ipairs(fuel_list) do
if i > new_fuel_size then
core.add_item(vector.add(nodeinfo.pos(), {x=0,y=0.5,z=0}), stack)
end
end
inv:set_size('fuel', new_fuel_size)
end
-- Spit out any extra items
local list = inv:get_list('main')
for i,stack in ipairs(list) do
if i > new_size then
core.add_item(vector.add(nodeinfo.pos(), {x=0,y=0.5,z=0}), stack)
end
end
inv:set_size('main', new_size)
end,
})
-- [[ Fuel ]]
robot.add_ability({
ability = 'fuel',
item = function ()
if core.get_modpath('unified_inventory') then
return 'unified_inventory:bag_small'
elseif core.get_modpath('default') then
return 'default:furnace'
end
return "default:aspen_sapling"
end,
act_on = 'self',
depends_on = 'self',
description = S("Expand the fuel inventory"),
done_by = { head = true, legs = true, body = true },
updates_formspec = true,
modifier = function(nodeinfo, player_name)
local inv = nodeinfo.inv()
inv:set_size('fuel', inv:get_size('fuel')+3)
end,
un_modifier = function(nodeinfo, player_name)
local inv = nodeinfo.inv()
-- Spit out any extra items
local list = inv:get_list('fuel')
local new_size = inv:get_size('fuel')-3
for i,stack in ipairs(list) do
if i > new_size then
core.add_item(vector.add(nodeinfo.pos(), {x=0,y=0.5,z=0}), stack)
end
end
inv:set_size('fuel', new_size)
end,
})
-- [[ Fill ]]
robot.add_ability({
ability = 'fill',
disabled = not core.get_modpath('tubelib'),
item = function ()
if core.get_modpath('tubelib') then
return 'tubelib:tubeS'
end
return "default:aspen_tree"
end,
act_on = 'self',
depends_on = 'self',
done_by = { legs = true, body = true },
description = S("Fill and empty the inventory using pushers"),
})
-- [[ Speed ]]
robot.add_ability({
ability = 'speed',
item = function ()
if core.get_modpath('terumet') then
return 'terumet:item_upg_speed_up'
elseif core.get_modpath('carts') then
return 'carts:powerrail'
end
return "default:aspen_wood"
end,
act_on = 'all',
depends_on = 'any',
description = S("Make the robot run twice as fast"),
done_by = { legs = true },
modifier = function (nodeinfo)
if not nodeinfo.speed_enabled() then
nodeinfo.meta():set_int('robot_speed', 1)
end
end,
un_modifier = function (nodeinfo)
if nodeinfo.speed_enabled() then
nodeinfo.meta():set_int('robot_speed', 0)
end
end
})
-- [[ Connectivity ]]
robot.add_ability({
ability = 'connectivity',
item = function ()
if core.get_modpath('digistuff') then
return "digistuff:insulated_straight"
end
return "default:obsidian_glass"
end,
act_on = 'self',
depends_on = 'self',
description = S("Connect to robot parts above"),
done_by = { legs = true, body = true },
updates_formspec = true,
modifier = function (nodeinfo)
api.correct_connection(nodeinfo)
end,
un_modifier = function (nodeinfo)
api.correct_connection(nodeinfo)
end,
})
-- [[ Fuel Swap ]]
robot.add_ability({
interface_enabled = true,
ability = "fuel_swap",
item = function ()
if core.get_modpath('replacer') then
return "replacer:replacer"
end
return "default:blueberries"
end,
act_on = 'self',
depends_on = 'self',
description = S("Swap some normal inventory for fuel inventory"),
done_by = { legs = true, body = true, head = true },
updates_formspec = true,
modifier = function(nodeinfo, player_name)
local inv = nodeinfo.inv()
local size_change = 1
if api.has_ability(nodeinfo, 'carry') then
size_change = size_change + 3
end
inv:set_size('fuel', inv:get_size('fuel')+size_change)
-- Spit out any extra items
local list = inv:get_list('main')
local new_size = inv:get_size('main')-size_change
for i,stack in ipairs(list) do
if i > new_size then
core.add_item(vector.add(nodeinfo.pos(), {x=0,y=0.5,z=0}), stack)
end
end
inv:set_size('main', new_size)
end,
un_modifier = function(nodeinfo, player_name)
local inv = nodeinfo.inv()
local size_change = 1
if api.has_ability(nodeinfo, 'carry') then
size_change = size_change + 3
end
inv:set_size('main', inv:get_size('main')+size_change)
-- Spit out any extra items
local list = inv:get_list('fuel')
local new_size = inv:get_size('fuel')-size_change
for i,stack in ipairs(list) do
if i > new_size then
core.add_item(vector.add(nodeinfo.pos(), {x=0,y=0.5,z=0}), stack)
end
end
inv:set_size('fuel', new_size)
end,
})
-- [[ Boost ]]
robot.add_ability({
interface_enabled = true,
ability = "boost",
item = function ()
if core.get_modpath('orienteering') then
return "orienteering:speedometer"
end
return "default:blueberry_bush_leaves"
end,
act_on = 'all',
depends_on = 'any',
description = S("Speed up but use more fuel randomly"),
done_by = { legs = true, body = true, head = true },
modifier = function (nodeinfo)
if not nodeinfo.boost_enabled() then
nodeinfo.meta():set_int('robot_boost', 1)
end
end,
un_modifier = function (nodeinfo)
if nodeinfo.boost_enabled() then
nodeinfo.meta():set_int('robot_boost', 0)
end
end
})