Exscriptor - new external script editor

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

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

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

Post by Whimsy »

Litcube wrote:Whimsy, still using your product of awesomeness.

Anyway to stop the scrolling from jumping around when either compiling, adding a new command from the context menu, or saving?

I code in VS, and I've used MFC, so I know how much a PITA it is dealing with MFC's scroll settings, but I do know it's possible to keep the screen/scroll locked when refreshing the data->view.
Glad you're still finding the Exscriptor useful. :wink:

As for your question, there are ways to fix the problem, but (as far as I know) not without completely changing the way I do the syntax highlighting. One of the reasons I made the Exscriptor was as a way of learning C#, and unfortunately I made a lot of bad choices along the way; the syntax highlighting was one of them. It works by using a RichTextBox and changing the underlying RTF, then accessing the otherwise inaccessible scroll bars using Win32 messages to reset the position. The only way to stop it jumping is to turn the highlighting off in the options. :(

V2 fixes the issue, but I don't know if I'll ever get round to finishing it...
JoeTheDestroyer
Posts: 36
Joined: Wed, 14. May 08, 01:40
x3tc

Post by JoeTheDestroyer »

Attempting to run the Exscripter command line compiler on Win7 x64 (and probably Vista/XP x64 also) gives the following error:

Code: Select all

Loading X game data...
Error - Could not initialise X game database: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
The error code indicates that ExscriptCmd is running as a 64bit program and attempting to load a 32bit dll (or vice versa).

The workaround is to use the "corflags.exe" utility from the .NET 2.0 SDK (or recent Windows Platform SDKs) to mark the program to run as 32bit only. Like so:

Code: Select all

CorFlags.exe /32BIT+ ExscriptCmd.exe
Probably not something many people will run into, but I thought I'd put this out there incase anyone else has the same problem in the future.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

I run this on win7 64 on an i7 and it runs fine (I used to run this on winxp 32 and 64 on a amd 64 and it worked fine back then too)
There should be nothing wrong with running 32 bit things on 64 bit machines (thou running 16 on 64 will fail, but will work on 32)

I do not need to do anything special to make it run, it just works
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Hi whimsy, I'm having a very unique problem at the moment

I'm trying to create an xml deserializer in the x3, and I whilst making the script, I needed to do something like this:

$string = '<'
But doing that in the exscriptor causes the following issue:
(When you try to open it, I suspect it's because it does not convert it to the <)
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
X3_Script_Editor.XSE_FileReadErrorException: Error while trying to open script file: C:\Program Files (x86)\EGOSOFT\X3 Terran Conflict\scripts\Mod\svc z\lib.deserialize ('Found but could not read from script file: C:\Program Files (x86)\EGOSOFT\X3 Terran Conflict\scripts\Mod\svc z\lib.deserialize ('Name cannot begin with the ''' character, hexadecimal value 0x27. Line 15, position 83.')') ---> X3_Script_Editor.XSE_FileReadErrorException: Found but could not read from script file: C:\Program Files (x86)\EGOSOFT\X3 Terran Conflict\scripts\Mod\svc z\lib.deserialize ('Name cannot begin with the ''' character, hexadecimal value 0x27. Line 15, position 83.') ---> System.Xml.XmlException: Name cannot begin with the ''' character, hexadecimal value 0x27. Line 15, position 83.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at X3_Script_Editor.Decompiler.openScript(String scriptName, String path)
--- End of inner exception stack trace ---
at X3_Script_Editor.Decompiler.openScript(String scriptName, String path)
--- End of inner exception stack trace ---
at X3_Script_Editor.Decompiler.decompile(String filename, Int32 gameMode)
at X3_Script_Editor.Editor.LoadFiles(String[] fileNames)
at X3_Script_Editor.Editor.menuOpen(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItem.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
X3 Script Editor V3
Assembly Version: 1.0.3806.32021
Win32 Version: 1.0.3806.32021
CodeBase: file:///F:/Downloads/X3/X3TC%20Tools/Exscriptor/Exscriptor.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (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 computer
rather than be handled by this dialog box.

<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet href="x2script.xsl" type="text/xsl"?>
<!--Produced externally by the Exscriptor-->
<script>
<name>lib.xml.deserialize</name>
<version>74</version>
<engineversion>44</engineversion>
<description />
<arguments>
<argument index="0" name="xmlString" type="Var/String" desc="Input Xml String" />
</arguments>
<sourcetext>
<line linenr="001" indent=""> </line>
<line linenr="002" indent=""> </line>
<line linenr="003" indent=""><var>$special.open = </var><text></text><var>'<' </var><text></text></line>
Browsers fail to load the xaml on that line 003 as well


Although... oddly enough, if I changed it to teh &l;t; it works, EVEN THOU, the greater than sign is still used on line 4 (and I did not replace it )
<line linenr="003" indent=""><var>$special.open = </var><text></text><var>'<' </var><text></text></line>
<line linenr="004" indent=""><var>$special.close = </var><text></text><var>'>' </var><text></text></line>


After a bit of testing
When you save scripts using the ingame SE it does this:
<line linenr="003" indent=""><var>$special.Open = </var><var>'<'</var></line>
<line linenr="004" indent=""><var>$special.Close = </var><var>'>'</var></line>
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Hey, Whimsy. Hope you're still at this. Still using the great invention of yours.

Comment time.

One of the pains I've always experienced when using Exscriptor, has been writing scripts from scratch. I love editing them, but puting in commands from the context menu has always been slightly difficult using just the keyboard.

I usually hit the list key (between right Windows key, and right CTRL key), to bring up that context menu. I then select the apropriate command. But then I have to reach for my mouse. It'd be cool to have the enter key simply select/pase whatever's highlighted in that script command list, despite what's in the text box to the top.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

(An intellisense would be pretty awesome, although I do not know how you would do it with a "literal" script engine like x3)
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

Litcube wrote:I usually hit the list key (between right Windows key, and right CTRL key), to bring up that context menu. I then select the apropriate command. But then I have to reach for my mouse. It'd be cool to have the enter key simply select/pase whatever's highlighted in that script command list, despite what's in the text box to the top.
I've altered it in the latest version so you should be able to use the keyboard exclusively, e.g. list key, select command category with the cursors & enter, press tab to move to the command list, cursors to move, and now enter will select the highlighted command (as long as the search/text box at the top is empty).
s9ilent wrote:I'm trying to create an xml deserializer in the x3, and I whilst making the script, I needed to do something like this:

$string = '<'
But doing that in the exscriptor causes the following issue:
(When you try to open it, I suspect it's because it does not convert it to the &lt;)
This one was a bit tricky to fix, but it should convert XML symbols in strings correctly now. It certainly shouldn't crash, like it was doing before. :wink:
(An intellisense would be pretty awesome, although I do not know how you would do it with a "literal" script engine like x3)
It's possible, it's just a lot of work. :P

Anyway, new version is here as usual. Let me know if I broke anything in the process...
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Whimsy, you fixed the hidden window glitch! Nice.


@ S9ilent:

Code: Select all

Raw = "E:\Litcube's Documents\Egosoft\X3TC\log08965.txt"
Out = "D:\Games\X3 Terran Conflict\t\8382-L044.xml"



Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInputFile = objFSO.OpenTextFile(Raw, 1)
Set objOutputFile = objFSO.CreateTextFile(Out, 1)
objOutputFile.WriteLine("<?xml version=""1.0"" encoding=""UTF-8""?>")
objOutputFile.WriteLine("<language id=""44"">")
objOutputFile.WriteLine("<page id=""9000"" title=""Exported empire"" descr=""Temporary data, you can delete this afterimporting your empire"" voice=""no"">")



Do until objInputFile.AtEndofStream

	strText = objInputFile.ReadLine
	strText = Replace(strText,",", "<")
	strText = Replace(strText,".", ">")
	objOutputFile.WriteLine(strText)
Loop

objOutputFile.WriteLine("</page>")
objOutputFile.WriteLine("</language>")

msgbox("Done!")
A temporary solution for you: Just change the Raw and Out file paths to your file. Copy and save it in a text file and rename it "whatever.vbs".
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Whimsy, some of the wares aren't being formatted properly when loading. They appear without their { or }, causing an error upon save.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Thanks for the fixes guys

I only used the < and > in 1 line each, so just use place holders and swapped it out just before I deployed.
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

Whimsy, here's what I'm talking about with version 1.2.37

http://members.shaw.ca/Litcube/X3/excri ... eerror.png
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

Litcube wrote:Whimsy, some of the wares aren't being formatted properly when loading. They appear without their { or }, causing an error upon save.
Not sure how I missed that one... :oops: Anyway, it should hopefully be fixed now in V1.2.38!
h2o.Ava
Posts: 349
Joined: Sun, 12. Oct 08, 04:04
x4

Post by h2o.Ava »

edit x2:
I thought of this after I posted.
As a possible fix for all of the following:
Is it possible and feasible to allow for forced saving?
Even if a Literal is Unresolved or a string has an extra ' in it, could you allow us to ignore those errors and save anyway?
end edit x2


Could you allow for apostrophes to be used in strings?
Perhaps using \ to escape it?

example code:

Code: Select all

$text.id.array[1] = 'Akeela's Beacon'

$sector = [PLAYERSHIP]->get sector
* {Akeela's Beacon}
$name = $sector->get name

if find $name in array: $text.id.array
I need to use strings since I am creating a way to send strings to Mission Director, currently only positive number variables and string variables can be sent to MD.
MD returns strings with apostrophes when you return: sector.name@<sector>, so to do a do_when or do_if name="stringSentToMD" exact="{sector.name@<sector>}"
I need a way to create these strings in your amazing program. (I could do it manually in the ingame editor, however I have over 240 entries :( )

Love you, love this!
Coding in SE would be sooo much slower without you.




edit:
Is it possible and feasible to add the ability to run the script with Ex Scriptor and create an output of each step or variable assignment?
This would make debugging sooo much easier than using the ingame SE.
end edit
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Is it possible and feasible to add the ability to run the script with Ex Scriptor and create an output of each step or variable assignment?
This would make debugging sooo much easier than using the ingame SE.
This would be a killer feature! Of course, you'd always have to enter data the ingame SE would normally query from the game by hand. I could imagine, that this could get quite tedious.

Still a huge timesaver, especially for cases when you'd have to setup a whole testing environment, to get the correct testing values (i.e. what happens when my trade script doesn't any tradable wares).

Greetings,
ScRaT
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

h2o.AvA wrote:Could you allow for apostrophes to be used in strings?
Perhaps using \ to escape it?
This turned out to be more fiddly than I'd expected, but hopefully in the latest version you should be able to use the \ character to escape the apostrophe, e.g.:

Code: Select all

$text.id.array[1] = 'Akeela\'s Beacon'
Note this is the only escape sequence, so you shouldn't need to escape the backslash itself (e.g. '\\' is still a string containing two backslashes), or at least that's the plan. :)

Let me know if you have any problems or if I broke anything...
h2o.AvA wrote:edit x2:
I thought of this after I posted.
As a possible fix for all of the following:
Is it possible and feasible to allow for forced saving?
Even if a Literal is Unresolved or a string has an extra ' in it, could you allow us to ignore those errors and save anyway?
end edit x2
You can already do this, but only as a text file; it's simply not possible to save an XML file containing errors due to the way it all works. If you really have to save to XML despite errors, e.g. to edit the script in-game, then your only option is basically to comment out any lines with errors, but even then in most cases you won't be able to uncomment those lines in the in-game.
h2o.AvA wrote:Is it possible and feasible to add the ability to run the script with Ex Scriptor and create an output of each step or variable assignment?
This would make debugging sooo much easier than using the ingame SE.
end edit
This would be a nice feature, but unfortunately even if I had the time, I'm not sure how feasible it is. As ScRaT_GER points out, the biggest problem is that you'd have to get all the game data from somewhere. Then there are some 800 different commands that Exscriptor would have to know how to interpret in order to be able to manipulate that data; and there are still a few that are still a bit of a mystery (at least to me). You'd have to essentially emulate the game, just without the graphics engine, for it to work - not a small task. :D
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@h20
Your probably better off using loadtext (Or better yet get sector x/y) and doing it that way.
h2o.Ava
Posts: 349
Joined: Sun, 12. Oct 08, 04:04
x4

Post by h2o.Ava »

I've created a dynamic colored sector names, no other way to do it.
SE determines which sector belongs to which race then calculates the textid based off the name of the sector and sends the id and the x,y to MD to have it changed.
Thank you for the suggestion, though. :)


Thank you for the very fast change!! :):)

What about a simple input/output debugger.
User manually inputs the script's input and the debugger displays the output?
That'd help me a lot, since, I use a lot of arrays within arrays and it gets tricky sometimes pulling the correct data. Maybe I should stop using so many arrays..


edit:
@silent
!! i didn't know about the command read text to array. Thank you very much for the suggestion!

@wimsy
I can't seem to keep the font at a larger size.
Using the Mwheel i enlarge the font. Upon typing it goes back to the default size.
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

the Variables dialogue box doesn't include those variable names with "."s.
JoeTheDestroyer
Posts: 36
Joined: Wed, 14. May 08, 01:40
x3tc

Post by JoeTheDestroyer »

s9ilent wrote:I run this on win7 64 on an i7 and it runs fine (I used to run this on winxp 32 and 64 on a amd 64 and it worked fine back then too)
...
I do not need to do anything special to make it run, it just works
Sorry about the late reply on this.

Anyways, it's only the command line compiler that has problems. I can run the main editor (gui) just fine.
s9ilent wrote:There should be nothing wrong with running 32 bit things on 64 bit machines (thou running 16 on 64 will fail, but will work on 32)
Unfortunately, when it comes to .Net and interpreted languages like C# (which I assume this was written in), this isn't exactly correct.

The problem is that, with the flags set as they are, 64-bit windows will load ExscriptCmd.exe and run it as a 64-bit program (not 32-on-64, but actual 64). The program then attempts to load a 32-bit dll (that has the code to read X3TC data files), which is a big no-no. Thus the error.

The program and command I listed adds a flag that forces windows to load the program as a 32-bit program, which is then capable of loading the 32-bit dll.
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

JoeTheDestroyer wrote:The problem is that, with the flags set as they are, 64-bit windows will load ExscriptCmd.exe and run it as a 64-bit program (not 32-on-64, but actual 64). The program then attempts to load a 32-bit dll (that has the code to read X3TC data files), which is a big no-no. Thus the error.
Sorry - I completely missed this before. I'll take a look at the compile settings and make sure they're set consistently; should be an easy fix hopefully. :)
Litcube wrote:the Variables dialogue box doesn't include those variable names with "."s.
Well spotted - I'll try and fix this in the next version.
h2o.AvA wrote:I can't seem to keep the font at a larger size.
Using the Mwheel i enlarge the font. Upon typing it goes back to the default size.
This is a known issue unfortunately. If you want to resize the font the best option is to just use the options menu to do it; that way it should stick.

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