[PROGRAM] X-Studio 2 Script Editor [Beta III : 30th Mar 14]

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

[PROGRAM] X-Studio 2 Script Editor [Beta III : 30th Mar 14]

Post by mr.bear » Tue, 25. Mar 14, 21:41

[ external image ]

Script and Language file editor for X² The Threat, X³ Reunion, X³ Terran Conflict and X³ Albion Prelude.
See the following post for an overview of the new features.

Beta Information
  • This is a beta version of X-Studio II. I've completed all of the basic features: script editor, language file editor etc. and I've tested the new compiler especially heavily, but with such a large program there are too many features for me to test alone. If you would like to download a copy, play about with it, and report any problems you find I'd be really grateful!

    Nearly all of the functionality of X-Studio 1 is present in X-Studio 2, the major difference being the 'File System Browser' is gone, and I haven't added a viewing window equivilent to the 'Strings' and 'Local/Global Variables' tabs of the X-Studio 1 script properties window.
Downloads
  • LATEST RELEASE: Beta III
    RELEASE DATE: 30th March 2014


    [ external image ]


    SUPPORT FILES: Microsoft 2013 C++ Redistributable
    INSTRUCTIONS:
    Necessary for all users. Select the x86 download, even if you have an x64 computer

    [ external image ]


    SUPPORT FILES: Microsoft XML 6 Redistributable
    INSTRUCTIONS:
    Only necessary for WinXP users without service pack 3

    [ external image ]
Instructions
  • Extract the archive to any folder and run X-Studio2.exe. You may need to download the C++ redistributable file above.
    Goto 'Edit' menu and 'Preferences', enter your game data folder
    Goto 'Game Data' menu and click 'Reload'
Source Code
  • LATEST RELEASE: Beta III
    RELEASE DATE: 30th March 2014


    [ external image ]

    Instructions:
    X-Studio is written in C++ 11 and MFC using Visual Studio 2013.
Contribute Latest changes available here Latest Updates
  • X-Studio II : Beta IV : TBA
    • Fixed: 016: Program is unable to load/save scripts using hard-coded sectors
    • Fixed: 015: Program attempts to load scripts dragged onto main window when no game data is loaded
    • Fixed: 014: No support for loose files that use the X3:TC encryption scheme


    X-Studio II : Beta III : 30th March 2014
    • Fixed: Compiler bug in the 'foreach' macro


    X-Studio II : Beta II : 30th March 2014
    • Variable argument commands: create new array, sprintf
    • Macro commands: dim, for, foreach
    • Status bar indicator of loaded game data version
    • Subroutine indentation
    • Implemented find & replace on scripts in project
    • Add Compiler preference to enabling/disabling macro commands
    • Fixed: 006: HOME key in the script editor doesn't scroll far enough left to display line numbers
    • Fixed: 007: RichEdit shortcut keys can be used to right/centre align script editor text
    • Fixed: 010: Changing the id/language property of X3R language files renames document using X3TC naming scheme
    • Fixed: 011: Script editor variables drop-down isn't updated after modifying arguments


    X-Studio II : Beta I : 25th March 2014
    • Initial beta release
Incomplete/Missing Features
  • [COMPLETE] • Macro commands eg. for, dim, etc
    • Code analysis algorithm for distinguishing script variables from constants
    • Script argument re-ordering refactoring
    • Properly position the caret in the script editor after starting a new line
    [COMPLETE] • Line numbers of labels in the script editor 'current scope' drop-down
    • Tooltips for game objects (ships/stations/wares etc.)
    [COMPLETE] • Support for variable arguments in 'create new array' and 'sprintf' commands
    [COMPLETE] • Subroutine indentation
    • Interrupt symbols
    • Preferences option for case insensitive labels/variables
    • Preferences option for disabling highlighting of script constants
    • Properties listing of strings and local/global variables used by a script
    • Ability to customize menus and shortcut keys
    • Supply default parameter values for script commands inserted from the 'Commands' window
    • Intellisense-style argument info when typing a script-call command
    [COMPLETE] • Status bar indicator of loaded game data version
    [COMPLETE] • Find&Replace on scripts within active project
Latest Feature Requests
  • [IN PROGRESS] Support for strings containing apostrophes
    [DECLINED] Support for relative paths in project files
    [COMPLETE] Ability to view differences between multiple scripts
    [COMPLETE] Ability to re-arrange document tabs
    [COMPLETE] Option to change the size of text in helper windows
    [COMPLETE] National symbol input in the script editor
    [COMPLETE] Compatible with scripts created using the ESCE editor
