From 4a1243fc95166bcad010f87179e6803b3b475ee3 Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Wed, 14 May 2025 11:00:45 +0200 Subject: [PATCH] inlined isp calc to make nde.ks standalone. --- lib/SASCheck.ks | 7 ------- loadmanprogram.ks | 5 ----- loadprograms.ks | 1 + nde.ks | 18 ++++++++++++++++-- 4 files changed, 17 insertions(+), 14 deletions(-) delete mode 100644 lib/SASCheck.ks delete mode 100644 loadmanprogram.ks create mode 100644 loadprograms.ks diff --git a/lib/SASCheck.ks b/lib/SASCheck.ks deleted file mode 100644 index 5ffe22a..0000000 --- a/lib/SASCheck.ks +++ /dev/null @@ -1,7 +0,0 @@ -function sascheck { //returns the average exaust velocity of active engines. to convert to isp, divide by constant:g0 - set saslist to ship:modulesnamed("ModuleSAS"). - if saslist:length = 0 { - return false. - } - return true. -} diff --git a/loadmanprogram.ks b/loadmanprogram.ks deleted file mode 100644 index 5add9ff..0000000 --- a/loadmanprogram.ks +++ /dev/null @@ -1,5 +0,0 @@ -if not exists("1:/lib") { - createdir("1:/lib"). -} -compile "0:/lib/isp.ks" to "1:/lib/isp.ksm". -compile "0:/nde.ks" to "1:/nde.ksm". diff --git a/loadprograms.ks b/loadprograms.ks new file mode 100644 index 0000000..c7f5540 --- /dev/null +++ b/loadprograms.ks @@ -0,0 +1 @@ +compile "0:/nde.ks" to "1:/nde.ksm". diff --git a/nde.ks b/nde.ks index 2a67d0e..37c5e7b 100644 --- a/nde.ks +++ b/nde.ks @@ -1,5 +1,19 @@ -//import functions -run once "lib/isp". +function evcalc { //returns the average exaust velocity of active engines. to convert to isp, divide by constant:g0 + local englist is list(). + local totalflow is 0. + local totalthrust is 0. + list engines in englist. + for eng in englist { + if eng:ignition and not eng:flameout { + set totalflow to totalflow + (eng:possiblethrust /(eng:isp * constant:g0)). + set totalthrust to totalthrust + eng:possiblethrust. + } + } + if totalthrust = 0 { //avoid div by 0 later + return 1. + } + return (totalthrust / totalflow). +} set nd to nextnode. //print out node's basic parameters - eta and deltav