Full autocomplete Defold API for Sublime Text 3

Hello all!

I use Sublime Text 3 as external editor for Lua code. After sometime use I created for Sublime Text 3 with LuaExtended plugin full autocomplete for Defold API.

For use you need Sublime Text 3 with LuaExtended Plugin
http://www.sublimetext.com/3 - Sublime
https://packagecontrol.io/packages/LuaExtended - plugin

After install Sublime and Plugin you need replace LuaExtended.sublime-package(for windows this packege located in \AppData\Roaming) my version.

Link for download modified packege - https://www.dropbox.com/s/ijtxet59hfhf2r9/LuaExtended.sublime-package?dl=0 (Plugin under MIT license)

After start Sublime you can use Defold API autocomplete.

For good work with Defold LUA scripts you need in Sublime goto “View menu->Syntax->Open all with current extension as …” and select LuaExtended for .script and .gui_script files!

Due to the limitations of the plugin you need to type commands with “_”, but not to the “.”. For example, to use the functions GameObjects, you need to start typing go_, then you see a list of all available functions for working with GameObjects (go_get_position for example). After you select need function, you press Enter and see right function format(for our example go.get_position([id])).

All start prefix same from API Defold documentation (crash,gui, go,sys,profiler,render,resource,sys,window,collectionfactory,collectionproxy,physics,factory,label,model,particlefx,sound,spine,sprite,tilemap,buffer,hash,html5,image,json,msg,vmath,zlib,facebook,iap,iac,push and webview)

I make special addons for standart messages. For example you enter go_msg_enable and after press enter you see msg.post(’#my_component’, ‘enable’). If message sent back you receive only message. For example you enter “collectionproxy_proxy_loaded” and receieve “proxy_loaded”

All macros for messages:
gui_layout_changed post layout_changed
go_msg_acquire_input_focus post msg.post(’#my_component’, ‘acquire_input_focus’)
go_msg_disable post msg.post(’#my_component’, ‘disable’)
go_msg_enable post msg.post(’#my_component’, ‘enable’)
go_msg_release_input_focus post msg.post(’#my_component’, ‘release_input_focus’)
go_msg_set_parent post msg.post(’#my_component’, ‘set_parent’, {parent_id=…, keep_world_transform=… })
render_clear_color post msg.post(’@render:’, ‘clear_color’, { color = vmath.vector4(r, g, b, a) } )
render_draw_line post msg.post(’@render:’, ‘draw_line’, { start_point = vmath.vector3(x, y, z), end_point = vmath.vector3(x, y, z), color = vmath.vector4(r, g, b, a) } )
render_draw_text post msg.post(’@render:’, ‘draw_text’, { text = … , position = vmath.vector3(x, y, z) } )
render_window_resized post window_resized
sys_msg_exit post msg.post(’@system:’, ‘exit’, {code = 0})
sys_msg_reboot post msg.post(’@system:’, ‘reboot’, {arg1 = …, arg2 = …, arg3=…, arg4=…, arg5=…, arg6=… )
sys_msg_set_update_frequency post msg.post(’@system:’, ‘set_update_frequency’, { frequency = 60 } )
sys_msg_start_record post msg.post(’@system:’, ‘start_record’, { file_name = …, frame_period = …, fps = … } )
sys_msg_stop_record post msg.post(’@system:’, ‘stop_record’)
sys_toggle_physics_debug post msg.post(’@system:’, ‘toggle_physics_debug’)
sys_msg_toggle_profile post msg.post(’@system:’, ‘toggle_profile’)
camera_acquire_camera_focus post msg.post(’#camera’, ‘acquire_camera_focus’)
camera_release_camera_focus post msg.post(’#camera’, ‘release_camera_focus’)
camera_set_camera post msg.post(’#camera’, ‘set_camera’, {aspect_ratio = …, fov = …, near_z = …, far_z = …})
collectionproxy_async_load post msg.post(’#proxy’, ‘async_load’)
collectionproxy_disable post msg.post(’#proxy’, ‘disable’)
collectionproxy_enable post msg.post(’#proxy’, ‘enable’)
collectionproxy_final post msg.post(’#proxy’, ‘final’)
collectionproxy_init post msg.post(’#proxy’, ‘init’)
collectionproxy_load post msg.post(’#proxy’, ‘load’)
collectionproxy_proxy_loaded post proxy_loaded
collectionproxy_proxy_unloaded post proxy_unloaded
collectionproxy_set_time_step post msg.post(’#proxy’, ‘set_time_step’, {factor = …, mode = …})
collectionproxy_unload post msg.post(’#proxy’, ‘unload’)
collobj_apply_force post msg.post(’#co’, ‘apply_force’, {force = vmath.vector3(x, y, z), position = vmath.vector3(x, y, z)})
collobj_collision_response post collision_response
collobj_contact_point_response post contact_point_response
collobj_ray_cast_response post ray_cast_response
collobj_trigger_response post trigger_response
model_animation_done post model_animation_done
sound_play_sound post msg.post(’#sound’, ‘play_sound’, {delay = 0, gain = 1})
sound_set_gain post msg.post(’#sound’, ‘set_gain’, {gain = 1})
sound_stop_sound post msg.post(’#sound’, ‘stop_sound’)
spine_animation_done post spine_animation_done
spine_event post spine_event
sprite_animation_done post animation_done
sprite_play_animation post msg.post(’#sprite’, ‘play_animation’, {id = hash(‘jump’)})

PS: I patched BracketHighlighter plugin for correct select If end, for end and etc blocks for LuaExtended(plugin under MIT License too)

Install by same path about install LuaExtended
Link to original version - https://packagecontrol.io/packages/BracketHighlighter
Link to patched version - https://www.dropbox.com/s/hnvmdtdwr070itl/BracketHighlighter.sublime-package?dl=0
PPS: Sorry for my bad English and I hope my work help someone

12 Likes

Thank you for sharing your work! I prefer Atom myself, but I have some colleagues that swear by Sublime instead. Ain’t that right @Adam_Westman?

1 Like

Looks great! Yeah when spanning over multiple code bases Sublime vs Atom is not a question anymore, the ability to join together projects and search them all in a matter of milliseconds is far too valuable :slight_smile:

1 Like

Uploaded new version. Small fix for functions with more when 2 params

3 Likes

I’ve a bit updated this useful package here: https://github.com/Dragosha/LuaExtended

  • Forked from most newest version of that package what I found.
  • Added: GUI and GO CONSTANTS, timer, spine_slots
  • Added: Defenitions for Flow.lua module (https://github.com/britzl/ludobits/blob/master/ludobits/m/flow.lua)
  • Zipped version ‘LuaExtended.sublime-package’ for quick replace old one at C:\Users\USERNAME\AppData\Roaming\Sublime Text 3\Installed Packages
5 Likes

Thanks for the extension! Next time pls check the readme, I lost a day figuring out that the original package in sublime package repo does not have any Defold api. Is there a way to make luacheck read lib dependancies?