Latest Known Bugs Latest issues available here
  • 016. [COMPLETE] Program is unable to load/save scripts using hard-coded sectors
    015. [COMPLETE] Program attempts to load scripts dragged onto main window when no game data is loaded
    014. [COMPLETE] No support for loose files that use the X3:TC encryption scheme
    013. [IN PROGRESS] Find&Replace on 'Script Folder' or 'Project Files' doesn't search open documents
    012. [IN PROGRESS] Wrong icon displayed in script command tooltips
    011. [COMPLETE] Script editor variables drop-down isn't updated after modifying arguments
    010. [COMPLETE] Changing the id/language property of X3R language files renames document using X3TC naming scheme
    009. [IN PROGRESS] Missing superscript parameter ordinals in script-editor command tooltips
    008. [IN PROGRESS] Square brackets in script-editor tooltips appear as [[, ]]
    007. [COMPLETE] RichEdit shortcut keys can be used to right/centre align script editor text
    006. [COMPLETE] HOME key in the script editor doesn't scroll far enough left to display line numbers
    005. [IN PROGRESS] Script editor caret not indented/outdented properly when starting new line after 'if/while' or 'end' etc.
    004. [IN PROGRESS] Language strings/pages copied to clipboard produce XML with unresolved character entities
    003. [IN PROGRESS] Cannot load language files with page IDs higher than 9999 that aren't prefixed 30, 35, or 38
    002. [IN PROGRESS] Language file strings with multiple paragraphs, where the last paragraph is not left-aligned, sometimes have their final paragraph left-aligned
    001. [IN PROGRESS] Script editor auto-complete is highlighting the match for the last key pressed
Mr. Bear

UPDATED: 2nd June 2014
Last edited by mr.bear on Sat, 14. Jun 14, 12:49, edited 42 times in total.
Rapunzel, Rapunzel, let down your bear...

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Tue, 25. Mar 14, 21:42

Main Features
  • NORMAL EDITING FEATURES

    • Problems like undo/redo in the original X-Studio have been solved - cut/copy/paste undo/redo work as expected.

    CODE REFACTORING

    • Rename refactoring is available for variables and labels within a script
    TODO Parameter re-ordering refactoring
    TODO Rename refactoring for string IDs and local/global variables

    [ external image ]

    VERSION CONTROL

    • All scripts in a project are under automatic version control.
    • You can manually commit your changes and/or commit on save, and revert to a previous version at any time.

    [ external image ]

    DIFFERENCE VIEWER

    • You can view differences between the current version of your script and previously commited versions.

    [ external image ]

    LANGUAGE FILE EDITOR

    • New language file editor mode for editing the formatting tags of language strings manually.
    • Formatting tags, string insertion markers {17,2232}, and MD code variables {param@ship} are all highlighted.
    • Normal editing features like cut/copy/paste all work as expected.
    • You can copy strings/pages into a text editor and X-Studio will generate the necessary XML

    [ external image ] [ external image ]

    GLOBAL FIND & REPLACE

    • Find & replace is available in a visual studio like manner, it works on text selection, entire document, all open documents, all project files, or all scripts in your script folder.
    • Regular expressions are supported

    [ external image ]

    NAMED SCRIPT ARGUMENTS

    • All script calls now use named arguments like the 'call script' command, instead of arg1, arg2, arg3 etc.
    • The 'create new array' and 'sprintf' functions now support variable arguments.

    [ external image ]

    INTELLISENSE-STYLE COMMENTING

    • Hovering over a label will display a tooltip showing the comments (if any) describing the label definition

    [ external image ]

    ADVANCED COMPILER

    • Syntax errors in commands are now explicitly highlighted, instead of the entire line. There are several compiler options regarding type checking of script-call arguments.
    • All variables and labels are now case sensitive, with a compiler option to use case insensitive variables if you wish.
    • C++ style operators: ||, &&, % are now supported in place of X operators if you wish.

    [ external image ]

    DOCUMENT TEMPLATES

    • Various document templates are available to get you started with common tasks

    [ external image ]

    CUSTOMIZATION

    • Document templates, Code Tooltips, Command Syntax are all defined by .xml files in the 'Data' subfolder, so they can be customized and shared by forum users.
    • Eventually this will lead to a 'complete' community-based MSCI reference for the remaining commands not documents by X-Studio / MSCI reference.

    DEBUG CONSOLE

    • X-Studio is a complex program that deals with user-edited data that is prone to errors . If and when it does go wrong there is a new easy to read console to replace the (horrible) X-Studio 1 feature. This is automatically saved in an RTF file called Console.rtf, created in the program folder.

    [ external image ]
