Script Editor

From HEWIKI
(Redirected from HSE2 Script Editor)
Jump to: navigation, search

Contents

The HeroEngine Script Editor provides an interface to read and edit scripts. It is built directly into HeroBlade and has many of the same modern features that can be found in other language editors, but is designed specifically to help create scripts in HeroScript Language (HSL).

Related tutorials

Invoking

There are multiple ways to open the Script Editor. Either:

Hse2hbopen.png

Opening a Script

To edit a specific script, either:

Hse2openfile.png

Important: The display of available scripts will at first only show Game-specific scripts (see Distribution package). To see all of the scripts in the original Clean Engine package, select the "Show Engine" checkbox at the bottom of the menu.

Scripts that are part of Clean Engine, will be prefixed with a "_" character.

Hse2ppicker.png


In the Script Picker, scripts listed with purplish/pinkish text are scripts that the viewer created (or "owns").
Scripts recently edited have a green background: dark green at first, then fading to white with each day, until back to fully white after a week.

Also, scripts listed with blue text are ones that the viewer was the most recent person to edit them, but does not own them.

Script editor

An opened script will look like this:
Hse2.png

Keyboard Shortcuts

ESC		Deselects All Selected Text, cancels member lists and parameter tips
ALT-G           Jumps to and opens if necessary the script that implements the method in which the cursor is located.
CTRL-]		Move to matching bracket/parenthesis
CTRL-ENTER	Open line above
CTRL-SHIFT-ENTER Open line below
CTRL-SPACE	Attempts to complete the current word
CTRL-SHIFT-SPACE Brings up function/method call parameter tip
CTRL-SHIFT-C	Open a Client Script
CTRL-SHIFT-S	Open a Server Script
CTRL-SHIFT-G	Open a GUI XML file
CTRL-SHIFT-L	Open a CLI file (not yet working)
CTRL-SHIFT-F	Opens the Function List panel
CTRL-/		Comment out the currently selected (or where cursor is) lines.
CTRL-SHIFT-/	Un-comment out the currently selected (or where cursor is) lines.
CTRL-G		Bring ups Goto Line# dialog
CTRL-H		Toggles History Panel Open / Closed
CTRL-T		Toggles Task List Panel Open / Closed
CTRL-R		Resolve
CTRL-F		Brings up Find / Replace Dialog
CTRL-SHIFT-A	Brings up Find In All Scripts Dialog
CTRL-I	        Starts a Dynamic Incremental Search (search from cursor down) Using CTRL-I repeatedly,
                will find the next occurrance of its current match.
CTRL-SHIFT-I	Starts a Dynamic Reverse Incremental Search (search from cursor up). Using this
                repeatedly will find the next previous occurrence of what it’s found so far.
CTRL-T		Transpose characters
CTRL-SHIFT-T	Transpose words
CTRL-SHIFT-ALT-T Transpose lines
CTRL-U		Change selection to lowercase
CTRL-SHIFT-U	Change selection to uppercase
CTRL-W		Toggles Word Wrap On / Off
CTRL-Z		Undo
CTRL-Y		Re-do
CTRL-C		Copy selected text
CTRL-V		Paste at cursor (overwrites any selected text)
CTRL-X		Cut (Removes the selected text from the original location after a paste)
DELETE		Deletes the selected text or the next character to the right of the cursor
CTRL-F2		Toggle Bookmark on line where cursor is located
CTRL-SHIFT-F2	Clear Bookmark on line where cursor is located
F2		Goto Next Bookmark
SHIFT-F2	Goto Previous Bookmark
F4		Goto Next Find Result
SHIFT-F4	Goto Previous Find Result
F6		Auto Reindent Script
F7		Compile
SHIFT-F7	Submit
F8		Goto Next Error
SHIFT-F8	Goto Previous Error

Main menu

File

Hse2filemenu.png
New 
Creates an empty file for a client or server script. You’ll fill out a name for the script and a description. Descriptions can be later edited.
Open 
Opens a server or client script.
Save Current File 
Saves only the active (tab selected) file.
Save All Files 
Saves all unsaved files currently opened.
Save File Group
Prompts the user to save all open files in a named group (lightweight project)
Load File Group
Prompts the user to load a previously saved named group (lightweight project)
Close
Closes the currently active file
Recent Files
10 most recently opened files
Recent Groups
10 most recently opened file groups
Exit 
Closes HeroScript Editor

