What's new

Scripting problem

herrali

Active Member
Hello
I am a beginner at scripting and I have a problem with scripting a release knob, i created a knob to link it to modulation retrigger release knob, but it doesn't work,
it applys and has no error but when i change my created knob amount there is no change on the modulation release knob ,
can you tell me what should i do?
here is my scripting:
Code:
on init
    make_perfview
    set_ui_height_px(350)
    message("")  { this clears the status line so no error messages will be hidden }
    declare ui_knob $Release(0,10,1)
    move_control($Release,6,4)
end on

on ui_control ($Release)
    set_engine_par($ENGINE_PAR_RELEASE,$Release, 0,0,-1)
end on
 

Attachments

  • Capture.PNG
    Capture.PNG
    12.4 KB · Views: 6
Last edited by a moderator:
(I edited your post to add code tags so that it's easier to read.)

Engine parameters usually go from 0 to 1000000, so if your GUI release knob only goes from 0 to 10, it's going to have virtually no effect, since it's essentially going from 0 to barely more than 0. In other words, the full range of a 0 to 10 GUI knob will result in only a range of 0 to 0.000001 in the actual engine Release. (0/1000000 to 10/1000000)

So when you declare the Release knob, you'd probably want something more like:
declare ui_knob $Release(0,1000000,1)

Another option is that you could keep the $Release knob range at 0 to 10, but then in the ui_control callback, multiply that value by 100,000 so that it translates into the full 0 to 1,000,000 range on the engine release.
 
(I edited your post to add code tags so that it's easier to read.)

Engine parameters usually go from 0 to 1000000, so if your GUI release knob only goes from 0 to 10, it's going to have virtually no effect, since it's essentially going from 0 to barely more than 0. In other words, the full range of a 0 to 10 GUI knob will result in only a range of 0 to 0.000001 in the actual engine Release. (0/1000000 to 10/1000000)

So when you declare the Release knob, you'd probably want something more like:
declare ui_knob $Release(0,1000000,1)

Another option is that you could keep the $Release knob range at 0 to 10, but then in the ui_control callback, multiply that value by 100,000 so that it translates into the full 0 to 1,000,000 range on the engine release.
I tried 1000000 but it didn't work
 
Please read the sticky thread about modulation in KSP and how to approach the modulators by using find_mod() etc.
I red a lot of threads and they made me more confused, all I need is link my created knob to that release knob which starts from 1 to 12, that's it
 
I explain how to do exactly what you need (well ok, it applies to changing the LFO frequency, but you just exchange the engine parameter for envelope release instead) in that sticky thread. Please read it. :)
 
I explain how to do exactly what you need (well ok, it applies to changing the LFO frequency, but you just exchange the engine parameter for envelope release instead) in that sticky thread. Please read it. :)
i red the thread and thank you very much for that it was very useful, my knob now works with some little changes ,but when i touch the knob to any number the release modulation goes only 1, and i don't know why? my knob any number then release knob = 1 , i couldn't find how to fix it in that thread, can you guide me a little more please?
 
all I need is link my created knob to that release knob which starts from 1 to 12, that's it
It's certain that if you set your knob from 0 to 12, it will deviate very little; normally, to have the full release setting, the ideal is 0 to 1 000000 _

declare ui_knob $Release(0,1000000,1)
 
It's certain that if you set your knob from 0 to 12, it will deviate very little; normally, to have the full release setting, the ideal is 0 to 1 000000 _

declare ui_knob $Release(0,1000000,1)
It worked , thank you very much, but There is no way to have smaller number?
The modulation knob itself is 0 to 12
 
0 to 12 just like the release knob at modulation quartet note, I think its not ms because it shows note icon
 
Right. You need to use the 0-1000000 range then. It's actually showing 1 to 12 not 0 to 12, it's a multiplier of the note value. You can use get_engine_par_disp() along with set_knob_label() if you want to show the 1-12 value, even if the knob's internal range is 0-1000000.
 
