Skip to content

Releases: untoldwind/KontrolSystem2

v0.5.9.5

13 Jun 14:33
2b69b83
Compare
Choose a tag to compare
  • Make vessel.name read-write
  • Add experiment.potential_science_value()
  • Add .visible to field to UI elements
  • Recompile vs 0.2.2.0

v0.5.9.4

13 Jun 13:12
4baffe3
Compare
Choose a tag to compare
v0.5.9.4 Pre-release
Pre-release
  • Recompile to 0.2.2

v0.5.9.3

30 May 06:14
4baffe3
Compare
Choose a tag to compare
v0.5.9.3 Pre-release
Pre-release
  • Add .visible to field to UI elements

v0.5.9.2

11 May 11:28
4baffe3
Compare
Choose a tag to compare
v0.5.9.2 Pre-release
Pre-release
  • Make vessel.name read-write
  • Add experiment.potential_science_value()

v0.5.9.1

05 May 07:27
908bf8a
Compare
Choose a tag to compare

Support for operator overloading.

  • structs can now have an additional impl operators for <struct-name> sections. Functions defined in that section will server as operators for that struct
  • The following operator-functions are supported (at the moment):
    • Unary operators (require one argument that has to be the struct-type):
      • neg: The -a operator aka "negate" aka "sign" aka "unary minus"
    • Binary operators (require two arguments, at least one of them has to be the struct type):
      • add: The a + b operator
      • sub: The a - b operator
      • mul: The a * b operator
      • div: The a / b operator
      • mod: The a % b operator
      • pow: The a ** b operator

Example:

pub struct NVector(values: float[]) {
    dim: int = values.length
    values: float[] = values
}

impl NVector {
    sync fn add_scalar(self, scalar: float) -> NVector = NVector(self.values.map(fn(v) -> v + scalar))

    sync fn mul_scalar(self, scalar: float) -> NVector = NVector(self.values.map(fn(v) -> v * scalar))
    
    sync fn to_string(self) -> string = $"NVector({self.dim}, {self.values.to_string()})"
}

impl operators for NVector {
    sync fn neg(right: NVector) -> NVector = NVector(right.values.map(fn(r) -> -r))
    
    sync fn add(left: float, right: NVector) -> NVector = right.add_scalar(left)

    sync fn add(left: NVector, right: float) -> NVector = left.add_scalar(right)
    
    sync fn add(left: NVector, right: NVector) -> NVector = NVector((0..min_dim(left.dim, right.dim)).map(fn(i) -> left.values[i] + right.values[i]))

    sync fn mul(left: float, right: NVector) -> NVector = right.mul_scalar(left)

    sync fn mul(left: NVector, right: float) -> NVector = left.mul_scalar(right)

    sync fn div(left: NVector, right: float) -> NVector = NVector(left.values.map(fn(l) -> l / right))
}

pub sync fn zero_nvector(dim: int) -> NVector = NVector((0..dim).map(fn(i) -> 0.0))

sync fn min_dim(dim1: int, dim2: int) -> int = if(dim1 < dim2) dim1 else dim2

v0.5.9.0

28 Apr 12:10
2b9e9d3
Compare
Choose a tag to compare
v0.5.9.0 Pre-release
Pre-release

Experimental support for operator overloading.

  • structs can now have an additional impl operators for <struct-name> sections. Functions defined in that section will server as operators for that struct
  • The following operator-functions are supported (at the moment):
    • Unary operators (require one argument that has to be the struct-type):
      • neg: The -a operator aka "negate" aka "sign" aka "unary minus"
    • Binary operators (require two arguments, at least one of them has to be the struct type):
      • add: The a + b operator
      • sub: The a - b operator
      • mul: The a * b operator
      • div: The a / b operator
      • mod: The a % b operator
      • pow: The a ** b operator

Example:

pub struct NVector(values: float[]) {
    dim: int = values.length
    values: float[] = values
}

impl NVector {
    sync fn add_scalar(self, scalar: float) -> NVector = NVector(self.values.map(fn(v) -> v + scalar))

    sync fn mul_scalar(self, scalar: float) -> NVector = NVector(self.values.map(fn(v) -> v * scalar))
    
    sync fn to_string(self) -> string = $"NVector({self.dim}, {self.values.to_string()})"
}

impl operators for NVector {
    sync fn neg(right: NVector) -> NVector = NVector(right.values.map(fn(r) -> -r))
    
    sync fn add(left: float, right: NVector) -> NVector = right.add_scalar(left)

    sync fn add(left: NVector, right: float) -> NVector = left.add_scalar(right)
    
    sync fn add(left: NVector, right: NVector) -> NVector = NVector((0..min_dim(left.dim, right.dim)).map(fn(i) -> left.values[i] + right.values[i]))

    sync fn mul(left: float, right: NVector) -> NVector = right.mul_scalar(left)

    sync fn mul(left: NVector, right: float) -> NVector = left.mul_scalar(right)

    sync fn div(left: NVector, right: float) -> NVector = NVector(left.values.map(fn(l) -> l / right))
}

pub sync fn zero_nvector(dim: int) -> NVector = NVector((0..dim).map(fn(i) -> 0.0))