Settings

Hse2settingsmenu.png
Save Panel Layout
Prompts the user to save the layout of displayed tool panels to a named file
Load Pabel Layout
Prompts the user to load the layout for displayed tool panels from a named file
Quick Save Panel Layout
Save the layout of displayed tool panels to an internal file
Quick Load Panel Layout
Loads the layout of displayed tool panels from an internal file
Close All Panels
Closes all open tool panels
Reset Panel Layout
Resets the display layout of all tool panels to the default

Edit

Hse2editmenu.png
Undo/Redo 
Undoes or re-applies separate edits made to the active (tab selected) script file in the order they were edited.
Cut/Copy/Paste/Delete 
Work as expected.
Auto Format Script 
Will go through the active script file (tab selected) and re-indent each line.
Comment Selection 
Will Comment out the selected line/s of code. CTRL-/ is the keyboard shortcut.
Uncomment Selection 
Will Uncomment out the Selected Line/s of code. CTRL-SHIFT-/ is the keyboard shortcut.
Complete Word 
If the HeroSense word-completion box is not already open, this will open it.
Parameter Info 
When the cursor is on a function/method call, this will show the parameter info tooltip.
Word Wrap 
Toggles word wrap on and off. Word wrap forces the lines of code to fit on the screen, wrapping to the next line if necessary.

Search

Hse2searchmenu.png
Find & Replace 
Prompts user to find or replace text
Find in All Scripts
Prompts user to find text in all scripts
Incremental Search / Reverse Incremental Search
Incrementally search forwards and backwards
Goto Line
Prompts user to specify line number to go to
Goto Definition
Prompts user to specify definition to go to
Next Error / Previous Error
Goes to next or previous error
Add Bookmark / Clear Bookmark
Sets or clears a bookmark
Previous Bookmark / Next Bookmark
Navigates between previous and next bookmarks


Incremental searching

Incremental Search 
This allows you to do an interactive search of the currently active (tab selected) script. Instead of a dialog, when you do an incremental search, the mouse cursor will change to show you’re doing an incremental searchImage018.jpg. As you type, the text edit cursor will move down (indicated by the arrow on the mouse cursor) to the next text that matches what is being typed, highlighting the letters it finds.

Below is an example of how this works. In this example, the writer ultimately typed id = The four pictures show how the search worked as the letters were typed in incrementally:

After typing in "i": Image020.jpg


After typing in "id": Image022.jpg


After typing in "id ": Image024.jpg


After typing in "id =": Image026.jpg

Note: After finding what you want:

Reverse Incremental Search 
This works exactly like Incremental search except that this will search up (indicated by the arrow on the mouse cursorImage028.jpg) instead of down from the text edit cursor.
Goto Line… 
Brings up a dialog allowing you to type in the line number you wish to the text edit cursor to “jump” to. This will scroll the window so that the line is visible.
Show Functions and Methods 
This brings up a window that lists all the functions and methods in the currently active (tab selected) script.

Tools

Hse2toolsmenu.png
Compile 
Will attempt to compile the active script (tab selected). If successful, the Submit menu option will become available. A successful compile will not cause the script to be used by the server or client. You must successfully submit it first.
Submit 
After a successful compile, this will submit the script to be saved and used by the server or client as the most recent revision of that script.
Resolve 
If the submit encountered a specific situation, this menu option will become active. The situation is when someone else is editing the same script, compiled it and submitted it before you submitted your change. In this case, you must resolve the conflict before you can submit it.
Image032.jpg
When resolving a conflict, the Merge Application will be run with your local script and the conflicting server script. The two scripts will be displayed side-by-side, while the merge application’s attempt to auto-merge will be shown below them. See the options dialog for information about your Merge Application. You must decide how to resolve the conflicts. There is an example showing the default conflict resolution application in action resolving a conflict (Three Way Merge Tool (Resolving Submit Conflicts)).
Abandon 
Only available when changes have been made to a script, whether they are saved or not. This will discard the changes and reload the last submitted version. CANNOT BE UNDONE
Distribution Package 
Set the distribution package of the script to be either Required, Optional, Game, or Optional Game.
Delete Script 
Marks the script as deleted. Its code will no longer be valid, but the script is not discarded completely.
Undelete Script 
Marks a deleted script as not deleted. The code will not be valid again until after re-submitting it.
Syntax Highlighting 
Brings up a dialog allowing the colors used in syntax highlighting to be changed. Syntax Highlighting controls the coloring of the code in the code windows.
Options 
This dialog allows you to specify a different Merge and Diff application from the default which is set up for use with p4Merge.

