Exscriptor - new external script editor

The place to discuss scripting and game modifications for X³: Reunion.

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

Post Reply
Starcub
Posts: 82
Joined: Sat, 7. Apr 07, 23:39
x3tc

File Loading Problem

Post by Starcub » Wed, 6. Aug 08, 05:48

This looks like a really nifty program that obviously took some time to write, and good job on the documentation.

However, I have a problem in that none of the script files in my \t directory are loading (the files in \script load fine).

If I try to open an xml or pct file, the error log looks like this (I took the example directly from my error log file):

Code: Select all

Exception occurred: Could not read from J:\Program Files\EGOSOFT\X3 Reunion.XTM\t\443557.xml
Message: Data at the root level is invalid. Line 1, position 1.
Stack Trace:    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(TextReader txtReader)
   at X3_Script_Editor.Decompiler.openScript(String scriptName, String path)
Source: System.Xml
Target: Void Throw(System.Exception)

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

Exception occurred: Could not read from J:\Program Files\EGOSOFT\X3 Reunion.XTM\t\443557.xml
Message: Found but could not read from script file: J:\Program Files\EGOSOFT\X3 Reunion.XTM\t\443557.xml ('Data at the root level is invalid. Line 1, position 1.')
Stack Trace:    at X3_Script_Editor.Decompiler.openScript(String scriptName, String path)
Source: X3 Script Editor V3
Target: System.Xml.XmlDocument openScript(System.String, System.String)

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

Exception occurred: 
Message: Found but could not read from script file: J:\Program Files\EGOSOFT\X3 Reunion.XTM\t\443557.xml ('Found but could not read from script file: J:\Program Files\EGOSOFT\X3 Reunion.XTM\t\443557.xml ('Data at the root level is invalid. Line 1, position 1.')')
Stack Trace:    at X3_Script_Editor.Decompiler.decompile(String filename)
   at X3_Script_Editor.Editor.LoadFiles(String[] fileNames)
Source: X3 Script Editor V3
Target: X3_Script_Editor.Script decompile(System.String)
Any ideas?

Atrocious
Posts: 165
Joined: Mon, 15. May 06, 20:13

Post by Atrocious » Wed, 6. Aug 08, 10:19

Whimsy wrote:Which means poor V1.012 was probably the shortest lived version ever... :D
But still, will remain in my memories for being the first version to introduce for loops and easy array assignment. :wink:

Great work as usual :!:

@Starcub: This program isn't meant to open the files in the \t folder. They are text files with some xml tags, not scripts. I recommend using "Notepad 2" to open the text files.

bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate » Thu, 7. Aug 08, 15:52

I have been using the script editor with some good success, however I wanted to notify you of a couple of bugs and give some feature requests.

Probably someone already mentioned some of these but hopefully I can help you improve it.

Bug: saving a file throws an uncaught exception.
Steps to reproduce: open a new file, attempt to save it anywhere; or open an existing file and attempt to save it under a different name
Details:

Code: Select all

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not find file "C:\Program Files\Steam\SteamApps\common\x3 - reunion\scripts\new7.xml".
File name: "C:\Program Files\Steam\SteamApps\common\x3 - reunion\scripts\new7.xml"
   at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
   at X3_Script_Editor.Editor.menuSaveAs(Object sender, EventArgs e)
   at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.MenuItem.ShortcutClick()
   at System.Windows.Forms.Menu.ProcessCmdKey(Message& msg, Keys keyData)
   at System.Windows.Forms.Form.ProcessCmdKey(Message& msg, Keys keyData)
   at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
   at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
   at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
   at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
   at System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2407
    CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
X3 Script Editor V3
    Assembly Version: 1.0.3140.2291
    Win32 Version: 1.0.3140.2291
    CodeBase: file:///C:/Documents%20and%20Settings/Bunker%20Private/Desktop/x3scripter/Exscriptor/Exscriptor.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2407
    CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
RegexAssembly3_0
    Assembly Version: 0.0.0.0
    Win32 Version: n/a
    CodeBase: 
----------------------------------------
System.Xml
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Accessibility
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.573
    CodeBase: file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
Bug: textfield snaps to the top after most operations:
Steps to reproduce: have a textfield which is scrollable and, use 'redo' (already documented), insert a command with a doubleclick on the scrollfield. Some others too I think.

