- 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)