HeroEngine has no build-in merge or diff tool leaving you free to choose a favorite if you have one. By default we tend to use P4Merge which is available as a free download from Perforce.com for both merging and diffing needs.

Program Merge Application (path may vary) Arguments
Araxis Merge C:\Program Files\Araxis\Araxis Merge\compare.exe /3 /swap /wait /a1 %1 %2 %3 %4
KDiff3 C:\Program Files\KDiff3\kdiff3.exe  %1 %2 %3 -o %4
p4merge C:\Program Files\Perforce\P4merge.exe  %1 %2 %3 %4
WinMerge C:\Program Files\WinMerge\WinMergeU.exe  %2 %3 %4

Also, there are checkboxes to specify preferences regarding the types of scripts that will be shown each time the Open Script dialog is shown.

Font 
Designate the font to be used in the scripts.

Hse2toolsmenu.png

Windows

CompilierError.png
Task List 
Toggles a set of tasks or problems to correct on the currently active (tab selected) script. This task list is populated after an attempted compile. The list will show the line and column where the message occurred and the error message associated with it.
Script Console 
Toggles a tool panel that displays informational messages.

Hse2historypanel.png
History 
Toggles a window showing the history of the currently active (tab selected) script. This history records all changes made by anyone to this script. Each history entry is recorded with a successful submit.
Find Results 
Toggles the Find Results window, showing the results of the most recent search.
Commented 
This checkbox will list only revisions that have comments attached to them. These would normally be when significant changes were made by a scripter.
Functions and Methods 
See Show Functions and Methods on the Search Menu.
List of Opened Scripts 
This will list all the opened scripts opened by the script editor

Help

Hse2helpmenu.png
HeroScript Editor
Launches web browser to Script Editor page
HeroScript
Launches web browser to HeroScript page
GUI XML
Launches web browser to GUIXML page
Report a Bug
Launches email application to report a bug to support@heroengine.com

Toolbar

Hse2toolbar.png
The toolbar provides quick access to often used functionality.

New
Quick way to create a new client / server script, or a GUI XML file. (CLI isn’t currently used)
Open
Quick way to open a client / server script or XML file
Save Active Script
Will save the currently active (tab-selected) script or XML file
Save All Opened Scripts
Saves all scripts/files currently opened in the editor.
Find 
Quick access to the find / replace dialog.
Undo 
Undoes an edit
Redo 
Re-applies the action undone by the last undo.
Cut / Copy Paste 
does the normal copy, cut and paste operations on the selected text at the cursor location.
Delete 
Deletes the current selected text.
Add bookmark 
Adds a bookmark Image050.jpg at the line where the cursor is located.
Next bookmark 
Moves the cursor to the next bookmark on the active (tab selected) script.
Previous Bookmark 
Moves the cursor to the previous bookmark on the active (tab selected) script.
Clear bookmark 
Clears the bookmark on the line where the cursor is located.
Compile 
Compiles the currently active (tab-selected) script.
Compile All 
Compiles all modified files that are open.
Submit 
Submits the currently active and successfully compiled script to the server to replace the current latest script on the server (client or server scripts).
Resolve 
If there’s a conflict after a “submit” with the script already on the server, this will bring up a tool to let you resolve the conflicts.
Abandon 
Abandons changes to the active file, and restores the previously submitted version from the DOM

Script Edit Window

The edit window is where the work is done in creating the script
Image052.jpg
1: Bookmark
2: If cursor is next to a parenthesis, it will show the matching parenthesis in a grey box.
3: Line Numbers 
4: Data Type (String in this case)
5: Keyword
6: Comment
7: Indented structures such as If / Else are connected by a grey vertical line.
8: Text (not a keyword) surrounded by quotes.
9: Clicking on this box will “hide” the section of code between it and its matching closing data structure.

HeroSense

HeroSense is a feature that helps you write HSL code as you type. It does this by offering context-sensitive suggestions, high-lighting syntax errors and showing you the expected arguments to methods and functions. All in real-time.

Here are the key features of HeroSense:

Syntax Errors

Compile error.PNG

As the code is typed, it is parsed in the background and any syntax errors are made visible right when the code is fresh in your mind.

Name Completion

Memberlist.PNG