Bug: saving with errors is not allowed
Details: I'm reporting this as a bug because it means I cannot backup my work as I go which could result in data loss.

Bug: compile never finds referenced script files.
Steps to reproduce: Eg write

Code: Select all

=[THIS]->call script 'bunker.resupply.list.cmd':
The compiler always reports an error, though bunker.resupply.list.cmd.xml is existing in the same directory as the script. Perhaps it would be better to do a kind of include file organisation, where it will first search the pathname of the current file, and then the x3 script directory. For example, on Unix, when you include a file in C, it will by default search /usr/local/include/, then /usr/include so you get to override library files in this way.

Bug: after compile, the indentation is lost.
Details: not really a bug I suppose, but it would save time to run the indent procedure automatically after saving.

Bug: assignments are given extra values
Steps to reproduce:

Code: Select all

$var = 'string literal'
When loaded in X3, the line is (note the two single quotes at the end):

Code: Select all

$var = 'string literal' ''
Bug: syntax colouring is wrong for literal array indices
Steps to reproduce:

Code: Select all

$array[0] = 'something'

The '[0' will be blue, instead of just the 0. (I just noticed this is actually noted in the documentation anyway.)

Feature requests:
- Warn for undeclared variables, eg

Code: Select all

  $errorLine = 'An error!'
  sprintf: fmt: $errorln, etc <-- results in a compiler warning due to typeo.
  
- Search function for expressions
- Descriptions for each expression (also searchable). Would be nice if you could also search the descriptions of other scripts.

Please don't mistake my pedantry with ungratefulness; this is a whole lot better than the internal script editor! It's possible that if you open the source of your program, I might be able to help in a more meaningful way though actually I'm a C++ programmer and I only looked at windows.Forms long enough to go 'yuck' and get back to my Qt program :)

Thanks for your hard work.

Atrocious
Posts: 165
Joined: Mon, 15. May 06, 20:13

Post by Atrocious » Thu, 7. Aug 08, 16:58

bunkerprivate wrote: Bug: saving a file throws an uncaught exception.
Strange, I never had any problems saving files.
bunkerprivate wrote: Bug: compile never finds referenced script files.
I think it only doesn't find them when the file wasn't there when the Editor was started - so newly created files. Maybe refreshing X3 data helps (under "Tools")?

bunkerprivate wrote: Bug: after compile, the indentation is lost.
Details: not really a bug I suppose, but it would save time to run the indent procedure automatically after saving.
Actually indenting IS run after compile. Maybe you have some errors in the script, like missing ends etc? Because then the indenting doesn't work correctly, but after fixing these things, it should work again.

I hope whimsy will come online soon to give you guys some feedback. He was very quick at fixing things lately. :)

bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate » Thu, 7. Aug 08, 22:18

Actually indenting IS run after compile.
You're right. I made a typeo: I meant after saving.
...only doesn't find them when the file wasn't there when the Editor was started
Also right, but it would still be nice if it would search the directory for you; also I caused myself problems by saving outside of the script directory. Oh and for some reason, it seemed to open all my files again when I did the reload. At least I think it did. It might just not have been paying attention properly :/

Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 21:32
x3tc

Post by Whimsy » Fri, 8. Aug 08, 00:46

Okay, sorry for my absence! I started off trying to implement some new suggestions, then started trying to fix the new bugs that came up, and just ended up in a terrible mess that took much longer to sort out than I'd like. A lot of new bugs were introduced in V1.013 (and to a lesser extent, in V1.012 - like the compiler suddenly not highlighting errors any more). Remind me not to release new versions late at night in future... :oops:

Anyway, to business. Firstly, CS:
CS wrote:Do you think it might be possible to make file tabs (when you have multiple documents open) closable on double / middle click, just like in Firefox or Visual Studio?
Okay, this is done now - fortunately, it was one of the simpler changes. :wink:
CS wrote:From the same approach I think a 'compare scripts' function might be useful - that is, something like WinMerge, where you choose two files that will be displayed next to each other. Highlighting of differences would be awesome, but just having them on the screen right next to each other would be great.
I had to do a lot of this (though mostly looking at the codearray parts) when I was testing the compiler, so I agree that a comparator can be useful. I've introduced a relatively simple one that allows you to open another file to compare against the current script and highlight the differences in red. As I said though, it's not very sophisticated so the slightest difference is recognised. Also, it's a bit slow if you try to edit the code in the comparator (I've got something in mind to fix this though).
CS wrote:And one more convenience item: I'd like to be able to shift the dividing bar between the code and the command panes to the right, i.e. resize them in favor of the code view pane.
I thought this sounded like a good idea too. Therefore, I set about introducing the capability... and inadvertantly unleashed an army of problems which I've been battling ever since. To cut a long story short, you should now be able to resize the Script Editor part and even hide the Object List altogether if you want (via the View menu).