Changes to Commands
  • DISCARDING THE RETURN VALUE

    The most obvious change in X-Studio II is the syntax of commands when discarding the return value - it is no longer necessary or allowed to add the leading '='

    Code: Select all

    = [PLAYERSHIP] -> add 1 units of {Disintegrator Rifles}

    VARIABLE ARGUMENT COMMANDS

    The following commands now accept variable arguments ie. you can omit the last four/five parameters and X-Studio II will automatically insert nulls.
    All variable arguments commands use the same syntax: the final colon operator marks the beginning of the optional arguments.

    dim: (macro)
    sprintf:
    create new array:
    call script $1 :
    call named script: script=$2, $3, $4, $5, $6, $7
    launch named script: task=$1 scriptname=$2 prio=$3, $4, $5, $6, $7, $8
    begin task $2 with script $1 and priority $3: arg1=$4o arg2=$5x arg3=$6y arg4=$7z arg5=$8a
    interrupt with script $1 and prio $2: arg1=$3 arg2=$4 arg3=$5 arg4=$6
    interrupt task $2 with script $1 and prio $3: arg1=$4 arg2=$5 arg3=$6 arg4=$7

    Code: Select all

    $sz = sprintf: pageid=$PAGE textid=65 : $i, null, null, null, null
    can now be written simply as:

    Code: Select all

    $sz = sprintf: pageid=$PAGE textid=65 : $i
    NOTE: You cannot use this feature to add extra arguments, eg. if the previous maximum was 5 arguments then it is still 5.


    NAMED ARGUMENTS IN SCRIPT-CALL COMMANDS

    All script-call commands now use named arguments like the call script command, and as shown above their arguments are optional. Any arguments you do not supply to scripts will be automatically saved as null.

    Code: Select all

    interrupt with script 'fight.monster' and prio 1: arg1=$ship arg2=[TRUE] arg3=null arg4=null

    Code: Select all

    interrupt with script 'fight.monster' and prio 1: target=$ship display=[TRUE]

    MACRO COMMANDS

    Four macro commands from X-Studio are currently supported: dim, for, and foreach. They have been slightly renamed from X-Studio 1 but their functionality remains the same.

    Code: Select all

    dim $array = 1, 2, 3, 4, 5
    
    (array) = array alloc: size=(size)
    Generates n: (array)[n] = (value)

    Code: Select all

    for $i = 1 to 10 step 1
    
    (iterator) = (inital_value) ± (step_value)
    while (iterator) less/greater (final_value)
    Either: (iterator) = (iterator) ± (step_value)
    Either: inc/dec (iterator)
    NOTE: The use of inc/dec is an optimization that X-Studio 1 does not recognise, so X-Studio 1 will not automatically insert a 'for loop' macro saved in X-Studio 2.

    Code: Select all

    foreach $item in $array
    
    (iterator) = size of array (array)
    while (iterator)
    dec (iterator)
    (item_iterator) = (array)[(iterator)]

    Code: Select all

    foreach $item in $array using $iterator
    
    (named_iterator) = size of array (array)
    while (named_iterator)
    dec (named_iterator)
    (item_iterator) = (array)[(named_iterator)]

    CASE SENSITIVE VARIABLES

    Variable and label names are now case sensitive, unlike X-Studio 1.


    RANDOM NUMBERS + GET INDEX OF ... IN ARRAY

    X-Studio 1 internally adjusted the offset parameter in the following commands to account for the -1 or +1 in the original command text.
    This caused confusion (and was just a bad idea generally) so X-Studio 2 doesn't adjust your values, but the command syntax is same (so be aware)

    Code: Select all

    (Egosoft) random value from 0 to 10 - 1
    (X-Studio 1) random value from zero to 9
    (X-Studio 2) random value from zero to 10
    This example returns a random value between 0 and 9. (half open range)

    Code: Select all

    (Egosoft) random value between 1 and 10 - 1
    (X-Studio 1) random value between 1 and 9
    (X-Studio 2) random value between 1 and 10
    This example returns a random value between 1 and 9. (half open range)

    Code: Select all

    (Egosoft) get index of <var> in array <var> offset=5 + 1
    (X-Studio 1) get index of <var> in array <var> offset=6
    (X-Studio 2) get index of <var> in array <var> offset=5
    This example searches for an element starting at offset 6


    START, MOD, OPERATORS

    The start keyword must now be lower case like other keywords, whereas the MOD operator must be upper case like the other operators.
    The goto label has been replaced simply with the goto keyword, so labels can be accessed with either goto or gosub
    C++ operators can be used in place of AND, OR, MOD if you wish.
