textmate bundle additions for lua

View previous topic View next topic Go down

textmate bundle additions for lua

Post  zzajin on Fri Apr 10, 2009 11:12 am

Here is a script that will generate the text additions needed for the Textmate lua language bundle to add syntax coloring to SIO2/GL/AL wrapped functions, defines, and enums.


Code:


#!/usr/bin/env python

import re

fileIN = open("sio2.module", "r")
line = fileIN.readline()

functions = re.compile(".*[\s|\*]([\w]+)\s*\([\.,\w\*\s]*\)\s*;")
defines = re.compile("^\s*#(define|DEFINE)\s([\w]+)\s.*")
enum_start = re.compile("^\s*typedef\s+enum.*")
enum = re.compile("^\s*([_A-Z0-9]+).*")
enum_end = re.compile("^\s*}.*")

func_bundle = "{        name = 'support.function.library';\
                        match = '(?<![.:])\\b(SIO2\.("

define_bundle = "{      name = 'meta.preprocessor.macro.c';\
                        match = '\\b(SIO2\.("

func_first = True
define_first = True
enum_ready = False

while line:

        m = enum_start.match(line)
        if m and not enum_ready:
                enum_ready = True
        m = enum_end.match(line)
        if m:
                enum_ready = False

        m = enum.match(line)
        if m and enum_ready:
                if not define_first:
                        define_bundle = define_bundle + '|'
                else:
                        define_first = False
                define_bundle = define_bundle + m.group(1)

        m = functions.match(line)
        if m:
                if not func_first:
                        func_bundle = func_bundle + '|'
                else:
                        func_first = False
                func_bundle = func_bundle + m.group(1)

        m = defines.match(line)
        if m:
                if not define_first:
                        define_bundle = define_bundle + '|'
                else:
                        define_first = False
                define_bundle = define_bundle + m.group(2)

        line = fileIN.readline()

define_bundle = define_bundle + "))\\b';\
                        },"
print define_bundle

func_bundle = func_bundle + "))\\b(?=\()';\
                        },"
print func_bundle




Place the script in [sio dir]/src/lua/swig. Running the script will parse through sio.module and print out a wall of text that looks like:

Code:

{   name = 'meta.preprocessor.macro.c';         match = '\b(SIO2\.(SIO2_VERSION_COPYRIGHT|SIO2_VERSION_WEBSITE|SIO2_VERSION_EMAIL|SIO2_VERSION_AUTHOR|SIO2_VERSION_MAJOR|SIO2_VERSION_MINOR|

....

|AL_INVERSE_DISTANCE_CLAMPED|AL_LINEAR_DISTANCE|AL_LINEAR_DISTANCE_CLAMPED|AL_EXPONENT_DISTANCE|AL_EXPONENT_DISTANCE_CLAMPED))\b';         },
{   name = 'support.function.library';         match = '(?<![.:])\b(SIO2\.(sio2Init|sio2InitGL|sio2InitAL|sio2ShutdownAL|sio2InitLUA|
 
...

|alBufferData|alBufferf|alBuffer3f|alBufferfv|alBufferi|alBuffer3i|alBufferiv|alGetBufferf|alGetBuffer3f|alGetBufferfv|alGetBufferi|alGetBuffer3i|alGetBufferiv|alDopplerFactor|alDopplerVelocity|alSpeedOfSound|alDistanceModel))\b(?=\()';         },



Paste this text in the bundle editor in the Lua language bundle (the text box will be titled 'Edit Language: "Lua") somewhere in the pattern list and hit "Test".

Code like "SIO2.sio2ResourceRender" and "SIO2.SIO2_RENDER_SOLID_OBJECT" should be colored now.

zzajin

Posts : 81
Join date : 2008-10-14

View user profile

Back to top Go down

Re: textmate bundle additions for lua

Post  uprise78 on Fri Apr 10, 2009 12:39 pm

Thats a sweet little bundle.

I have a question for you: why are you using lua instead of just coding in C? I have not been able to come up with any reason at all to use lua besides user created downloadable scripts (not a very good reason).

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: textmate bundle additions for lua

Post  sio2interactive on Fri Apr 10, 2009 4:12 pm

I am personally using LUA for my game the following way:

- Set the characters animations sequence within Blender
- Dialogs
- Characters stats
- Items stats
- Goals definition
- Game settings

I am also thinking of creating a small IDE to create GUI, drag drop, click click click, pop the callback code etc... so basically every piece of GUI in the game is a LUA script. The point of using LUA is to don't have to recompile the whole game when changes are made or simply to offload some code that can be dynamically loaded...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: textmate bundle additions for lua

Post  oioioi on Fri Apr 10, 2009 4:51 pm

can't people with a jailbroken device go in and change the lua script? If you use it for stats your online high score(if you got one) would be screwed. Unless you make a check for whats on, lets say line 50, and if it's changed the app won't start, just tell the user to redownload the app. Just a thought

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: textmate bundle additions for lua

Post  sio2interactive on Fri Apr 10, 2009 4:59 pm

All the .LUA are bundled within an SIO2 file and are password protected... so there's no way the users can get access to it...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: textmate bundle additions for lua

Post  zzajin on Fri Apr 10, 2009 5:24 pm

For me LUA support is perhaps the main feature of SIO2.

I've created a remote console/terminal for SIO2. It's a desktop app which connects via bonjour and can send/receive data. The two main use cases are sending LUA commands/scripts and sending game assets. The goal is to create an environment for rapid game dev/prototyping by avoiding recompiling and uploading the app to the device.



Compiling is so tiresome Sleep

zzajin

Posts : 81
Join date : 2008-10-14

View user profile

Back to top Go down

Re: textmate bundle additions for lua

Post  oioioi on Sat Apr 11, 2009 2:22 am

Open up a password protected zip file isn't hard, unless you use a password with lots of wierd characters, but it will stll be possible

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: textmate bundle additions for lua

Post  uprise78 on Mon Apr 13, 2009 12:28 pm

zzajin,

That sounds like an interesting way to play with things in SIO2. Do you care to share the code or submit to SIO2?

On a side note, to speed up compile time check out the post on sprites that I put up a week or so ago. The project download in there compiles everything except SIO2 from the source into a static lib and speeds things up A LOT.




zzajin wrote:For me LUA support is perhaps the main feature of SIO2.

I've created a remote console/terminal for SIO2. It's a desktop app which connects via bonjour and can send/receive data. The two main use cases are sending LUA commands/scripts and sending game assets. The goal is to create an environment for rapid game dev/prototyping by avoiding recompiling and uploading the app to the device.



Compiling is so tiresome :sleep:

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: textmate bundle additions for lua

Post  zzajin on Mon Apr 13, 2009 3:28 pm

uprise78 wrote:zzajin,

That sounds like an interesting way to play with things in SIO2. Do you care to share the code or submit to SIO2?


Yes, I plan on making it available. I'm still working out bugs, polishing, and discovering how to best work with it. For instance, I'm adding a variable inspector/editor now that I figured out how to dynamically traverse all the global LUA variables.

zzajin

Posts : 81
Join date : 2008-10-14

View user profile

Back to top Go down

Re: textmate bundle additions for lua

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum