Jump to content

Autoit + Lua + SciTE


Recommended Posts

First of all, I love Autoit. It's very simple and easy to understand and I use it a lot. I've just now started to use LUA as well (because I'm working on a project that requires it) and I notice a couple of things concerning SciTE.

One thing I love about the new SciTE version is that it supports autoit's keyword functionality in the editor. So, if you type any of the beginning words for the statements it automatically formats the line for you.

This has helped me a ton in learning the basics of autoit as well as making sure I don't make incorrect mistakes.

However, with LUA, there isn't any type of editor that supports keyword enhancement within the editor itself. With my new project, I need to work with LUA but it also involves privately used functions, statements, etc. and I wanted to know if it's easy or difficult to create keyword functionality in SciTE.

So, my questions are:

1. How hard is it to create keyword properties for SciTE for another SciTE supported program?

2. Would creating the keyword properties involve using an Autoit script to do and if so, where is an example of the script being used?

3. If there is more involved than this, could someone place in a quick synopsis of what is fully covered in making keyword properties in SciTe like those for autoit?

Thanks again.

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

  • Developers

So, my questions are:

1.  How hard is it to create keyword properties for SciTE for another SciTE supported program?

<{POST_SNAPBACK}>

To create a keyword list is not difficult. there are 2 kind of lists (e.g. for autoit3):

- au3.properties: contains the list of functions/keywords etc which is used for the Syntax Highlighting and is dependant on the SciLexer logic

- AU3.api : is used for the Autocomplete and Intellisense function.

2.  Would creating the keyword properties involve using an Autoit script to do and if so, where is an example of the script being used?

<{POST_SNAPBACK}>

I am using an Autoit3 script which i have started a while ago and is overhauled/completed by Valik. It automatically generates the Au3.keywords.properties and au3.api files (but also the definition files needed for Tidy, Au3check etc...) and uses the Helpfile sources files as its base source.

3.  If there is more involved than this, could someone place in a quick synopsis of what is fully covered in making keyword properties in SciTe like those for autoit?

<{POST_SNAPBACK}>

Just have a look at the examples that come with Scite and you will see its not that difficult to get it going... :(

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks JdeB, I'll look into the examples you gave and see what I can come up with.

Appreciate it.

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

Okay, it's working nice.

Here's an example of some functions I placed in the iface.api file:

AbandonQuest() Example: AbandonQuest() Description: Abandon the specified quest. 
AbandonSkill(index) Example: AbandonSkill(index) Description: Abandon a skill 
abs(number) Number Example: abs(-22) Description: Returns the absolue value of the number. 
AcceptDuel() Example: AcceptDuel() Description: Accept the challenge to a duel 
AcceptGroup() Example: AcceptGroup() Description: Accept the invitation to party 
AcceptGuild() Example: AcceptGuild() Description: Accept the invitation to join a guild 
AcceptResurrect() Example: AcceptResurrect() Description: Accepts the resurrection of your character by another player. 
AcceptXPLoss() Example: AcceptXPLoss() Description: Accept the XP loss to be reborn where you stand. 
acos(number) Number Example: myangle = acos(1) Description: Returns the value of the Arc Cosine of X in degrees. 
ActionButtonDown(buttonID) Example: ActionButtonDown(1) Description: Press the specified action button. 
ActionButtonUp(buttonID) Example: ActionButtonDown(1) Description: Release the specified action button. 
AddChatWindowChannel(identifier, channel) Example: AddChatWindowChannel(chatFrame:GetID(), channel) Description: Adds a chat channel to a chat window. 
AddChatWindowMessage(identifier, group) Example: AddChatWindowMessages(chatFrame:GetID(), group) Description: Addes a messaging group to the specified chat window. 
AddFriend(FriendName) Example: AddFriend(editBox:GetText()) Description: Add a friend to your friends list. 
AddFriend(name) Example: AddFriend("kelthan") Description: Adds the specified friend to the friends list.  
AddIgnore(UserName) Example: AddIgnore(editBox:GetText())  Description: Add a player to your ignore list. 
AddOrDelIgnore(name) Example: AddOrDelIgnore("Marco") Description: Toggles the ignore state of the specified user. 
AddTradeMoney() Example: AddTradeMoney() Description: Adds money to the trade window from the cursor. 
asin(number) Number Example: myangle = asin(1) Description: Returns the value of the Arc Sine of X in degrees. 
AssistByName(target) Example: AssistByName("Marco") Description: Assists the player whose name is entered. 
AssistUnit(target) Example: AssistUnit("target") Description: Instructs your character to assist the target player. 
AssistUnit(targetcode) Example: AssistUnit("target") Description: Targets the target of the targeted unit. 
atan(number) Number Example: myangle = atan(1) Description: Returns the value of the Arc Tangent of X in degrees. 
atan2(numberx, numbery) Number Example: myangle = atan2(1,2) Description: Returns the value of the Arc Tangent of X/Y in degrees. 
AttackTarget() Example: AttackTarget() Description: Attacks the targetted unit. 
AutoEquipCursorItem() Example: if ( button == "LeftButton" ) then AutoEquipCursorItem() end Description: Causes the equipment on the cursor to be equipped. 
AutoEquipCursorItem() Example: AutoEquipCursorItem() Description: Instructs the player to equip an item held by the cursor. 
BankButtonIDToInvSlotID(indentifier,bankboject) Identifier Example: BankButtonIDToInvSlotID(this:GetID(),this.isBag) Description: Returns the ID number of a bank button in terms of inventory slot ID 
BeginTrade() Example: BeginTrade() Description: Begins the trade with the target. 
BonusActionButtonDown(buttonID) Example: BonusActionButtonDown(1) Description: Trigger the specified bonus(pet or minion) action button. 
BonusActionButtonUp(buttonID) Example: BonusActionButtonUp(1) Description: Release the specified bonus(pet or minion) action button. 
CancelDuel() Example: CancelDuel() Description: Refuse the invitation to fight a duel. 
CancelDuel() Example: CancelDuel() Description: Cancels the duel with the specific user.  
CancelLogout() Example: CancelLogout() Description: Refuse the logout attempt 
CancelPendingEquip(slot) Example: CancelPendingEquip(slot) Description: Drop the item you were going to equip. 
CancelPlayerBuff(index) Example: CancelPlayerBuff(0) Description: Cancels the buff at the specified index. 
CancelTrade() Example: CancelTrade() Description: Declines the offer to trade with the other player. 
CancelTradeAccept() Example: CancelTradeAccept() Description: Cancels the trade attempt which required an accept. 
CanOpenPanels() Boolean Example: if ( CanOpenPanels() ) then Description: Returns true if the player is allowed to open his items. 
CanSignPetition() Boolean Example: CanSignPetition() Description: Returns true if the player is not in a guild. 
CastSpell(id, SpellBookFrame.bookType) Example: CastSpell(id, SpellBookFrame.bookType) Description: Casts the spell at slot "id" in book "bookType" 
CastSpellByName(spellname) Example: CastSpellByName("Demon Skin") Description: Casts a specific spell by the name used in the game. 
ceil(number) Number Example: 1 == ceil(.8) Description: Returns the value of a number rounded up to the next integer. 
ChangeActionBarPage() Example: ChangeActionBarPage() Description: This updates the action bar page to be at the correct page.  
ChangeActionBarPage() Example: ChangeActionBarPage() Description: Changes the action bar page to the page specified in CURRENT_ACTIONBAR_PAGE 
ChannelBan(channel,player) Example: ChannelBan("uimods", "alexyoshi") Description: Bans a player from the specified channel. 
ChannelInvite(channel,player) Example: ChannelInvite("cutestelves","glorfindel") Description: Invites the specified user to the chatroom. 
ChannelKick(channel,player) Example: ChannelKick("bigllamas", "Strong_Bad_Is_Geh") Description: Kicks the specified user from the channel. 
ChannelModerator(channel,player) Example: ChannelModerator("uimods","Kelthan") Description: Sets the specified player as the channel moderator. 
ChannelMute(channel, player) Example: ChannelMute("uimods","zileas") Description: Turns off the specified player's ability to speak in a channel. 
ChannelToggleAnnouncements(channel) Example: ChannelToggleAnnouncements(channel) Description: Sets the channel to display announcements.  
ChannelUnban(channel, player) Example: ChannelUnban("uimods", "kat") Description: Unbans a player from a channel. 
ChannelUnmoderator(channel, player) Example: ChannelUnmoderator("uimods", "xiphoric") Description: Takes the specified user away from the moderator status. 
ChannelUnmute(channel,player) Example: ChannelUnmute("uimods", "marco") Description: Unmutes the specified user from the channel. 
ClearTutorials() Example: ClearTutorials() Description: Removes the tutorial popups. 
CloseBag(number) Example: CloseBag(0) Description: Closes the bag at number specified. 
CloseTrade() Example: CloseTrade() Description: Closes the trade. 
CloseWindows( ignoreCenter) Example: CloseWindows(true) Description: Closes all of the currently open frames unless the boolean parameter is set to true, making it ignore the center window. 
CollapseQuestHeader(questID) Example: CollapseQuestHeader(questID) Description: Collapses the quest header? 
CollapseTrainerSkillLine(0) Example: CollapseTrainerSkillLine(0) Description: Collapses the trainer skill ine. 
CompleteQuest() Example: CompleteQuest() Description: Called when the CompleteQuest button is pressed. 
CompleteQuest() Example: CompleteQuest() Description: Completed the specified quest in the quest log window. 
ConfirmAcceptQuest() Example: ConfirmAcceptQuest() Description: Accept the quest. Yes. Really accept it. 
cos(number) Number Example: myx = cos(180) Description: Returns the cos of the value in degrees. 
CursorHasItem() Boolean Example: CursorHasItem() Description: Returns true if the cursor currently holds an item

The snippet of code you gave me works great in the lua.properties. I didn't have to make any adjustments. Posting it in case others need to see.

# Autocomplete and call tip settings
api.$(file.patterns.lua)=$(SciteDefaultHome)\api\iface.api
calltip.lua.word.characters=$(chars.alpha)$(chars.numeric)_
calltip.lua.ignorecase=1
calltip.lua.end.definition=)
autocomplete.lua.ignorecase=1
autocomplete.lua.start.characters=$(chars.alpha)$(chars.numeric)$_@#
word.characters.$(file.patterns.lua)=$(chars.alpha)$(chars.numeric).$_@#

Thanks JdeB, looks like I can throw in the other 1,000 functions over the next few days hehe.

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

Okay, it's working nice. 

Here's an example of some functions I placed in the iface.api file:

<snip>

The snippet of code you gave me works great in the lua.properties.  I didn't have to make any adjustments.  Posting it in case others need to see.

# Autocomplete and call tip settings
api.$(file.patterns.lua)=$(SciteDefaultHome)\api\iface.api
calltip.lua.word.characters=$(chars.alpha)$(chars.numeric)_
calltip.lua.ignorecase=1
calltip.lua.end.definition=)
autocomplete.lua.ignorecase=1
autocomplete.lua.start.characters=$(chars.alpha)$(chars.numeric)$_@#
word.characters.$(file.patterns.lua)=$(chars.alpha)$(chars.numeric).$_@#