Right. You need to use the 0-1000000 range then. It's actually showing 1 to 12 not 0 to 12, it's a multiplier of the note value. You can use get_engine_par_disp() along with set_knob_label() if you want to show the 1-12 value, even if the knob's internal range is 0-1000000.
Yes,I will try it, thank you so much
 
I red a lot of threads and they made me more confused, all I need is link my created knob to that release knob which starts from 1 to 12, that's it
Yes, there is. As I mentioned earlier: ;)
Another option is that you could keep the $Release knob range at 0 to 10, but then in the ui_control callback, multiply that value by 100,000 so that it translates into the full 0 to 1,000,000 range on the engine release.
So your knob could still be 1 to 10 (or 0 to 12 or whatever, just adjust the math), then in the ui callback, do this:

Code:
on ui_control ($Release)
    $Engine_Value_That_We_Need := Release * 100000
    set_engine_par($ENGINE_PAR_RELEASE, $Engine_Value_That_We_Need, xxx, xxx, -1)
end on
 
Yes, there is. As I mentioned earlier: ;)

So your knob could still be 1 to 10 (or 0 to 12 or whatever, just adjust the math), then in the ui callback, do this:

Code:
on ui_control ($Release)
    $Engine_Value_That_We_Need := Release * 100000
    set_engine_par($ENGINE_PAR_RELEASE, $Engine_Value_That_We_Need, xxx, xxx, -1)
end on
Can you edit the command just for me for that knob 1 to 12? I don't understand these codes (but don't laugh at me , I am beginner) 🙂
 
If your ui knob ($Release) goes from 1 to 12, then that means:

If $Release is at 1 (your knob minimum), it should correspond to the minimum engine value, which is 0.
If $Release is at 12 (your knob maximum), that should correspond to the maximum engine value, which is 1000000.

Before reading further, think about that and make sure it makes sense to you.

There are 11 increments between 1 and 12. (There would be 12 increments from 0 to 12, but for whatever reason, you want your knob to go from 1 to 12.) So for each $Release knob increment, it needs to increase the Engine value by 1,000,000 / 11. That equates to 90,909 per click of the $Release knob.

So the $Release knob values and their corresponding Engine values will look like this, where $Release is the first value, and Engine value is the second:
1 : 0
2 : 90,909
3 : 181,818
4 : 272727
5 : 363636
6 : 454545
7 : 545454
8 : 636363
9 : 727272
10 : 818181
11 : 909090
12 : 999999 (close enough to 1,000,000)

So your code would look like this:
Code:
on ui_control ($Release)
    $Engine_Value_That_We_Need := ($Release - 1) * 90909
    set_engine_par($ENGINE_PAR_RELEASE, $Engine_Value_That_We_Need, xxx, xxx, -1)
end on

I'll leave it to you to firgure out why I used ($Release - 1) instead of $Release.
 
If your ui knob ($Release) goes from 1 to 12, then that means:

If $Release is at 1 (your knob minimum), it should correspond to the minimum engine value, which is 0.
If $Release is at 12 (your knob maximum), that should correspond to the maximum engine value, which is 1000000.

Before reading further, think about that and make sure it makes sense to you.

There are 11 increments between 1 and 12. (There would be 12 increments from 0 to 12, but for whatever reason, you want your knob to go from 1 to 12.) So for each $Release knob increment, it needs to increase the Engine value by 1,000,000 / 11. That equates to 90,909 per click of the $Release knob.

So the $Release knob values and their corresponding Engine values will look like this, where $Release is the first value, and Engine value is the second:
1 : 0
2 : 90,909
3 : 181,818
4 : 272727
5 : 363636
6 : 454545
7 : 545454
8 : 636363
9 : 727272
10 : 818181
11 : 909090
12 : 999999 (close enough to 1,000,000)

So your code would look like this:
Code:
on ui_control ($Release)
    $Engine_Value_That_We_Need := ($Release - 1) * 90909
    set_engine_par($ENGINE_PAR_RELEASE, $Engine_Value_That_We_Need, xxx, xxx, -1)
end on

I'll leave it to you to firgure out why I used ($Release - 1) instead of $Release.
I think I got it, I'm working on it, your explanation was very good and clear enough , thank you very very much
 
Top Bottom