Releases: untoldwind/KontrolSystem2
Releases · untoldwind/KontrolSystem2
v0.5.9.5
v0.5.9.4
- Recompile to 0.2.2
v0.5.9.3
- Add
.visible
to field to UI elements
v0.5.9.2
- Make
vessel.name
read-write - Add
experiment.potential_science_value()
v0.5.9.1
Support for operator overloading.
structs
can now have an additionalimpl 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
: Thea + b
operatorsub
: Thea - b
operatormul
: Thea * b
operatordiv
: Thea / b
operatormod
: Thea % b
operatorpow
: Thea ** b
operator
- Unary operators (require one argument that has to be the struct-type):
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
Experimental support for operator overloading.
structs
can now have an additionalimpl 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
: Thea + b
operatorsub
: Thea - b
operatormul
: Thea * b
operatordiv
: Thea / b
operatormod
: Thea % b
operatorpow
: Thea ** b
operator
- Unary operators (require one argument that has to be the struct-type):
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
v0.5.8.4
v0.5.8.3
- 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
- Script 1 "test_send.to2":
- Add
ksp::game::notification_alert
andksp::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
toksp::debug::SAVE_LOAD_CONTROL
(#152) - Add
orbit.global_orbit_normal
v0.5.8.2
- 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
- Script 1 "test_send.to2":
- Add
ksp::game::notification_alert
andksp::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
toksp::debug::SAVE_LOAD_CONTROL
(#152)