Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / [WIP] AGK in Sublime

Author
Message
Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 12th Jul 2013 13:13 Edited at: 17th Jul 2013 12:44
For a bit of fun and to expand my skill set a bit, I had a go at writing a syntax definition for AppGameKit for Sublime. I've only been working on it for a few hours but here's the result so far:



The syntax highlighting still needs some work and I'm also looking into how we can go about building/compiling the project from Sublime. If anyone knows of any documentation about the AppGameKit compiler and its command line arguments, please point me in the right direction.

Latest download needs to be extracted!!!

For now though, you can simply run Sublime alongside the AppGameKit IDE.

In basic steps:

1. Edit file(s) in Sublime (have the same project open in the AppGameKit IDE).
2. Once you wish to compile, switch to the AppGameKit IDE and you'll encouter a message:
.

Simply hit 'Yes' (or 'All' if you've been editing multiple files).

Installing the package
Simply download the package attached to this post and place it in <sublime installation folder>/Pristine Packages. Then open up sublime. That's it!!!

To check that it has worked, down in the bottom right hand corner of Sublime, you should see the file type e.g "Plain text". Click on that and a drop down menu should appear. "AGK" should be near the top and simply select it to use the AppGameKit highlighting.



Remember to back up your code as I haven't given this method a thorough test (although theoretically, it should be safe).

Enjoy!!!

A few features about sublime which may encourage you to at least give it a try:
-Autocomplete
-Split Editing (two or more source files open side by side).
-Goto anything: press Ctrl+P, type '#' and then your search to search through your code. A find and replace is also available.
-Much more...

A note about the autocomplete
Upon a fresh install of Sublime, autocomplete may not be available. To install autocomplete follow these steps:
1. Paste and Run this code in the built-in console (View->Show Console) (may take a few mins).

2. Once you've restarted Sublime hit Ctrl+Shift+P and type in "Install Package" - hit Enter.
3. Type in "SublimeCodeIntel" and press Enter. May take a few mins.
4. Restart Sublime.

I haven't done anything with the autocomplete but Sublime seems to be able to pick up on what you've typed and adds it to it's own auto complete list. However, it only adds what you've currently got in the source file to it's list and so commands and variable names may not instantly be in the list. I'll see if I can somehow add the AppGameKit commands to the list but it's not high on my to-do list.

Update
-Added 'to' 'or' 'and' 'not' keywords.
-Variable names with numbers in them no longer have the numbers highlighted.
- the '`' symbol is now recognised as a comment.
- AppGameKit functions highlight differently to user functions.

We can now compile in Sublime!
In summary, to do this, install the sublime package downloaded from this post (simply copy/paste into <your sublime installation folder>/Pristine Packages). Then add the agkcompiler to your PATH. I'll give more detailed instructions in a post below.
Please follow these steps: http://forum.thegamecreators.com/?m=forum_view&t=206696&b=48&msg=2471944#m2471944

Update 17/7/2013
-Syntax highlighting fixed for a few extra keywords including type, endtype, as, and agk datatypes.
- New build system. Instead of having 4 different build systems to switch from, there is now only 1 - AppGameKit Build. The way this works is that F7 will compile and to execute the other variants, hit Ctrl+Shift+P and in the search box type in "run", "compile", "broadcast" or something along those lines (the search box is flexible).
- AppGameKit Run added - allows you to run the latest build. To do this, simply drop the AGKRun.exe into the same folder as your AGKCompiler.exe (assumes you've already set your PATH). To run the latest build, hit Ctrl+Shift+P and search for "agk run" (or similar). Make sure that "AGK Build" is the current build system sublime is using in Tools->Build Systems. See here for more details.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
13
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Jul 2013 16:59
Nice work Hodgey! This might prove a suitable replacement for the IDE for those who can't wait for V2


this.mess = abs(sin(times#))
Lucas Tiridath
AGK Developer
12
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 12th Jul 2013 20:25
Hey Hodgey, this looks great! Very nice that it autocompletes the user defined functions too. Thanks for sharing!

If you're looking for the compiler's command line parameters, I think Markus figured them out and wrote them down for us here.

If you get it compiling natively from sublime, I'll definitely be switching over, at least until we see what TGC come up with for V2.

Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 13th Jul 2013 01:29
Thanks Baxslash and Lucas!

I'll look into those command line args. One of the problems I currently see with it though is locating the compiler.exe. People may have it installed in different locations. I'll try to cover the basic C:\Program Files\... but if you want to test code in different versions of AppGameKit, it's probably best to just have the AppGameKit IDE open alongside Sublime and simply reload the source files.

xCept
17
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 13th Jul 2013 05:45
Cool, I just bought Sublime recently and was thinking about using it for AppGameKit development. Thanks for sharing this.
unlikely
8
Years of Service
User Offline
Joined: 5th Mar 2012
Location: Ohio, USA
Posted: 13th Jul 2013 07:08 Edited at: 13th Jul 2013 07:10
Quote: "One of the problems I currently see with it though is locating the compiler.exe."

You can have people add the compiler path as a shell variable. That's what I've seen some TextMate extensions do...

Good initiative, by the way!
Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 13th Jul 2013 07:58
You're welcome xCept. I hope you can make good use of it. I know I will be.

Quote: "You can have people add the compiler path as a shell variable. That's what I've seen some TextMate extensions do..."

I've been thinking about that, just trying to work out the cons. I'd have to show people (or point them to a tutorial) on how to add it and I'm also wondering about AppGameKit updates and what effects those will have.

I've just updated the package- it now highlights AppGameKit commands differently to user-defined functions. I have used the list from the index in the AppGameKit docs so any command that's not in the index won't light up. Let me know if I've missed any!

Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Jul 2013 13:57 Edited at: 14th Jul 2013 13:57
I've made a few updates:
-Added 'to' 'or' 'and' 'not' keywords.
-Variable names with numbers in them no longer have the numbers highlighted.
- the '`' symbol is now recognised as a comment.

Download the latest package from the top post.

RickV
TGC Development Director
20
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 15th Jul 2013 15:13
Hi,

Lee is back now and I was able to garner this info out of him;

Compiling AppGameKit T1 Source from third party IDEs

1. Locate and call the AGKCompiler.exe to compile an AppGameKit T1 source file

2. Ensure the current working folder is within the AppGameKit project at the time of calling the compiler

3. To compile only, use the command parameters: "-agk main.agc" where main.agc is the main source

4. To compile and broadcast, use the command parameters: "-bct main.agc" where main.agc is the main source

5. To compile, run and broadcast, use the command parameters: "-run main.agc" where main.agc is the main source

6. When the AGKCompiler.exe process terminates, the compile is complete

Financial Director
TGC Team
Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Jul 2013 01:13 Edited at: 17th Jul 2013 12:43
Thanks Rick! I'm now compiling agk code in Sublime! To do this follow these steps:

1. Install the sublime package downloaded from the top post by copy/pasting into <your sublime installation folder>/Pristine Packages (you should see a bunch of other packages there as well).
2. Add the <your AGK installation folder>/AGK/IDE/Compiler to your PATH (explained further below).
3. Open sublime.
4. [deprecated]Click on Tools -> Build System and you should see 3 relating to AppGameKit - AppGameKit Compile, AppGameKit Compile and Broadcast, AppGameKit Compile Run Broadcast. Select which one you want to use currently and then use F7 to execute the build system.[/deprecated] "AGK Build" is the new system -> see here for more details.
NOTE: your project must have a main.agc for this to work. Also, when using AppGameKit Compile, to run the program, you'll have to navigate to your project folder in windows explorer and run from there (simply via the double click).

Setting up your PATH
1. Find your AGK/IDE/Compiler folder (for me it's- C:\Program Files\The Game Creators\AGK\IDE\Compiler).
2. Right-click on My Computer and then click on properties.
3. Click on "Change Settings"

4. Click on the "Advanced" tab.
5. Click on "Environment Variables".
6. Under System Variables scroll until you find "Path".
7. Click on Path and then click on "Edit"
8. Add a semicolon ';' (don't add a space!) right after the last entry.
9. Paste in your path to the AGK/IDE/Compiler folder. Your path should look something like this:


There will probably be a lot more stuff in your path but this gives you the basic idea.
10. Click OK in all open windows.
11. Open/Restart Sublime.
12. Begin coding!

baxslash
Valued Member
Bronze Codemaster
13
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Jul 2013 11:37 Edited at: 16th Jul 2013 11:37
I set up the build system as suggested by Hodgey and sublime is pretty nifty! I would like a "Run latest build" command but Hodgey and I are looking into that right now

Anyway for those who like the look of the AppGameKit IDE here's the colour scheme I'm using:



this.mess = abs(sin(times#))

Attachments

Login to view attachments
Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 17th Jul 2013 12:42
As well as fixing up the syntax highlighting a bit, I now have "Run latest build" working.

To set this up, download the latest .zip and extract. There will be two files:
- AGKPackage.sublime-package (install as per instructions given above)
- AGKRun.exe - place in the same folder as your AGKCompiler.exe.

Usage
-F7 will compile the agk code.
-Ctrl+Shift+P will bring up a "Command Palette": search for "agk" and you should see the other build variants. Select the one you desire.


Ancient Lady
Valued Member
16
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 17th Jul 2013 16:12
Pretty cool work. Thank you.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
10
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 19th Jul 2013 06:11
This may be exactly what I'm looking for thanks!!

Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 19th Jul 2013 09:42
Let me know how it runs on your end guys. It's working like a dream on mine!

Zwarteziel
9
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 19th Jul 2013 10:28
Thank you for this, Hodgey. I hadn't heard of Sublime before, but it looks very nice. I'll be trying your download this weekend if I can free up some time!
Zwarteziel
9
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 21st Jul 2013 11:00 Edited at: 3rd Aug 2013 15:32
I've been able to try Sublime Text 3 and am very happy with the way it works. Thanks for all the effort that has been put into this.

For those that dislike pressing [ctrl]-[shift]-[p] and selecting a command with the mouse: it is possible to bind stuff such as the 'Run the latest AppGameKit build'-command to a key. To do this, click on [Preferences] -> [Key bindings - User] and enter the following text:



In this case, I've bound F8 to the run-command, so I can build with F7 and see the results by pressing an adjacent key. You can replace "f8" with anything you like though, and of course bind other commands such as broadcast etc. to other keys.

EDIT: for easy copy-pasting, here's the line in text:

Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 21st Jul 2013 14:16
I'm glad you're making use of it Zerotown! I was looking into keybindings but couldn't quite work out the variant part - thanks for sharing!

Zwarteziel
9
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 22nd Jul 2013 02:54 Edited at: 22nd Jul 2013 16:00
I'm a big fan of the dark themes Sublime comes with. I've created a relatively sober one that I'd like to share. It consist of a color scheme, a matching darkened sidebar and a hinted version of the famous (and free) Inconsolata 'programmers font'. To install all of it, download the file and follow the included instructions.

The archive contains four files, beside a readme.txt file with the same text as below:

1. Default.sublime-theme
2. Zerotown_AGK.tmTheme
3. Inconsolata-Bold.ttf
4. Inconsolata-Regular.ttf

To install files 1 and 2, do the following:
- copy the files by selecting them and pressing [Ctrl]+[C] from the Windows Explorer;
- open Sublime Text 3 and click on [Preferences] -> [Browse Packages];
- paste the files into the folder that has opened;
- select [Preferences] -> [Color Scheme] -> [User] -> [Zerotown-AGK]
- you're done!

To install files 3 and 4, do the following:
- right-click on each of the files from the Windows Explorer;
- select either [Install] or [Preview] -> [Install];
- open Sublime Text 3 and click on [Preferences] -> [Settings - User]
- the following text should appear (or something along those lines):

- add a comma after the color_scheme-string and the following text, so that it reads:

- select [File] -> [Save]
- you're done once more! (though you might want to adjust the font-size)

Here's a resized screenshot of how it should look:

Attachments

Login to view attachments
Impetus73
9
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 22nd Jul 2013 05:56
Zerotown, you just made coding, beautiful!

TGC should really consider this setup as the default for AppGameKit 2.0

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
Zwarteziel
9
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 22nd Jul 2013 15:57
Quote: "Zerotown, you just made coding, beautiful!

TGC should really consider this setup as the default for AppGameKit 2.0"


Thank you! I find that the dark background is really easy on the eyes and helps to preserve my laptop's battery as well

I wonder if it is possible (in Sublime) to list the available functions of an opened file in the sidebar. That's something I'm really missing in the current iteration of the Codeblocks IDE. Another thing that the Codeblocks IDE *does* offer, (but Sublime could possibly adapt) is the opening of help/reference-files for specific commands, by selecting them and pressing F1. These files are stored locally, so I guess a script could be made that links to them and launches the browser to display them.
Naphier
10
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 2nd Aug 2013 17:05 Edited at: 2nd Aug 2013 18:52
This is so great. I just set this up (don't know what I was waiting for). It is so near perfection. And Zerotown, thank you so much for this nice theme it is so easy on the eyes!! Much better than the colors I had set up in AppGameKit IDE.

I hope someone comes up with a way to open the help files.
Actually since we're using the online help with examples and all I think it would be great to be able to press F1 and open the online help for the command... or just have the command typed into the search box that Paul set up. I tried passing like this
http://www.appgamekit.com/documentation/search.html?search=text
but the page isn't set up to accept a variable like that.

Hotkeys for folding don't work
And folding isn't persistent (i.e. close Sublime then reopen and anything you folded is unfolded)

Still better than the standard IDE!!

EDIT: Google!
If you want persistent folding and more then install BufferScroll
https://github.com/SublimeText/BufferScroll
And nevermind about folding hotkeys not working... I didn't realize it required two hotkeys...

EDIT2:
I've found a way to do a google search of the selected text in Sublime. the method uses AutoHotkey, which I love. What it does is it copies the selected text to the clipboard and sends it to you browser. Works nicely and the command help is only a click away.
Here's the AutoHotKey scrip for anyone interested (currently uss Win+S hot key):


Zwarteziel
9
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 3rd Aug 2013 11:32 Edited at: 3rd Aug 2013 15:30
Hi Naphier,

thanks for both your kind words and your additions! This is indeed starting to feel like the perfect IDE. It is very nice to be able to search google for selected text/AGK-commands. I've installed AutoHotKey and made your script part of my standard Windows-startup commands. The BufferScroll-functionality also looks handy. I'll look into installing it later today. (It requires the Package Manager, which - in order to work for Sublime Text 3 - requires GIT, right?)

EDIT:
I had some trouble getting Package Control for Sublime Text 3 working (and thus BufferScroll as well). For those that are also wondering or struggling, here's what I did:

1. installed GIT from this location;
2. opened GIT BASH;
3. followed the instructions in this post;
4. started Sublime Text 3;
5. pressed [Ctrl]+[Shift]+[P]
6. typed: "package control";
7. selected: "Package control: Install package";
8. selected: "BufferScroll".
Naphier
10
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Aug 2013 21:48
Would be awesome if I didn't have to actually have to make sure that main.agc is the in-focus tab when compiling and running.

Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 6th Aug 2013 00:55
Quote: "Would be awesome if I didn't have to actually have to make sure that main.agc is the in-focus tab when compiling and running."

I'll look into that. Unfortunately, my PC is packed a way for a little bit so I can't test this out right away but I do recall being able to compile from a different source file other than main.agc. However, I do believe that the source file that's in focus when you hit compile must be in the same folder as your main.agc file.

One thing to remember is that Sublime is a text editor (with a bunch of awesome features) more than it is and IDE. It doesn't exactly make and manage projects (something Code blocks has over it) but when I eventually get my PC out I'll try to find a fix.

Naphier
10
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 6th Aug 2013 04:31
That'd be awesome! Thanks, Hodgey!
Another feature I really miss from the DBPro IDE is being able to highlight a block and comment/uncomment it all. Unfortunately this doesn't appear to be working in sublime.
All minor inconveniences.
This is already much better than the AppGameKit IDE, so I can't complain!
But I always wish for more
If I knew python (or had time to learn it) I'd give some of this a go, but I'm on deadline to get a prototype working by the weekend.
Thanks again for all the work!

Naphier
10
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 10th Aug 2013 00:10
Added UNDIM to the keyword list at line 5872 in AGK.tmLanguage



That's the only keyword I've found missing so far.
A few minor things that would be cool if fixed (I'm not sure how to):
Function names that end in a number (i.e. MyFunction2()) aren't recognized as user functions for color coding.

Multiple quotes in a single line confuses the color coding for string text. For example
Print("ABCD" + str(someNum) + "EFG")
will cause the
+ str(someNum) +
to be highlighted like it is characters between quotes.
Not a biggy, just confuses the eyes occasionally.
Comments with quotes on the same line as quoted text also exhibits this behavior.
Comment blocks (Toggle Comment and Toggle Block Comment) don't work. I really miss this from the DBPro IDE.

Thanks a ton!!!

Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 10th Aug 2013 00:35
Thanks Naphier, I'll check those out ASAP.

The occasional keyword/command slips through the net as I had to do a copy/paste from the Index and Language pages of the AppGameKit docs.

I'll see if I can fix up the colouring; my regex isn't fantastic though.

Naphier
10
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 21st Aug 2013 05:42
I had a few extra minutes and made some changes to the AGK Build.sublime-build file so that you no longer need to have main.agc in focus or even open. just have the folders open for you project and build.
After a bit of a struggle I was also able to get the AGKRun command to work as well.



I just added the working directory in to be the current project path.
Had to do similar for AGKRun, but I'm not all too sure about why it can't just use the working directory. No matter, passing the entire path of main.agc for your project to the AGKRun.exe seems to work just fine. I tried to find ways to just run the executable in the project directory, but had no luck.

Hodgey
11
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 21st Aug 2013 13:16
Thanks for spending time on this Naphier as I just haven't been able to find the time to work on it (PC is still packed away and my Mac won't cut it ).

The AGKRun.exe simply takes the project folder of the file you give it and runs the executable based on that (so if your exe name is different to your project folder it won't work). The other reason it might not be working is because I whipped it up in about an hour - there could be cases in which I haven't accounted for .

I should be able to have my pc up and running again by the weekend and hopefully (very hopefully) I'll be able to track down the bugs and fix them.

Thanks again for your fixes Naphier!

Naphier
10
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 21st Aug 2013 15:46
Yeah I was trying to make a cmd that just used Sublime's environment variables to run an exe based on the project folder name, but it was running a hidden version of the exe (i.e. no window would appear, but the program would show as running in task manager). No matter, AGKRun now works without needing to focus on main.agc in Sublime OR even having it open.

Cliff Mellangard 3DEGS
Developer
14
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 24th Aug 2013 10:15
great work hodgey!
I will surely look in to this when i have more time!

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Login to post a reply

Server time is: 2020-10-28 12:19:46
Your offset time is: 2020-10-28 12:19:46