~starkingdoms/starkingdoms

ref: 314f853748aebff9fd637ad97fb0d46d0e19f25e starkingdoms/kabel_test/test/runtime/turbo_oop.kab -rw-r--r-- 708 bytes
314f8537 — ghostly_zsh move kabel_test over 1 year, 4 months ago
                                                                                
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
// modules.select(type, group ...)
//
// select all super thrusters that are in both the 'forward' and 
// 'lowpoweronly' user-defined groups
//
// 'forward' and 'lowpoweronly' are vecs of modules that have 
// been tagged in the ship editor as such

function sleep(h) {}

var lp_forwards = modules.select(modules.types.SuperThruster, "forward", "lowpoweronly");
var sensors = modules.select(modules.types.ShipProximitySensor);

loop { 
  // yes, i think we need 'loop' - while True 
  // may confuse beginners

  sleep(1); // 1 second
  
  // if something is less than 15u away,
  if (sensors.read() < 15) { 
    lp_forwards.activate();
  } else {
    lp_forwards.off(); // alias of Module.deactivate
  }
}