Unfortunately, the trade off for this seems to be that using Ctrl-Tab to switch forward through opened scripts no longer works (but oddly, Ctrl-Shift-Tab to cycle backwards still works). I have no idea why this is and I have been unable to work around it thus far.
Starcub wrote:However, I have a problem in that none of the script files in my \t directory are loading (the files in \script load fine).
As Enrico777 mentioned, the files in the "\t" directory aren't scripts (or at least shouldn't be, unless you've put some in there yourself). They're the language files that provide all the names of things etc. At some point I'll figure out a way of making sure that only script files can be opened but for now I'd just avoid opening those files. :wink:
bunkerprivate wrote:Bug: saving a file throws an uncaught exception.
Steps to reproduce: open a new file, attempt to save it anywhere; or open an existing file and attempt to save it under a different name.
This was because of the new script backup function I added - I forgot to check that the original file exists, so if you tried to save to a new file (rather than saving over an existing one) it would crash. Hopefully it's all fixed now.
bunkerprivate wrote:Bug: textfield snaps to the top after most operations
This one has plagued me for ages, and I still haven't thought of a good way to fix it. What I've done in this version is get it to snap back to the cursor location; this is better than looking at the top of the script each time, but unfortunately it usually puts the cursor right at the top of the window, which is still a bit disorientating.

The problem is caused by the incredibly ugly way I handle the syntax highlighting, which is basically to take the undecorated text from the box, add the RichText bits to it, and put it back in the box again, replacing everything that was there. Then I have to restore the cursor position but as you've noticed, this isn't the cleanest solution... If you have any bright ideas I'd be very grateful!
bunkerprivate wrote:Bug: saving with errors is not allowed
Details: I'm reporting this as a bug because it means I cannot backup my work as I go which could result in data loss.
This is actually intentional, would you believe it. My thinking is twofold: firstly, it (in theory) means that only valid script files are ever saved to disk, so X3 won't have any problems when it loads (dodgy script files can cause it to crash, as I discovered the hard way); secondly, I added in the save-to-txt capability for just this reason, so you can save a script as simple text without bothering the game or requiring a compile. You can then reopen the txt file and continue from where you left off.

Actually I could add in an autosave that works in this way - every five minutes, say, it would save a text file of the current script you're working on. Would that be useful, or is it a bit excessive?
bunkerprivate wrote:Bug: compile never finds referenced script files.
I almost wish I never introduced this capability, since it's never worked quite right! :D You were quite right, it was always checking in the /scripts directory. I've hopefully fixed it now - it should check the location of the current script first and then the /scripts directory second.
bunkeprivate wrote:Bug: after compile, the indentation is lost.
Didn't realise I'd forgotten that - I got into the habit of compiling then saving separately, so I hadn't noticed. Anyway, fixed now.
bunkerprivate wrote:Bug: assignments are given extra values
Okay, there's good news and bad news here. The bad news is that this wasn't just a cosmetic problem - the compiler was somehow generating an extra (invalid) string on the end of any expression ending with a string. So any file you've saved like this will have this problem - it's not a loading problem. The good news is that it's fixed now, so if you cut off the extra string, it shouldn't come back. :wink:
bunkerprivate wrote:Bug: syntax colouring is wrong for literal array indices
Yeah, as you noticed I've put this in the manual. I use regular expressions for the syntax highlighting but I've not managed to quote perfect it; in this case it was a trade off between numbers being highlighted correctly, but highlighted everywhere - in variable names, literals, and commands - or numbers being highlighted mostly in the right places but with the character to the left highlighted too. I chose the latter since it seemed less noticeable... :(
bunkerprivate wrote:Feature requests: - Warn for undeclared variables
Good idea. I've added this in now, so it will warn you if you try to use a variable before it's been assigned to. It might not be 100% perfect though, so we'll have to see.
bunkerprivate wrote:- Search function for expressions
- Descriptions for each expression (also searchable). Would be nice if you could also search the descriptions of other scripts.
I wasn't quite sure what you meant here - what do you mean by expressions in this context? And when you say descriptions of other scripts, can you be more specific? :?
bunkerprivate wrote:Please don't mistake my pedantry with ungratefulness; this is a whole lot better than the internal script editor! It's possible that if you open the source of your program, I might be able to help in a more meaningful way though actually I'm a C++ programmer and I only looked at windows.Forms long enough to go 'yuck' and get back to my Qt program
Not at all, you've been very helpful! Accurate & repeatable bug reports are worth their weight in gold. As for opening the source, I did consider putting it up on SourceForge or somewhere but frankly, the code is so embarrassingly awful in many places that I decided not to. :D I started it partly as a way of learning the ins and outs of C# (since there's no better way to learn a language than to use it), since I too mostly use C++, but this was nearly two years ago and the older parts of the code are abysmal - and that's after a complete rewrite at one point. Unfortunately, and as the number of bugs can attest, the interface is one of the oldest (and buggiest) parts of the program...

