-
Notifications
You must be signed in to change notification settings - Fork 241
Closed
Description
Hello
Not sure this discussion is not appeared in the past.
I looked through issues but found nothing similar.
Sorry if is duplicate.
I noticed that list#x marked as deprecated here
http://ksp-kos.github.io/KOS_DOC/structures/collections/list.html?highlight=deprecated
Accidently I found that # works also for lexicons.
And voila - we get good OOP syntax out of box right now.
function kob_atm_ascent_new {
declare local parameter myMaxQ.
local obj is lexicon().
// class attributes
set obj#q_lim to myMaxQ.
set obj#q_cur to 0.
set obj#q_factory to 0.
... more attributes
// class methods
set obj#update to kob_atm_ascent_update@:bind(obj).
set obj#test to kob_atm_ascent_test@:bind(obj).
}
function kob_atm_ascent_test{
declare local parameter obj, mult.
return obj#q_cur * mult.
}
// Update variables according to ship current state
// Param1: object
function kob_atm_ascent_update {
declare local parameter obj.
obj#q_factor to obj#q_cur * 12345.
}
class usage example somewhere in code
local ascent is kob_atm_ascent_new(15).
until ship:altitude < 60 {
ascent#update().
print round(ascent#q_cur, 2) + at ( 0, 1).
...
}
That looks exciting to me.
It is absolutely true OOP like in other scripting languages.
Just don't depreciate it.
Thanks for excellent mod.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels