What's new

SublimeKSP Updates (current version: 1.18.2)

Sorry @EvilDragon but there seems to be a compile bug. I have a couple of knobs used to position controls, but since I updated, they made the control disappear, rather than move it, so I checked the compiled script, and found the error:

Uncompiled:
Code:
on ui_control(knb_control_x)
        control -> POS_X := knb_control_x
end on

on ui_control(knb_control_y)
        control -> POS_Y := knb_control_y
end on


Compiles to:

Code:
on ui_control($knb_control_x)
  set_control_par(get_ui_id($sli_dirt),$CONTROL_PAR_POS_X,get_ui_id($knb_control_x))
end on

on ui_control($knb_control_y)
  set_control_par(get_ui_id($sli_dirt),$CONTROL_PAR_POS_Y,get_ui_id($knb_control_y))
end on

The error is obvious, the last parameter should be the value, not the ui ID of the control.

That said, I updated a few days ago manually. I will try the latest version and report back.

EDIT: Yep, just installed latest version via package control, bug is still there
 
This has been fixed since 1.4.2 release, do a manual update to the latest state of the SublimeKSP repo.
Just did. Bug is still there... :(

UPDATE: My bad. I downloaded from "latest version" in the repo, not the master version. Doing the latter fixed it!
 
Last edited:
Updated for 1.15.0 release (still needs to propagate to Package Control).

Don't forget to restart Sublime Text after upgrading from Package Control (when it's finally there), if you notice any weird behavior!
 
Updated for 1.16.0 release (still needs to propagate to Package Control).

Don't forget to restart Sublime Text after upgrading from Package Control (when it's finally there), if you notice any weird behavior!
 
Appreciate the updates, some good features recently.

I don't know if this is a bug or whether it was not supposed to work in the first place, but all my instrument stopped compiling with this update because I use code like this:
Code:
    { from an imported file }
    USE_CODE_IF_NOT(MIDI_NOTE_COUNT)
        define MIDI_NOTE_COUNT := 128
    END_USE_CODE

    { elsewhere}
    USE_CODE_IF_NOT(MIDI_NOTE_COUNT)
        define MIDI_NOTE_COUNT := 128
    END_USE_CODE

I hope it's a bug because this was really handy. Otherwise it means adding extra SET_CONDITION lines everywhere.
 
It's not a bug.

  • Added an error in case a duplicate define is being declared (issue #380)

That's the result of this entry in the changelog.


I would say be careful about your defines, especially with imports. If you have a situation where the same define is in multiple files, this means you should abstract those defines into a separate import file that just contains them, and is then imported where needed. And I'm not sure why are you wrapping this into USE_CODE_IF_NOT, this is kinda micromanaging IMO. Defines are either way scrubbed away if they are not being used.
 
The way I have been doing things that worked really well up to now was by having default value defines in my library files wrapped in USE_CODE_IF_NOT(define_name) that I could override if I wanted by defining the same define name with a different value in my project file just above where I import the library file. What would be a good way to do the same thing now? They need to be constants that can be evaluated at compile time.
Thanks for any suggestions.
 
I would never override. I would always have a file with library-specific defines that is being imported. Then it's easy to set it up differently per library, you don't need to override anything.
 
I just need to override the odd define on a project basic so I've just added a SET_CONDITION(DEFINE_NAME) along with the define to solve the problem so my code compiles again. It's fine.

Found a problem with combine callbacks though which is this:

Imported file:
Code:
on init
    declare x
end on

main file:
Code:
import "import_fle.ksp"

on init
    declare !multi_dimensional_string_array[2, 2]
end on

Syntax error. Works fine with normal string arrays.
 
Last edited:
I just need to override the odd define on a project basic so I've just added a SET_CONDITION(DEFINE_NAME) along with the define to solve the problem so my code compiles again. It's fine.

Found a problem with combine callbacks though which is this:

Imported file:
Code:
on init
    declare x
end on

main file:
Code:
import "import_fle.ksp"

on init
    declare !multi_dimensional_string_array[2, 2]
end on

Syntax error. Works fine with normal string arrays.
Hi Tonewill,

I'm aware of this issue, but a little unsure on what's causing it. If you add the import line after the init callback that may fix it. Looking into a fix for this!

All the best,
Jack
 
Thanks Jack, I'll give that workaround a try later.

This is not related to the above and I don't want to be a pain, but I was looking through the source out of interest and noticed this in ksp_parser.py:
Code:
# Define a rule so we can track line numbers
def t_COMMENT(t):
    r'\{[^}]*?\}|\(\*[\w\W]*?\*\)'
    t.lexer.lineno += t.value.count('\n')
    pass
I don't know python and don't use regex enough to ever remember how it works but as far as I can tell, it doesn't seem to be tracking line numbers of c-style comments (//).
I'm 99% sure I'm either wrong or it doesn't matter so I apologize for wasting your time if so!
 
Last edited:
You are correct, it's only matching the { } and (* *) style comments, it's not matching /* */ nor // style comments. However, I cannot immediately force a case where the line number goes out of whack, do you perhaps have a minimal example where an error is thrown at the wrong line number?
 
Top Bottom