At some point, possibly to coincide with X3TC, I might try to overhaul the code (updating it to C# 3.0 at the same time, as it's much nicer - it even has templates now). In which case I might well open the source at the same time, but we'll see how things go.
bunkerprivate wrote:Oh and for some reason, it seemed to open all my files again when I did the reload.
Note to self - the Initialise() function is not to be called more than once. Okay, this should be fixed now... :oops:
Enrico777 wrote:I hope whimsy will come online soon to give you guys some feedback. He was very quick at fixing things lately.
Again, sorry for the delay! I have less spare time now than I did last week and these bugs/improvements took a lot longer than expected. Hopefully I haven't introduced quite as many bugs as I did with V1.013; my changelog entries are getting bigger, not smaller, which is worrying! So I'd be very grateful if anyone has time to verify the changes to make sure I've not broken anything else, and thanks once again to all those who pointed out the new bugs. :)

Incidentally, V1.014 is here. I'll update the main post next.

CS
Posts: 13
Joined: Sat, 30. Dec 06, 04:39

Post by CS » Fri, 8. Aug 08, 01:29

Wow, I really didn't think my suggestions would get realized quite so fast! Thank you very much. I'm happy to see that they didn't seem that useless to you, too. :)

bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate » Fri, 8. Aug 08, 05:35

Whimsy wrote:
bunkerprivate wrote:Bug: textfield snaps to the top after most operations
This one has plagued me for ages, ...
This is the only real usability issue with the program for me. I guess if I had a similar bug in Qt, I would simply connect a scroll position changed signal to a storing function and store the cursor position and scrollbar position. Then I could just call a function to restore those states after the syntax highlighting method (or whatever it is that snaps the textfield anyway). Bit of a hack and I don't think C# is anything like Qt, but meh.
Whimsy wrote:
bunkerprivate wrote:Bug: saving with errors is not allowed.
This is actually intentional, ...
I didn't realise you could export as text like that. My mistake. I have been using revision control and saving outside of the X3 directory as a matter of habit anyway (and my scripts crash X regardless^^)
Whimsy wrote: Actually I could add in an autosave that works in this way ...
My fingers tend to habitually find Ctrl+S every few seconds and that was the only functionality I was looking for. Perhaps there could be a checkbox to say 'allow saving broken scripts to scripts directory (warning: likely to crash X)', but since I save outside the scriptdir, I would not actually need it.
Whimsy wrote:... the compiler was somehow generating an extra (invalid) string on the end of any expression ending with a string.
FWIW, X3 still loaded the scripts ok, but the vars would evaluate to the empty string (unless that was my bug ^^).
Whimsy wrote: ...numbers being highlighted correctly, but highlighted everywhere...
Does C# have some kind of longest-match regexp parser? You can normally use them to get around that kind of issue. For example with FLEX in C. They are a lot harder to implement though, and FLEX is actually a program which generates C programs but it could be worth a look. It's a minor cosmetic thing for me tho.

<3 Qt again http://doc.trolltech.com/4.4/qsyntaxhighlighter.html ^^

Whimsy wrote:
bunkerprivate wrote:- Search function for expressions
I wasn't quite sure what you meant here ...
Since none of the expressions (ie, anything in the commands toolbar thing) are namespaced or documented, I find it quite hard to find things. It's probably because I am used to looking for module::function_name(param1, parm2) etc. but I find it impossible to remember whether it's 'add $x of $y to cargo bay' or 'add $x units of $y'. I'd like to be able to type in 'cargo bay' and have it list all the commands with something to do with the cargo bay. Probably a simple tagging database would work really well (so I might ask for 'cargo bay' and 'add' and it will come back with 'add $x units of $y'). Additionally, searching descriptions of scripts (and adding tags to them) would be useful (which of the move scripts is the right one?!?). Could be a bit ambitious though!

Impressively fast fixes and additions anyway, Whimsy! I've been messing around with .13 most of the day, but I'll certainly give .14 a go tomorrow.

Atrocious
Posts: 165
Joined: Mon, 15. May 06, 20:13

Post by Atrocious » Fri, 8. Aug 08, 15:08

Thanx for the fixes!

The warning for unassigned variables brought up new issues though:
Warnings:
- Variable minimum is being used on line 24 before being assigned to.
- Variable minimum is being used on line 25 before being assigned to.
- Variable minimum is being used on line 28 before being assigned to.
- Variable class is being used on line 40 before being assigned to.
- Variable race is being used on line 42 before being assigned to.
- Variable min_bay_size is being used on line 44 before being assigned to.
- Variable min_tc is being used on line 46 before being assigned to.
- Variable min_bay_size is being used on line 53 before being assigned to.
- Variable min_tc is being used on line 53 before being assigned to.
- Variable min_bay_size is being used on line 76 before being assigned to.
- Variable min_bay_size is being used on line 78 before being assigned to.
- Variable min_tc is being used on line 84 before being assigned to.
- Variable min_tc is being used on line 90 before being assigned to.
- Variable minimum is being used on line 123 before being assigned to.
- Variable minimum is being used on line 134 before being assigned to.
Compiled with no errors but 15 warnings
Those are all arguments, so they should be assigned outside. And in any case I will check them if they are set, which is still called as "use" by the compiler.


- Another thing: I tried to use \n in a string (though I dunno if that is possible in a X3 script anyway) and it made \par of it. It also removed the line break, so the next line moved one up. When I try to write behind the par, it disappears together with the backslash.

SSwamp_Trooper
Posts: 201
Joined: Sun, 29. Apr 07, 17:58
x3tc

Post by SSwamp_Trooper » Fri, 8. Aug 08, 17:01

hi, seems a good program but i'm getting a problem selecting the x3 directory and the scripts folder.

Error message:

Code: Select all

Failed to load X3 data:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Could not load X3 data - please check settings in Tools-->Options
I don't know whats causing it :?

EDIT: Btw if you want i can host it on my site aswell (x1tp.com)
Image

Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 21:32
x3tc

Post by Whimsy » Sat, 9. Aug 08, 02:04

bunkerprivate wrote:This is the only real usability issue with the program for me. I guess if I had a similar bug in Qt, I would simply connect a scroll position changed signal to a storing function and store the cursor position and scrollbar position.
That sounded like a good solution, so I went to implement it only to find I'd already done it (or most of it). Turns out the syntax highlighting does exactly that internally, except all the other automatic text modifications (e.g. undo, redo, which are all separate) didn't. Anyway, hopefully I've plugged the gaps so they should all restore their positions now, though it still flickers visibly.
bunkerprivate wrote:My fingers tend to habitually find Ctrl+S every few seconds and that was the only functionality I was looking for. Perhaps there could be a checkbox to say 'allow saving broken scripts to scripts directory (warning: likely to crash X)', but since I save outside the scriptdir, I would not actually need it.
There's another problem with saving broken scripts, though: the de/compiler loads its information from and saves it to the codearray of the script.xml file. If it cannot generate the code array due to errors, it cannot save it and thus cannot load it again next time. Hence the text file option.

What I've done is add a "quicksave to text" function (Ctrl-Q) which does no compile and does no backup copying and just puts the current script in a text file with the script's name. Hopefully it should allow you to keep your current code up to date without the problems associated with an .xml save. :)
bunkerprivate wrote:FWIW, X3 still loaded the scripts ok, but the vars would evaluate to the empty string (unless that was my bug ^^).
This is what frequently confuses me about the script engine in X3 - it seems to be very lax at times, particularly with expressions. Anyway, with any luck the problem is gone now...
bunkerprivate wrote:Does C# have some kind of longest-match regexp parser? You can normally use them to get around that kind of issue. ...
Qt looks quite fun - I may look into that next time I need a GUI! In this case though C# has some nice enough regexps in it but for the syntax highlighting I use multiple regexps, one for each colour basically. I haven't found an easy way of stopping a subsequent regexp from recognising something I've already dealt with in an earlier regexp (like a number occurring in a variable), though maybe I'm just being dense and missing the obvious (it's been known to happen).
bunkerprivate wrote:Since none of the expressions (ie, anything in the commands toolbar thing) are namespaced or documented, I find it quite hard to find things.
There are > 500 commands so it's definitely difficult to find things sometimes. :wink: But the script commands are all categorised already (General, Trade, Flight etc) and you can use the pseudo-autocomplete thingy in the right click context menu too to help narrow down the options. As for documenting them, that's a job in itself - check out the X2 MCSI Programmer's Handbook if you've not seen it already, as that covers a lot of info that's all still relevant.
bunkerprivate wrote:I'd like to be able to type in 'cargo bay' and have it list all the commands with something to do with the cargo bay.
I see what you mean now, but I'm a bit dubious about it - who would choose all the tag words, for example? Besides, most of the commands are fairly self-descriptive already, so searching for common tags would probably be equivalent to searching the text of the commands themselves (which is already possible).

Don't get me wrong, I'm all for making scripting easier - that's why I came up with the Exscriptor - but this sounds like it would take a fair bit of effort to create the initial tag database. Maybe in a future version when I've got more time I might be able to do something like this, we'll see. :)
bunkerprivate wrote:Additionally, searching descriptions of scripts (and adding tags to them) would be useful (which of the move scripts is the right one?!?). Could be a bit ambitious though!
The descriptions are all in readable text, so in theory any search utility that can read text in files could do this just by scanning the /scripts directory. Tagging them and categorising them would definitely be handy though (I've got > 1200 scripts in my folder, just scrolling through them takes long enough!) and maybe it could be like a preview browse mode (like you often have with image editors), where you can narrow down the choices using tags, click on a script and it'll load the name and description, say, and if that's the one you want then you can open it fully.

Again though I think this is something for a later version... :wink:
Enrico777 wrote:Those are all arguments, so they should be assigned outside. And in any case I will check them if they are set, which is still called as "use" by the compiler.
I knew I forgot something! I actually thought this myself - "Remember to include the arguments, you idiot!" - but then other bugs popped up and somehow I forgot about it and the scripts I tested didn't have any arguments, so I didn't notice. Anyway, it was easily fixed so hopefully you won't have any more problems now - thanks for spotting it!
Enrico777 wrote:Another thing: I tried to use \n in a string (though I dunno if that is possible in a X3 script anyway) and it made \par of it.
Yeah, this was a known bug in the syntax highlighting. The RichText tags all use backslashes so when you type one it thinks that it's part of an RTF command. Yet when I looked at it today I suddenly realised it was really easy to fix so now backslashes should work okay. :)
SSwamp_Trooper wrote:hi, seems a good program but i'm getting a problem selecting the x3 directory and the scripts folder. ... I don't know what's causing it
Neither do I, unfortunately - I've never seen that error before. Do you by any chance use a 64 bit version of Windows? I googled the error and it might be something to do with a 32/64 bit issue. Anyway, I've tried to fix it, so if that was the problem, hopefully it will work okay now. If not, open up the error log and see if it gives you any more information there - maybe I can track it down that way.
SSwamp_Trooper wrote:EDIT: Btw if you want i can host it on my site aswell (x1tp.com)
Thanks for the offer, but I think two sites is enough for now - at least unless Mediafire starts having problems again... Thanks anyway though! :)

Anyway, V1.015 available here. Hope it works okay this time... :D

bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate » Sat, 9. Aug 08, 05:45

Whimsy wrote:What I've done is add a "quicksave to text" function (Ctrl-Q) ...
Perfect!
Whimsy wrote: ... who would choose all the tag words, for example? ...
I was thinking of doing it myself actually and just have the facility of a database available. Anyway now I've thought about it, I think it would likely be better to make one of my own with an SQL database or something. I was looking for a more accurate replacement for Ctrl+F in the X2 programming guide really ^^!
The descriptions are all in readable text...
Hm I didn't notice that. I was looking at the pk files I think. I could easily enough make a shell script to search the descriptions. I noticed a zlib dll in there somewhere; are the pck files just gzipped? If they are, a shell script is trivial.
now backslashes should work okay. :)
Another really handy one.

--

Well you beat me to it by releasing a patch while I spent the day testing the old version ^^! But I'll list some issues I found anyway. I have no time now, but I'll edit this post tomorrow if I find they've been fixed.

Blockers (stop me testing the editor):

- Interrupt points seem to be ignored by the editor

Example:

Code: Select all

  * All OK:
  @ = wait 300 ms
  = @ wait 300 ms
  = wait  @ 300 ms
  

- Related: it seems the @ always disappears when loading scripts.