sync fn min_dim(dim1: int, dim2: int) -> int = if(dim1 < dim2) dim1 else dim2

v0.5.8.5

23 Apr 18:02
7f0a852
Compare
Choose a tag to compare
  • Make timeouts configurable (#168)
  • Add string.to_int() and string.to_float() methods

v0.5.8.4

15 Apr 16:04
6d114ca
Compare
Choose a tag to compare
  • Fix type check of field assign using operators +=, -= ... (#114)
  • Add unique id to ksp::vessel::Part (#165)
  • Add read_lines() method to ksp::debug::LogFile (#144)

v0.5.8.3

10 Apr 19:35
7e3996d
Compare
Choose a tag to compare
  • Main feature: Improve ConsoleWindow
    • REPL command field has been removed
    • Instead, console itself now focusable and has a command prompt with history
    • In addition to evaluating expression some basic commands have been added:
      • help, clear, test, reboot, list, start
      • ... will most likely be expanded in the future
  • Add ksp::game::MESSAGE_BUS. Example:
    • Script 1 "test_send.to2":
      use { Vessel } from ksp::vessel
      use { CONSOLE } from ksp::console
      use { MESSAGE_BUS } from ksp::game
      
      pub struct MyMessage(message: string, a_number: int) {
          message: string = message
          a_number: int = a_number
      }
      
      pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
          MESSAGE_BUS.publish(MyMessage("Hello", 1234))
      }
    • Script 2 "test_recv.to2":
      use { Vessel } from ksp::vessel
      use { CONSOLE } from ksp::console
      use { MESSAGE_BUS, wait_until, Subscription } from ksp::game
      use { MyMessage } from test_send
      
      pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
        CONSOLE.clear()
      
        const subscription : Subscription<MyMessage> = MESSAGE_BUS.subscribe()
      
        while(true) {
          // This is still rather clunky, there should be a proper helper for "wait for message"
          wait_until(fn() -> subscription.peek().defined)
          
          // The wait is not really necessary, this can be done in any loop with yield or sleep
          if(Some(message) = subscription.recv()) {
              CONSOLE.print_line($"Recv message: {message.message} {message.a_number}")
          }
        }
      }
    • Added system event:
      • ksp::game::EventProcessStarted
      • ksp::game::EventProcessStopped
  • Add ksp::game::notification_alert and ksp::game::notification_passive. Example:
    use { Vessel } from ksp::vessel
    use { notification_alert, notification_passive, Importance } from ksp::game
    
    pub fn main_flight(vessel: Vessel) -> Result<Unit> = {
      notification_alert("Alert title", "Alert message", Importance.Low, 10)
      notification_passive("Passive message")
    }
    
  • Allow any return value in UI callbacks (#151)
  • Fix REPL if typing (#160)
  • Add try_recover_vessel to ksp::debug::SAVE_LOAD_CONTROL (#152)
  • Add orbit.global_orbit_normal

v0.5.8.2

08 Apr 19:01
704626a
Compare
Choose a tag to compare
v0.5.8.2 Pre-release
Pre-release
  • Add ksp::game::MESSAGE_BUS. Example:
    • Script 1 "test_send.to2":
      use { Vessel } from ksp::vessel
      use { CONSOLE } from ksp::console
      use { MESSAGE_BUS } from ksp::game
      
      pub struct MyMessage(message: string, a_number: int) {
          message: string = message
          a_number: int = a_number
      }
      
      pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
          MESSAGE_BUS.publish(MyMessage("Hello", 1234))
      }
    • Script 2 "test_recv.to2":
      use { Vessel } from ksp::vessel
      use { CONSOLE } from ksp::console
      use { MESSAGE_BUS, wait_until, Subscription } from ksp::game
      use { MyMessage } from test_send
      
      pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
        CONSOLE.clear()
      
        const subscription : Subscription<MyMessage> = MESSAGE_BUS.subscribe()
      
        while(true) {
          // This is still rather clunky, there should be a proper helper for "wait for message"
          wait_until(fn() -> subscription.peek().defined)
          
          // The wait is not really necessary, this can be done in any loop with yield or sleep
          if(Some(message) = subscription.recv()) {
              CONSOLE.print_line($"Recv message: {message.message} {message.a_number}")
          }
        }
      }
    • Added system event:
      • ksp::game::EventProcessStarted
      • ksp::game::EventProcessStopped
  • Add ksp::game::notification_alert and ksp::game::notification_passive. Example:
    use { Vessel } from ksp::vessel
    use { notification_alert, notification_passive, Importance } from ksp::game
    
    pub fn main_flight(vessel: Vessel) -> Result<Unit> = {
      notification_alert("Alert title", "Alert message", Importance.Low, 10)
      notification_passive("Passive message")
    }
    
  • Allow any return value in UI callbacks (#151)
  • Fix REPL if typing (#160)
  • Improve ConsoleWindow
    • REPL command field has been removed
    • Instead console itself now focusable and has a command prompt with history
  • Add try_recover_vessel to ksp::debug::SAVE_LOAD_CONTROL (#152)