Customization
  • CUSTOM COMMANDS

    The command syntax and custom syntax files from X-Studio has been depreciated in favour of a new XML file in the 'Data' subfolder. There is an 'Import' command in the File menu for importing your old custom syntax file, it will automatically upgrade it to the new format.

    The new format allows several new features:
    you can define your own parameter types
    you can specify which parameters are script-calls, which enables the GUI menu item 'Open Target Script'
    you can specify which parameters are string/pageIDs, which enables the GUI menu item 'View String'
    you can define commands with variable arguments

    See the comments in CommandSyntax.xml for more details

    NOTE: If you change and distribute this file, make sure you update the 'title' and 'version' properties, which are displayed to the user when the program loads.

    CUSTOM TOOLTIPS

    The command and script object tooltips for X-Studio are now stored in the 'Descriptions.xml' file in the 'Data' subfolder. I have documented about 60% of the commands myself, the remainder are commented in the appropriate place. There is a keyword system to maintain uniform formatting throughout the file, and a macro system to insert prefabricated blocks of text.

    See the comments in Descriptions.xml for more details

    NOTE: If you change and distribute this file, make sure you update the 'title' and 'version' properties, which are displayed to the user when the program loads.
Last edited by mr.bear on Sun, 8. Jun 14, 19:40, edited 13 times in total.
Rapunzel, Rapunzel, let down your bear...

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Tue, 25. Mar 14, 21:43

*reserved*
Last edited by mr.bear on Sun, 30. Mar 14, 03:58, edited 2 times in total.
Rapunzel, Rapunzel, let down your bear...

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Tue, 25. Mar 14, 21:50

omg omg omg omg omg :D
/hugs mr.bear
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Tue, 25. Mar 14, 21:57

Amazing feature set.

And I thought that X-Studio (1.x) was perfect. Or nearly so. :)

Thanks!
  • (You might want to make a post on the old thread to let Watchers know that you made this new thread.)

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Tue, 25. Mar 14, 22:06

hi guys,

let me know how your experiments go! :) I've just spent two hours editing that post though, so I'm taking a break.

mr.bear

(That's a good idea Bullwinkle, I'll do that later)
Rapunzel, Rapunzel, let down your bear...

User avatar
TECSG
Posts: 1604
Joined: Tue, 17. Feb 04, 22:06
x3tc

Post by TECSG » Tue, 25. Mar 14, 23:14

Hi,

I'm getting the error "The program can't start because mfc120u.dll is missing from your computer. Try reinstalling the program to fix this problem."

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Tue, 25. Mar 14, 23:22

hi TECSG,

sorry I forgot to post a link to the latest C++ redistributable from microsoft. I've added a link beneath the program download.

mr.bear
Rapunzel, Rapunzel, let down your bear...

User avatar
jack775544
Posts: 1277
Joined: Tue, 13. Dec 11, 08:27
x4

Post by jack775544 » Tue, 25. Mar 14, 23:39

Looks amazing mr.bear. I think uni lectures today are going to take a back seat while I give his ago

I see you also made the change to C++, I'm sure leaving C behind was too hard :).
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Tue, 25. Mar 14, 23:49

i thank god every day that i'll never have to use C again :)

C++ 11 has some really great features, I really like it, and development has been really speedy - I only started at christmas and i'm almost finished.

the source code is so accessible/documented that someone else can takeover one day if necessary.

stay in school :)
mr.bear
Rapunzel, Rapunzel, let down your bear...

Shush
Posts: 244
Joined: Sat, 6. Dec 03, 16:21
x4

Post by Shush » Wed, 26. Mar 14, 00:44

Hey mr.bear,

There are only a couple of issues that are impeding the import of my projects from X-Studio to X-Studio II.

1) "dim $test = 0, 1, 2, 3" fails with: Unexpected token in command '$test'
Is this related to?:
• TODO The 'alloc array' and 'sprintf' functions now support variable arguments.

2) " = null-> call script 'plugin.LIFE.ships.leveled.reset' :" fails with: Unable to parse command '= null-> call script 'plugin.LIFE.ships.leveled.reset' :'
Removing the "=", i.e. "null-> call script 'plugin.LIFE.ships.leveled.reset' :" allows the command to parse and the file to compile.
This exact same issue can be seen with similar commands, i.e. "= wait 2000ms"

I'm loving the feature set of X-Studio II so far, keep up the great work.

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Wed, 26. Mar 14, 02:17

hi shush,

1) i completely forgot to mention that I haven't implemented macro commands yet, that's why 'dim' doesn't work!

2) i've changed the syntax of the language slightly so it's now illegal to preceed a command with '=' (I found that jarring)
if you don't want to keep the return value you should write the command without the leading '='

another minor change is 'goto label restart:' is now just 'goto restart:'