- Parameter checking is faulty in odd ways. This took a *long* time to
track down! Called script parameters only seem to be valid if the
script is called with less than or equal to the number of arguments to
the current script.

Example (in bunker.resupply.travel.suppliedjump):

Code: Select all

  * ok iff bunker.resupply.travel.suppliedjump has >= 1 argument
  $success = [THIS]->call script 'bunker.resupply.travel.squadjump' : arg0=$solSec
  * ok iff bunker.resupply.travel.suppliedjump has >= 3 arguments (script really required one)
  $success = [THIS]->call script 'bunker.resupply.travel.squadjump' : arg0=$solSec arg1=$junk  arg2=$junk
  

I thought that there was a workaround for this by saving both the caller
and the callee in the script directory, but it seems that actually doesn't
always work (or maybe it was a fluke it worked one time...) so this one's
a fairly major blocker.

Critical (data loss, crash):

- Bracketed arithmetic expressions are not stored (or maybe read) properly:
Example:

Code: Select all

  $sectorDistance = ( $xdist * $xdist ) * ( $ydist * $ydist )
  

Save, then load it. The code is now missing the first close bracket:

Code: Select all

  $sectorDistance = ( $xdist * $xdist  * ( $ydist * $ydist )
  
Workaround is obviously to use temporary variables. I only managed to reproduce
this once or twice before it started working again. Putting different
bracketed expressions nearby seemed to affect the output (when it was reproducable).
The compiler will never complain of unbalenced brackets, even if you type in
a bad expression, and the brackets were also wrong for expressions where they actually
do something (eg $r = $x * ($u - $v).). As I noted at the start, I've not had a
chance to test whether the X3 engine can handle this kind of thing but it seems
likely to cause a parser crash or worse: silent data loss.

This may be a regression, I'm not positive. I wrote this script in .13 and never
noticed the bug.

Normal (loss of function):
- Declaration checker doesn't seem to check arguments which are passed to scripts.
Example:

Code: Select all

  * No error:
  =[THIS]->call script 'a.real.script': $undefined
  
Minor (basically just here for completeness; none of these bother me at all):
- I can't Ctrl+V/C the 'script name' etc. fields any more. Rightclick->copy/paste works tho.

- Textfield 'flickers' (already noted) and sometimes it places the cursor a
few places away from where you last were. Still a good step forward, though.

- When you load a script, it indents with three spaces. Selecting indent
make it two

- Removing and adding script arguments doesn't set the script as altered any more (ie put the * in script's tab title). Regression I think.

- File->exit does nothing.

Sorry if you already sorted these but I wrote them in advance and didn't want it to go to waste!

P.S if ayone's still reading by this point, if you get errors like 'error parsing entity name...' then it means someone has written an ampersand in a textfile and forgot to use a proper entity (or just wrote a wrong entity). Just like in HTML, '&' must be written like '&' - note the semicolon at the end. So just go into the file and change it to a properly valid entity. Google for more entity codes if you need them. I know that XTM and QRF scripts have this error.

Example in XTM file 447215.xml, line 69

Code: Select all

	%sThe total R&ampD cost before we can [i](rest of line ommitted...)[/i]
Should have an added semi-colon:

Code: Select all

	%sThe total R&D cost before we can [i](rest of line ommitted...)[/i]

SSwamp_Trooper
Posts: 201
Joined: Sun, 29. Apr 07, 17:58
x3tc