Thanks JdeB, looks like I can throw in the other 1,000 functions over the next few days hehe.

<{POST_SNAPBACK}>

Are you wanting an api/properties file for Lua's built-in methods/properties...?
Link to comment
Share on other sites

Are you wanting an api/properties file for Lua's built-in methods/properties...?

<{POST_SNAPBACK}>

I could definitely use a lua.api file if you have one. I created a brand new api called wow.api which houses all of the functions, variables, etc. for the application I'm using.

However, I've been having to add in all of the string, math, and table parameters for lua to enhance the calltip functionality of SciTe.

So far, the .api I've created is up to about 980 lines.

Edited by Joel

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

Attached is a ZIP archive with 4 files:

  • lua.properties - A copy of the properties file I use. If you use this, a lot of tweaking will be needed; all the syntax highlighting is configured through variables that you won't have.
  • lua.keywords.properties - Auto-generated list of SciTE's built-in LUA methods/properties. This file shouldn't be edited in the event I ever post another one.
  • lualib5_annot.api - API file for the standard LUA functions/methods. This can be found on the web.
  • iface.api - Auto-generated API (from Scintilla.iface) containing most (all?) of SciTE's builtin methods/properties.
The contents of the files may reflect things not available in your version of SciTE. It was generated from a CVS snapshot a couple days ago so if fresh.

Link to comment
Share on other sites

Thanks Valik!

I'm going to take a look at it now.

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

I modified the lua.properties to accept the wow.api and call tips in there as well as the one for yours:

api.$(file.patterns.lua)=$(SciteDefaultHome)\api\lualib5_annot.api;$(SciteDefaultHome)\api\iface.api;$(SciteDefaultHome)\api\wow.api
calltip.lua.word.characters=$(word.chars.lua)$(chars.alpha)$(chars.numeric)_
calltip.lua.ignorecase=1
calltip.lua.end.definition=)
autocomplete.lua.ignorecase=1
autocomplete.lua.start.characters=$(word.chars.lua)$(chars.alpha)$(chars.numeric)$_@#
word.characters.$(file.patterns.lua)=$(chars.alpha)$(chars.numeric).$_@#

I had to change the cases to 1 in order for the wow.api to work but it's looking good so far. I'm still going to test with it.

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

I had to change the cases to 1 in order for the wow.api to work but it's looking good so far.  I'm still going to test with it.

<{POST_SNAPBACK}>

I don't recommend that. Lua is a case sensitive language. If the wow.api isn't working right, then finding out why is a better idea than disabling case sensitivity.
Link to comment
Share on other sites

I don't recommend that.  Lua is a case sensitive language.  If the wow.api isn't working right, then finding out why is a better idea than disabling case sensitivity.

