~starkingdoms/starkingdoms

ref: 0216bf5e52ce141f5a1f5eaaf3e699eb07fed0b1 starkingdoms/kabel/test/runtime/turbo_oop.kab -rw-r--r-- 708 bytes
0216bf5e — ghostly_zsh fix issue with not ppopping to clear stack with an expression statement 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
  }
}