Post by SSwamp_Trooper » Sat, 9. Aug 08, 11:53

Whimsy wrote:
SSwamp_Trooper wrote:hi, seems a good program but i'm getting a problem selecting the x3 directory and the scripts folder. ... I don't know what's causing it
Neither do I, unfortunately - I've never seen that error before. Do you by any chance use a 64 bit version of Windows? I googled the error and it might be something to do with a 32/64 bit issue. Anyway, I've tried to fix it, so if that was the problem, hopefully it will work okay now. If not, open up the error log and see if it gives you any more information there -
maybe I can track it down that way.
Yeah i am using Vista 64bit
Whimsy wrote:
SSwamp_Trooper wrote:EDIT: Btw if you want i can host it on my site aswell (x1tp.com)
Thanks for the offer, but I think two sites is enough for now - at least unless Mediafire starts having problems again... Thanks anyway though! :)
Fair enough, you can pm me if you ever need another host :)
Image

bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate » Sun, 10. Aug 08, 01:31

OK, as promised. All of the previous post's issues are confirmed in .015, but I managed to glean a bit more information.

Blockers (stop me testing the editor):

-- More on script parameters checking: the rule
if ${called script argc} <= ${current script argc} then called script is valid
only applies to script argc when the script was loaded. Example:
- start a new script
- make a script call with > 1 arg => error.
- add a new argument to the script we started
- comment script call and save script
- reload script and uncomment line
- compile => success!

Critical (data loss, crash):

-- Ctrl-Q does not appear to overwrite a previous quicksave

Serious (app is unusable)

-- Parser compatability problem:
- I wrote a script with the comments (noted later) with exscriptor
- load the script with X3
- save it with X3
- load it with exscriptor:
Load failed! Found but could not read from script file: C:\Documents and Settings\Bunker Private\Desktop\a.a.a.a.a.a.a.bunker.test.wont.load.xml ('Found but could not read from script file: C:\Documents and Settings\Bunker Private\Desktop\a.a.a.a.a.a.a.bunker.test.wont.load.xml (''If' is an unexpected token. Expecting white space. Line 139, position 20638.')')

Removing these lines fixed it:

Code: Select all

  * "If object ptr is null, then it is a global script"
  * "If it is null OR the ptr != [THIS], then it is a fork."
  
It didn't occur to me to test whether X3 will actually let you write a comment like that.

Normal:

-- I've tried to reliably reproduce this since .013 but I can't so I'll just report
it: sometimes the script name etc. fields will disappear after doing some loads
and reloads.

Minor (cosmetic, typeo etc, or easy work around)

-- When you click on a tab name, it doesn't focus the text area, so if you
click on a tab, do ctrl+c, then the selected text won't be copied.

-- Running a compile causes the script to be altered (the * appears in the
tab name). Indent does as well (but maybe that's necessary?)

-- When writing null in a comment, the rest of the line is highlighted.

-- writing a hash followed by a number causes the same problems as used to be
with backslash.

Seems pretty good anyway. We're definitely getting to the weird edge cases now.

User avatar
Moonrat
Posts: 1082
Joined: Sun, 20. Apr 08, 16:20
x4

Post by Moonrat » Sun, 10. Aug 08, 01:41

Great tool. I'm finding the SE inside X3 a return to the stone age and when I saw your offering I thought wey hay !!

Having a problem however on compiling for example...

Compile errors detected:
- Error on line 271 - Calling a script with the wrong number of parameters
- Error on line 273 - Calling a script with the wrong number of parameters
Compile failed....plus 3 other lines as above

0269 if $command != {COMMAND_STATION_REBUILD}
0270 skip if $setdobjc == {Sector}
0271 START $ship->call script 'plugin.escort.moveto' : arg1=$ship arg2=$dsec arg3=$destination
0272 skip if $setdobjc != {Sector}[/color]
0273 START $ship->call script 'plugin.escort.moveto' : arg0=$ship arg1=$dsec arg2=$anull

The above called script ''plugin.escort.moveto' does appear to have 3 parameters as shown by Exscriptor. The calling script does not have any parameters and so it kind'a looks like the bug reported by bunkerprivate (I think). If I hack the above code and remove the three passed arguments it compiles Ok....?

Thanks in advance

Post Reply

Return to “X³: Reunion - Scripts and Modding”