Whenever the script needs the name of a field, script, method, function, etc., the editor provides a list of all of the possible values in a nice unobtrusive notification window. The user can keep typing just using the window as a guide, or they can have the editor do the typing for them. The list automatically selects the first item that matches what has been typed so far, so a simple keystroke (Tab, Enter, or any character that isn't allowed in names) will complete that name.

Besides the list of names, the editor often has additional details that are displayed for the selected item after a brief pause.

In most scenarios, the list just automatically appears. For the cases where it doesn't, there is a special key combination to request completion (Ctrl-Space). If what is there already uniquely identifies the name, it will be inserted immediately; otherwise, the list is displayed as above.

When the editor completes a function or method name, it also goes that extra step and inserts parenthesis for you. It even positions the cursor either between the parenthesis or after them depending on if the function or method takes parameters.

Parameter Tips

Parameter tip.PNG

Another indispensable feature is the parameter tip. Whenever your calling a function or method, the parameter tip shows the declaration with the current parameter's name in bold. Comment lines immediately before and after the declaration are included (up to 10 lines total).

The parameter tip automatically appears when the open parenthesis is inserted, and goes away when the cursor leaves the parenthesis. The tip can be brought up at any time by pressing Ctrl-Shift-Space with the cursor inside the parenthesis of the call.

History Window

The history window is where you can see the list of revisions.
HSEFileHistory.png
1: Revision #, latest one first.
2: Name of account which did a successful submit for each revision.
3: Date/Time of the last successful submit
4: Comments related to their revisions. (Note: When the commented checkbox at the top of the History Window is checked, uncommented revisions will not appear on this list.)

Comparing Revisions

You can use your third-party diff tool to compare any two revisions of your choice:

  1. Single-click on revision X to select it. Selected revisions are highlighted in the history window.
  2. Double-click on revision Y to compare revisions X and Y.
HistoryWithSelectedRevs.png
Double-clicking on a revision when no other revisions are selected compares the clicked-on revision to the current revision.


A comparison of two revisions with the default Perforce merge tool (p4merge) is shown below. Unhighlighted text is the same in both revisions, green-highlighted text appears only in the right-side revision, and lavender-highlighted text appears only in the left-side revision. 

Diff.png



Resolving Conflicts: The Merge Tool

HSedit-DescribeWindow.jpg

What’s a Three Way Merge?

A three-way merge is the merging of three different files into one version. The Perforce merge tool here is doing a three-way merge. The top-left window is the server side’s latest version (the version you want to overwrite). The upper-right window is a view of the script you submitted. The bottom window shows the resolution of the conflicts between them.

The three files being merged are the current server side script version, and your two local versions of the same script file. Your two local versions are (1) the original version you had as of your last successful compile/submit; and (2) the file with the current edits (the script you want to become the current version).

Walking through a resolve

The scenario: There’s a problem with a script that needs fixing right away. You open the offending script and prepare to fix it. You notice that the problem is the function “testFunc()” is returning an Integer. You realize it must return a Boolean.

Unfortunately another equally dutiful GM (Sir Speedy), has already grabbed the same script, edited it and submitted a new version of the script. However, their fix is different from yours. Not knowing Sir Speedy was also fixing the problem, you compile and submit your code. To your horror, you see the following error in the status bar…

Image056.jpg

No worries, you just press the “Resolve” button. This shows:

  1. Code on both sides which shows no conflicts (not colored).
  2. Code that the merge tool is 100% sure must be deleted (green).
  3. Code that the merge tool is 100% certain must be deleted but where the code on both sides is not exactly the same. This means there’s a potential that this particular merge might be incorrect. You should look at the way it resolved this after all conflicts have been resolved.
  4. An un-resolvable merge (red). Merging this is beyond the merge tool’s ability to decide on a reasonable merge, and requires a human to make a decision.
  5. A popup menu where you can change how the merge tool has decided to merge the code. In this case, it’s being brought up so you can resolve the “un-resolvable” conflict. In this case, the choice is "Yours," which means that the person doing the merge (you) has decided the correct resolution to the conflict will be the “Your” code and not the “Theirs.”

After the merge is done

Image060.jpg
  1. The purple shows differences that have not become part of the final merge.
  2. The blue shows the code that’s become part of the final merge
  3. The grey shows where code (in this case it was blank lines with a space in them) was deleted and neither the “Theirs” version nor the “Yours” version was used.
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox