Squirrel IDE - Notepad++

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Squirrel IDE - Notepad++

Post by R2dical »

So having tried a few of the IDEs for Squirrel, Eclipse, Code::Blocks, etc I like Notepad++ the best, mainly for quick startup and large coding space on my small screen.

Anyway I have some tools to help with OpenTTD squirrel coding, namely syntax highlighting(colouring) and code completion for the API that others might find useful.

Features
----------

- Syntax highlighting, for the Squirrel language (structure(brackets), keywords, comments, operators and math library), NoAI API, NoGo API and with Doxygen support too.
- Code completion, for the Squirrel language (keywords, functions(methods or default delegates), metamethods), NoAI and NoGo API (functions, classes and enumerators) version 1.4, math lib. These provide return value, function/class etc definition, parameters and description.

Download
----------
Squirrel Openttd Tools.7z
API Version 1.4
(55.23 KiB) Downloaded 1195 times
To use (Windows)
--------

- Syntax highlighting, put "userDefineLang.xml" in "C:\Users\%USERNAME%\AppData\Roaming\Notepad++\". (Note if this file already exists you may wish to back up or merge to keep existing user defined language.) Now a file opened with .nut extension should have the highlighting, otherwise it can be activated by Language -> Squirrel . Colours and customizing can be done in Language -> Define Your Language -> select "Squirrel". (Note if you make use of code folding - using the [+]/[-] blocks next to "{" and "}" to collapse the blocks of code, you will need the beta branch of the UDL2.0 lexer available here).

- Code completion, put "Squirrel.xml" in the "\Notepad++\plugins\APIs\" folder, usually in "C:\Program Files\". Activate in Notepad++ by Settings -> Preferences -> Auto-Completion -> select "Enable auto-completion on each input", "Function completion" and "Function parameters hint on input". (Note this requires a User Defined Language (UDL) called "Squirrel" to work, like the one above.) This is based on the 1.3.3 NoGo and NoAI API and was created by a custom xml parser and writer from the DoxyGen docs. The best way to do this would probably be to have one autogenerated for each new version of the API by a Python script or something. My current version is made from a Excel database and will need to be updated manually for API changes.

Links and resources (For anyone looking to modify and my own reference :) )
----------------------

- UDL2.0 Docs here.
- UDL2.0 beta branch here.
- UDL Autocomplete xml documentation here.
Attachments
Openttd Api.7z
Database for code completion and macro to generate xml. Only required if you want to modify or make your own Squirrel.xml!
(172.94 KiB) Downloaded 413 times
Last edited by R2dical on 24 Mar 2014 12:22, edited 2 times in total.
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Squirrel IDE - Notepad++

Post by skippern »

I will test this in Wine::Notepad++ on Mac, currently using TextWrangler that is nut much help apart from some syntax highliting, doesn't fully recognize squirrel language. Hope these tools can improve my bit-twisting on my AI idea
Skippern
OpenTTD Mac user
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: Squirrel IDE - Notepad++

Post by R2dical »

skippern wrote:that is nut much help
:lol:

Cool, good luck :)
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Squirrel IDE - Notepad++

Post by skippern »

Thanks R2dical for the highlighting, though the API seems to be a little buggy. Don't know if this is a Wine::Notepad++ problem or a general Notepad++ bug, as I havn't tried it on other platforms.

Guess you will be maintaining this with future API updates, etc...
Skippern
OpenTTD Mac user
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: Squirrel IDE - Notepad++

Post by R2dical »

NP, though there were a few highlighting presets available. This one was made to work with the code complete :)

What do you mean by buggy? Even the one I see has quirks, it is a txt editor after all :lol: But should be pretty solid, where is it not working?

As changes to the api are usually not too large the current version of the xml should be easy enough to modify. If someone has MSOffice they can use the spreadsheet I posted to generate the xml without getting their hands dirty. I will post updates on the occasion but I think a nice long term solution would be to have some combo of doxygen and say python script to create this xml direct from source. This should be pretty easy but I don't (yet) know enough python or equivalent to do it.
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Squirrel IDE - Notepad++

Post by skippern »

R2dical wrote: What do you mean by buggy? Even the one I see has quirks, it is a txt editor after all :lol: But should be pretty solid, where is it not working?
The autocompletion dropdown sort of flickers whenever I write anything, even if there are nothing to put in the dropdown (try writing "teleledningsanka")
Skippern
OpenTTD Mac user
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: Squirrel IDE - Notepad++

Post by R2dical »

Hmm, yeah I get nothing like that in the win7 version. That happen with the built in autocompletion languages (C++, xml, etc)?
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Squirrel IDE - Notepad++

Post by skippern »

R2dical wrote:Hmm, yeah I get nothing like that in the win7 version. That happen with the built in autocompletion languages (C++, xml, etc)?
Worth checking out, I havn't been using Notepad++ much, and than mostly for MapCSS and XML (without the use of autocompletion) so I really don't know.

It is probably to do with the interaction between Mac::Wine or Wine::Notepad++
Skippern
OpenTTD Mac user
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: Squirrel IDE - Notepad++

Post by skippern »

Mac OS X (Maverick) installation guide:

I got this successfully installed on my instance of Notepad++ installed from WineBottler (winebottler.kronenber.org) and following these simple steps got it up and running:

The userDefineLang.xml file goes into ~/Library/Application\ Support/org.kronenberg.winebottler.npp_139256822923326/drive_c/npp/

The Squirrel.xml goes into ~/Library/Application\ Support/org.kronenberg.winebottler.npp_139256822923326/drive_c/npp/plugins/APIs/

The rest is just the same as the Windows setup

I found it much better to run Notepad++ as a winebottler bundle than as a wine bundle, as winebottler allow me to run it as standalone app, instead of having to activate it via the wine file finder
Skippern
OpenTTD Mac user
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: Squirrel IDE - Notepad++

Post by R2dical »

Updated for API 1.4, get it from the first post :)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 16 guests