<{POST_SNAPBACK}>

With testing, this seems to work for everything you incorporated and for the wow.api. What do you think?

# Autocomplete and call tip settings
api.$(file.patterns.lua)=$(SciteDefaultHome)\api\lualib5_annot.api;$(SciteDefaultHome)\api\iface.api;$(SciteDefaultHome)\api\wow.api
calltip.lua.word.characters=$(word.chars.lua)$(chars.alpha)$(chars.numeric)_
calltip.lua.ignorecase=1
calltip.lua.end.definition=)
autocomplete.lua.ignorecase=1
word.chars.lua=$(chars.alpha)$(chars.numeric)_%.:
autocomplete.lua.start.characters=$(word.chars.lua)$(chars.alpha)$(chars.numeric)$_@#
word.chars.lua=$(chars.alpha)$(chars.numeric)_%.:
word.characters.$(file.patterns.lua)=$(chars.alpha)$(chars.numeric)_%

With this, the call tips seem to work great for the wow.api, lualib5_annot.api, and iface.api.

If I keep the following:

autocomplete.lua.ignorecase=1

I can see all three .api fine and they work great with the call tips.

If I change that to 0, I only see the two .api files you created and wow.api is completely ignored. Any ideas and what does this particular case do? Prompt for syntax checking?

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

Here's the .zip with the modified files and it includes the wow.api. Can you take a peek and see what the cause may be?

Thanks Valik and by the way, I love the .api files. These were "EXACTLY" what I was looking for.

Thanks mate.

wowscite.zip

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

I copied the text inside the code box from this post, added it to a file named wow.api and added that to the lua.properties. Everything seemed to work fine for me. The autocomplete listbox and the tooltip displayed for the items I copied to wow.api.

Link to comment
Share on other sites

Here's the .zip with the modified files and it includes the wow.api.  Can you take a peek and see what the cause may be?

Thanks Valik and by the way, I love the .api files.  These were "EXACTLY" what I was looking for.

Thanks mate.

<{POST_SNAPBACK}>

I dropped the wow.api file on top of the one I had created, reloaded SciTE and everything worked as expected. I didn't have to make any changes anywhere (Except I had to add the API file to the list, obviously). You've probably got a typo somewhere in your properties file or something.
Link to comment
Share on other sites

I copied the text inside the code box from this post, added it to a file named wow.api and added that to the lua.properties.  Everything seemed to work fine for me.  The autocomplete listbox and the tooltip displayed for the items I copied to wow.api.

<{POST_SNAPBACK}>

Thanks mate.

[font="Optima"]"Those who heed life with speculation and contemplation, are the ones stuck home with constipation." - Joel[/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...