i think that's all the changes i made...

mr.bear

EDIT: another change is that variables highlighted in yellow are constants. [but algorithm for identifying them is simple/crap at the moment]
Rapunzel, Rapunzel, let down your bear...

albazeus
Posts: 76
Joined: Fri, 21. Feb 14, 17:21
x3ap

Post by albazeus » Wed, 26. Mar 14, 15:00

Hi mr.bear, thanks for this programm.

I'm new to scripting, so I might say something obvious but:
you have to download the 32bit version of the Visual C++ Redistributable Packages, even if your PC is 64bit.

I thought the choice was based on the architecture of your PC.

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Wed, 26. Mar 14, 15:09

mr.bear wrote:2) i've changed the syntax of the language slightly so it's now illegal to preceed a command with '=' (I found that jarring)
if you don't want to keep the return value you should write the command without the leading '='

another minor change is 'goto label restart:' is now just 'goto restart:'
While I understand the reasons for your changes, can XS2 edit (and save) XS1 scripts without having to update all of the changed syntax?

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Wed, 26. Mar 14, 15:58

albazeus wrote:Hi mr.bear, thanks for this programm.

I'm new to scripting, so I might say something obvious but:
you have to download the 32bit version of the Visual C++ Redistributable Packages, even if your PC is 64bit.

I thought the choice was based on the architecture of your PC.
thanks albazeus, I'll add a note to the download link.
(it's because x-studio 2 is 32-bit, even when running on a 64-bit computer)

bullwinkle wrote:While I understand the reasons for your changes, can XS2 edit (and save) XS1 scripts without having to update all of the changed syntax?
hey bullwinkle,
yes it's completely compatible. all the syntax you see is actually an illusion, none of it is saved to the scripts. you would only have a problem if you copy/paste code from XS1 or eXscriptor into XS2. then you'd have to remove all the '=' signs manually.
Rapunzel, Rapunzel, let down your bear...

Shush
Posts: 244
Joined: Sat, 6. Dec 03, 16:21
x4

Post by Shush » Wed, 26. Mar 14, 16:15

mr.bear wrote:1) i completely forgot to mention that I haven't implemented macro commands yet, that's why 'dim' doesn't work!
Assuming it's trivial for you to do, (reuse of X-Studio code), is there any chance you can prioritise the macro stuff. I use way too many dim statements in way too many scripts for me to be able to effectively beta test X-Studio 2.

If not I can wait.

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Wed, 26. Mar 14, 17:24

i'll make it a high priority, but i haven't worked out how i'm going to do them yet - so it'll take a few days. [the compiler is quite different from XS1]

mr.bear
Rapunzel, Rapunzel, let down your bear...

User avatar
jack775544
Posts: 1277
Joined: Tue, 13. Dec 11, 08:27
x4

Post by jack775544 » Thu, 27. Mar 14, 07:59

I was just downloading the latest version and then i realised I have a couple of copies of X-Studio on my computer http://i.imgur.com/pLZpWAj.jpg?1 :D
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube » Fri, 28. Mar 14, 09:21

Hey! Remember this file?

Custom.Syntax.txt


This thing looks good, but I can't test it yet due to the above. ;) Keep it up, Mr. Bear.

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Sun, 30. Mar 14, 03:53

jack,
aww, it's a like a museum of X-Studio in there :)

litcube,
I've changed the format of the syntax file completely so i've provided an Import command in the file menu you can use to upgrade the file, and optionally merge commands loaded from the stock 'CommandSyntax.xml' into it.

X-Studio II loads just the one command syntax file btw, there's no 'CustomSyntax.xml' file. I haven't been able to test it, but if you select 'Yes' to the merge when importing then X-Studio should generate you a whole new syntax file with both the stock and your custom commands. If you don't want that then select 'No' to merge.

mr.bear

----------------------------------------------------------------------

Preceeding messages relate to Beta I

----------- BETA II RELEASED -----------

Following messages relate to Beta II

----------------------------------------------------------------------

• Variable argument commands: create new array, sprintf
• Macro commands: dim, for, foreach
• Status bar indicator of loaded game data version
• Subroutine indentation
• Implemented find & replace on scripts in project
• Add Compiler preference to enabling/disabling macro commands
• Fixed: 006: HOME key in the script editor doesn't scroll far enough left to display line numbers
• Fixed: 007: RichEdit shortcut keys can be used to right/centre align script editor text
• Fixed: 010: Changing the id/language property of X3R language files renames document using X3TC naming scheme
• Fixed: 011: Script editor variables drop-down isn't updated after modifying arguments


mr.bear
Rapunzel, Rapunzel, let down your bear...

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”