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

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

Post by Moonrat »

Hi (again).....The fix to the calling parms validation looks to be working, thanks.

What an amazing prompt service you offer !!

I'm however confused now about another aspect (now that I can get my altered script complied OK)...there seems to be something very strange happening when I try to save changes and then re-edit them. The XML content changes in the existing file do appear to be over written as I can see them via iExplorer & NotePad. But when I go back into the editor it not only sometimes loads up things I have explicitly used "Close" on (and do not want to work on again) but also they appear to be without my new changes !! even tho' iExplorer & NotePad indicate otherwise.

In the options tab I have the following...
C:\Program Files\EGOSOFT\X3 Reunion
C:\Program Files\EGOSOFT\X3 Reunion\scripts
for the two locations.

Where is the editor getting the old versions of the pre-modified scripts from ? Also is the "openedScripts.dat" file working correctly. ie. When you close something is it getting updated correctly ? :?

Thanks in advance,

PS: Thanks for the mention in the docs....I am not worthy
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

Moonrat wrote:Hi (again).....The fix to the calling parms validation looks to be working, thanks.

What an amazing prompt service you offer !!
Glad to be of service! :)
Moonrat wrote:Where is the editor getting the old versions of the pre-modified scripts from ? Also is the "openedScripts.dat" file working correctly. ie. When you close something is it getting updated correctly ?
The openedScripts file wasn't working properly, you're right - if you had no scripts open when you exited, it wasn't emptying the file. This is fixed now, as is the XML problem SSwamp_Trooper experienced above.

However, I'm confused by this other behaviour - it shouldn't be possible for it to load old versions of the scripts... the only cases I can think where that might be possible are if you had a quicksave TXT or a PCK open and saved to an XML, but I take it that's not the case?

Try v1.017, which fixes the opened scripts bug, and see if it still does it - i.e. when you load your scripts, they still appear unchanged. I can't reproduce this bug myself so maybe if you let me know the locations and types of files that you opened/closed, I can figure out what is going on... :?
bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate »

Great fixes again!
Whimsy wrote:
bunkerprivate wrote: - Interrupt points seem to be ignored by the editor
This is true and in fact it's deliberate,...
OK this is a product of my learning the scripting language using Exscriptor: it seemed interrupts were optional on some commands and I don't use the command list to find them because it's too slow for me. I never tested the assumption because I didn't want to lock up the game ^^. I could see it being a problem for commands like 'turn turret to target' or similar, which are not immediately obvious as interruptable.
Whimsy wrote: I don't think you ever could Ctrl-C/V from those
That's weird because I'm sure I remember copying the script filename and pasting to the script name whenever I moved a script or saved it under a different name...

--

I have a couple of minor issues from trying to parse your command list for this database thing:

Code: Select all

<RetVar> = <Var/Warpgate> get gate destination: return sector= <Var/Number>
<RetVar> = <Var/Warpgate> get gate id
<RetVar/IF> <RefObj>is script <Script Name> on stack of task= <Var/Number>
<RetVar/IF> <RefObj>is task<Var/Number> in use
Presumably they're supposed to be <RefObj>->, but I can't actually find any documentation for them, so maybe I'm wrong!

There are also a few which don't have '<RetVar> command' instead of '<RetVar>= command', though presumably this is to save typing.

There's also

Code: Select all

<RefObj> -> set relations from notoriety: include player as target and race > teladi as owner = <Var/Number>
add merchant <Var/String> base= <RefObj> -> wanted wares= <Var/Array> owned wares= <Var/Array> cash= <Var/Number> rank= <Var/Number>
set notoriety of <Var/Race> -> <Var/Race> to <Var/Number> points
START <RefObj> -> command: arg1= <Value>, arg2= <Value>, arg3= <Value>, arg4= <Value> 
Which my parser choked on due to additional angle brackets, but I can't find them documented so I don't know if it's a real command or a typeo.

There are some in the "New in 2.5" section where are duplicated elsewhere and some which are not. I think it's just the PHQ commands.

There are a number of typeos:
- var/stations seriall
- var/sting
- var/nmber

Also, the type names are not case-consistent; eg you have Var/number and Var/Number.

---

Well since I can't find any other bugs I guess I'll float my list of enhancement suggestions now ^^!

- When saving a file that has compile errors, it would be nice if the errors were shown automatically, rather than having to manually press compile again. In fact, now that there are compile warnings it would be good to see that output on every save.

- Infinite undo, or undo 'since last pause', ie when you last stopped typing. Kinda tricky, but my text editors do this ^^. Undo per-character makes 25 spaces a little low.

- Could do with a cancel button on the add/edit argument boxes.

- Report everything that conflicts in text files. At the moment it only reports that 'there is a conflict with X'. It would be nice to have 'X conflicts with Y'. The conflict checker is actually a really nice side-effect to this program.

- Reload file from disk function for when you're working on a script in game and in the editor.

- When opening a file, check if it's already open and ask if it should be reloaded from disk.

- When closing a file, go to the last used tab instead of the first tab.

- When saving, start the 'save as...' box in the same directory as the file.

- For loading, start the file chooser in the directory of the currently active tab (perhaps there could be an additional button for 'go to scripts directory? Same for above.).

- At the moment, parameter names are lost when reloading a file so call script 'name': memorableName=$val becomes call script 'name': arg0=$val. It would be nice if the editor would substitude argX for the name of the parameter in the script that is being called.
DesertEagle
Posts: 117
Joined: Thu, 2. Feb 06, 05:32
x3

Scripting Troubles

Post by DesertEagle »

First : You are a god among men for actually releasing a usable external script editor. I was writing a massive mod for Sector Takeover and the in-game editor's clunkiness eventually caused me not only to abandon the effort, but the entire game as well. Now, heh heh, you've brought me back.

#1
Alright, onto the problems. The script below saves just fine in your editor, but it doesn't refresh in my 2.5 steam install of X3 unless I start a new game. I've tried re-init'ing the script caches, to no avail. It stays stubbornly on the previous version (the one the X3 editor must have cached). Additionally, I've created two new files in your editor, and they refuse to appear in the X3 script editor at all, even when starting new games. Re-loading a save game doesn't clear the problem either.

Code: Select all

$myT = [PLAYERSHIP]->get sector
$myX = [PLAYERSHIP]->get x position
$myY = [PLAYERSHIP]->get y position
$myZ = [PLAYERSHIP]->get z position
 
$myZ = $myZ + 2000 
$mySector = [PLAYERSHIP]->get sector
 
$tg2 = create ship: type={Argon Nova Raider 7_111} owner={Player} addto=$mySector x=$myX y=$myY z=$myZ
 
$tg2->set name to 'The Valiant'
 
 
return null
EDIT: Deleting the file in the script editor, and reloading a savegame seems to do the trick for refreshing the thing. But is there an easier way?

#2
Changing the version number doesn't trigger the * asterisk in the title bar. Just a niggle.

#3
Finally, my error log keeps getting this error whenever I start your editor:

Code: Select all


Exception occurred: Error while cleaning XML string
Message: StartIndex cannot be less than zero.
Parameter name: startIndex
Stack Trace:    at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
   at X3_Script_Editor.XData.CleanXML(String xml)
Source: mscorlib
Target: System.String InternalSubStringWithChecks(Int32, Int32, Boolean)

If you could provide any assistance resolving these, would much appreciate it. #1 is a showstopper for me right now.

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

Re: Scripting Troubles

Post by bunkerprivate »

DesertEagle wrote:it doesn't refresh in my 2.5 steam install of X3
AFAIK you always need to re-load the savegame. X3 won't ever re-read a script from disk; however it will write them to disk whenever you save in X3. It's a problem for me too but just think of it like programming for embedded systems ^^. Just make sure you put lots of debugging logs in your scripts and it's not too annoying, especially if you program defensively.
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

bunkerprivate wrote:OK this is a product of my learning the scripting language using Exscriptor: it seemed interrupts were optional on some commands and I don't use the command list to find them because it's too slow for me.
Ah, I see - yes, the commands themselves are interruptable. I could probably add in an option to enforce the use of the interrupt symbols if you think it would be useful? Then it would make the user aware that the command is interruptable but they also have the option to turn them off if they get annoying.
bunkerprivate wrote:That's weird because I'm sure I remember copying the script filename and pasting to the script name whenever I moved a script or saved it under a different name...
Sorry, you're quite right - I went back a few versions to check. I don't know at what point or why this changed, but it should work again now.
bunkerprivate wrote:Presumably they're supposed to be <RefObj>->, but I can't actually find any documentation for them, so maybe I'm wrong!
For the latter two, you're definitely right - you can tell by looking in the main language XML file (e.g. 440001.xml). It's also like that in the Exscriptor's command parameters XML file (which is the one it mostly uses - the text file is just for the script command list in the Object List). As for the first two, I'm pretty sure those are supposed to be RefObjs too, though the param types aren't shown in the language file.
bunkerprivate wrote:There are also a few which don't have '<RetVar> command' instead of '<RetVar>= command', though presumably this is to save typing.
Are these the <RetVar/IF> ones? I can't find any normal RetVars without equals. But yes, if I remember rightly, the IF ones don't have equals because otherwise it forced you to use the equals even if you were making it into a conditional and not an an assignment.
bunkerprivate wrote:Which my parser choked on due to additional angle brackets, but I can't find them documented so I don't know if it's a real command or a typeo.
Some of those are all correct - the single ">" one and the notoriety one. The merchant one was wrong (I've removed the ->). The last one I'm not sure about but I left the -> in. You can double check the first few by looking in the language XML or command param XML files, but the XML files tend not to show the arrows after RefObjs.
bunkerprivate wrote:There are some in the "New in 2.5" section where are duplicated elsewhere and some which are not. I think it's just the PHQ commands.
I think they're all duplicated actually (one's in the General commands). This was mostly for selfish reasons - I kept forgetting where they were when X3 2.5 came out so I kept them duplicated in a separate menu and I just never removed it. :wink:
bunkerprivate wrote:There are a number of typeos:
- var/stations seriall
- var/sting
- var/nmber
Well spotted - they're fixed now.
bunkerprivate wrote:Also, the type names are not case-consistent; eg you have Var/number and Var/Number.
Which file? I couldn't find these.
bunkerprivate wrote:- When saving a file that has compile errors, it would be nice if the errors were shown automatically, rather than having to manually press compile again. In fact, now that there are compile warnings it would be good to see that output on every save.
I've got it so it will highlight if errors are detected while saving. It still won't do this when saving as a text file though (since it doesn't run a compile then).
bunkerprivate wrote:- Infinite undo, or undo 'since last pause', ie when you last stopped typing. Kinda tricky, but my text editors do this ^^. Undo per-character makes 25 spaces a little low.

I've upped the limit to 50 but the way I do it is very primitive - I just copy the text each time and store it; therefore I'm loath to up it too much lest it eat loads of memory for huge scripts. One day I might find a better solution to this though.
bunkerprivate wrote:- Could do with a cancel button on the add/edit argument boxes.
Wish granted. :)
bunkerprivate wrote:- Report everything that conflicts in text files. At the moment it only reports that 'there is a conflict with X'. It would be nice to have 'X conflicts with Y'. The conflict checker is actually a really nice side-effect to this program.
I'll try to do something like this in a later version, since it's a more time-consuming task. The current functionality really is just a side effect - I had to load all the names and check whether they already existed anyway, so it was easy enough to tell the user too. :) In the meantime I think Cycrow's plugin manager can check for conflicts too, though it might only be for plugin scripts.
bunkerprivate wrote:- Reload file from disk function for when you're working on a script in game and in the editor.
Done - added to the View menu. Hope it works properly...
bunkerprivate wrote:- When opening a file, check if it's already open and ask if it should be reloaded from disk.
Done as well. If you try to open an already opened file, you can either reload it or not, but it won't put it in a new tab any more.
bunkerprivate wrote:- When closing a file, go to the last used tab instead of the first tab.
Done.
bunkerprivate wrote:- When saving, start the 'save as...' box in the same directory as the file.
Good idea - done.
bunkerprivate wrote:- For loading, start the file chooser in the directory of the currently active tab (perhaps there could be an additional button for 'go to scripts directory? Same for above.).
I just use the built-in file dialogues, so it's not worth the effort of trying to add a new button, but as a consolation I've got it to start in the directory of the current script, just like with Save As.
bunkerprivate wrote:- At the moment, parameter names are lost when reloading a file so call script 'name': memorableName=$val becomes call script 'name': arg0=$val. It would be nice if the editor would substitude argX for the name of the parameter in the script that is being called.
This is something that should have worked long ago but never did, and I forgot to fix it. It's done now, so it uses the argument names as set out in the other script. This differs a little from the ingame editor which I think uses the argument descriptions instead (but those are a lot harder to parse...).
DesertEagle wrote:Alright, onto the problems. The script below saves just fine in your editor, but it doesn't refresh in my 2.5 steam install of X3 unless I start a new game. I've tried re-init'ing the script caches, to no avail. It stays stubbornly on the previous version (the one the X3 editor must have cached). Additionally, I've created two new files in your editor, and they refuse to appear in the X3 script editor at all, even when starting new games. Re-loading a save game doesn't clear the problem either.
I've never been 100% clear on how and when X3 loads its scripts. As bunkerprivate said, normally you have to at least reload; usually I restart the whole game to make sure it's loading the new versions properly. Even then, I believe that ships/stations that are running scripts already when a game is saved will still be running old versions (but I may be wrong). Unfortunately there's not much I can do about any of this. :(

Your new scripts not showing up at all is a puzzle, though - do they show up once you reload the whole game (i.e. shut down X3 and restart it)? As I said, that's normally what I have to do to get it to pick them up. However, if you've done that and it's still not loading them, I don't know what to suggest; the only thing I can think of is that perhaps you have two files with the same script name - internally, X3 uses the script name (which is not the same as the filename) to display scripts, so it will only show one of them. Other than that, I don't know - sorry!
DesertEagle wrote:Changing the version number doesn't trigger the * asterisk in the title bar. Just a niggle.
I might not be able to fix your biggest problem but I can fix this one. :wink:
DesertEagle wrote:Finally, my error log keeps getting this error whenever I start your editor:
Sorry about that - I have this habit of introducing stupid bugs whenever I release a new version, and this was new in V1.017 I think. Anyway, I've fixed it now. There will doubtless be new bugs in V1.018, of course - it's traditional. :D

V1.018 is here.
DesertEagle
Posts: 117
Joined: Thu, 2. Feb 06, 05:32
x3

Post by DesertEagle »

You are an awesome developer for supporting your tool so well. Sincere kudos
bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate »

Whimsy wrote:Are these the <RetVar/IF> ones?
It could be... I only found this out by making a seriously hacked together PHP script to generate some SQL statements. As a side effect, the script would moan about commands it couldn't parse.
bunkerprivate wrote:There are some in the "New in 2.5" section where are duplicated elsewhere and some which are not. I think it's just the PHQ commands.
Whimsy wrote:I think they're all duplicated actually..
Yeah they are. It's actually a pretty good idea since there is no source to say whether a command is in x2 or what version. It might be handy for forward porting of scripts, though I don't know how much of that is going on now.
Whimsy wrote:Which file? I couldn't find these.
I was speaking generally. Apparently MySQL is case-insensitive by default and I got a lot of duplicate key errors until I just set them all lowercase.
Whimsy wrote:I've never been 100% clear on how and when X3 loads its scripts.
I tested this and it will always load new scripts if you do Ctrl+Q then load up the savegame again (so no need to fully exit X3). I guess the chances of Egosoft pushing a patch to correct this behavior is virtually nil. As for running scripts, there are a number of hacks to make them restart, and I think actually a command like 'script has new version' or something... shame I didn't know about that one until I finished using one of the hacks ^^!
Whimsy wrote:Your new scripts not showing up at all is a puzzle, though -
I just though that perhaps it is a consequence of the compile errors not showing up on save? It's happened a couple of times where I didn't notice the save was unsuccessful because only a couple of lines get printed to the output box instead of the usual mass of errors ^^.

--

Top quality fixes again! The editor makes it a lot easier (read: actually possible) to do things like write unit tests and complicated stuff like iterative tree traversal.

--

Edit: I managed to reproduce the fields disappearing error: just minimise the program and click on it in the task bar again. Strange I never noticed that before!
Last edited by bunkerprivate on Tue, 12. Aug 08, 15:37, edited 1 time in total.
Atrocious
Posts: 165
Joined: Mon, 15. May 06, 20:13

Post by Atrocious »

Nothing really important, but I wanted to mention:

When I tried to compile this:

Code: Select all

write to player logbook: printf: fmt= 'ObjID: %s', $ObjID
The compiler told me
- Error on line 5 - Unrecognised symbol in expression: write
So I thought it's the %s that it doesn't recognize, but actually it just wanted all parameters set. So like this it works:

Code: Select all

write to player logbook: printf: fmt= 'ObjID: %s', $ObjID, null, null, null, null
Cheers!

Edit: Probably a new bug in 0.18: When I tried to "undo" what I had edit to post here, it just removed the last line of the script (which wasn't my last edit). I could do that multiple times and it rolled in my whole script, line by line.

Edit2: Underlines _ in variable names are no longer allowed. Was that always the case? Is it intended?
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

DesertEagle wrote:You are an awesome developer for supporting your tool so well. Sincere kudos
Thanks! :) And I hope the tool is working okay for you now - did you get those scripts to appear?
bunkerprivate wrote:Yeah they are. It's actually a pretty good idea since there is no source to say whether a command is in x2 or what version. It might be handy for forward porting of scripts, though I don't know how much of that is going on now.
I thought about making it fully backward compatible - adding an X2 mode which would disable X3 only commands, loading X2 data files, testing it with X2 scripts etc - but I don't think there's so much X2-only scripting going on now and most X2 scripts should be compatible with X3 anyway. As for the future, we'll just have to see what X3TC holds...
bunkerprivate wrote:I tested this and it will always load new scripts if you do Ctrl+Q then load up the savegame again (so no need to fully exit X3). I guess the chances of Egosoft pushing a patch to correct this behavior is virtually nil.
That's good to know - at least we don't need to exit & restart the game each time, then. :)
bunkerprivate wrote:I just though that perhaps it is a consequence of the compile errors not showing up on save?
Good point - that's another possibility (and hopefully one that won't be as much of a problem now the errors are highlighted properly).
bunkerprivate wrote:Top quality fixes again! The editor makes it a lot easier (read: actually possible) to do things like write unit tests and complicated stuff like iterative tree traversal.
Happy to help! But wait - you've actually written a tree traversal algorithm using X3 scripts? How?!
bunkerprivate wrote:Edit: I managed to reproduce the fields disappearing error: just minimise the program and click on it in the task bar again. Strange I never noticed that before!
Ah, you're right - that definitely causes it. How odd - I can't figure out why it's doing that at all; I'll poke around a bit and see what I can come up with for v1.019.
Enrico777 wrote:The compiler told me
- Error on line 5 - Unrecognised symbol in expression: write
Unfortunately the compiler is not very clever. If it doesn't match the command (the keywords and number of parameters), it assumes it's a general expression, so almost all the error messages say something about bad expressions. I'll try to find a way to improve this some time, to make it more obvious what's wrong, but sadly there's a limit to how much is possible without completely changing the way it works. :(
Enrico777 wrote:Probably a new bug in 0.18: When I tried to "undo" what I had edit to post here, it just removed the last line of the script (which wasn't my last edit). I could do that multiple times and it rolled in my whole script, line by line.
That's happened to me a couple of times too; usually undo works okay but sometimes it acts a bit strangely. I think what's happening is that it's included some automatic process in the list of previous states, most of which involve replacing the entire script line by line, hence the way it disappears. I'll look into it.
Enrico777 wrote:Underlines _ in variable names are no longer allowed. Was that always the case? Is it intended?
It's new in the last few versions - since v1.016 I think. I realised that the ingame editor doesn't allow underscores, so I changed it (but I apparently forgot to mention it anywhere). It's actually a little inconsistent though, as I've just realised, since it's only expressions that disallow this - normal commands still allow it. Ssomething else to fix for the next version! :wink:
bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate »

Whimsy wrote:Happy to help! But wait - you've actually written a tree traversal algorithm using X3 scripts? How?!
Heh, well I'll show you the second most complicated code I wrote in your editor yet ^^

Edit 2: kinda off-topic so sniped: http://pastebin.ca/1169617

(It's actually not space-optimal, but I can't emulate the stack very easily without a struct, and it would be better to do it with a linked list (which is also a bit trying without a struct). Still, typically recursive script calls have big overheads in languages like this so it might be a bit faster)

Edit: OK so I can't let a problem go (have you guessed that?!). Here is a rough go of one that fixes the last one: http://pastebin.ca/1168941 (untested). Not all that complicated actually, but still sod doing it in MSCI ^^!

--

Just a couple of new minor ones this time:

- More info on the mysterious textfields: hiding and revealing the objects view thing triggers it. [s]Also the object list is made invisible when this happens. This might be a new one[/s]. Scratch that; it only happened once.

- When opening a new file, the compiler output text is wiped with you press Ctrl + O... come to think of it, there's not a huge amount of point keeping it if the opening process overwrites it anyway, though if you cancel then the output is still gone.

- 'Hide object view' is ticked when it is not hidden and vice versa after you click it for the first time.

- The unassigned parameter checker is reporting incorrect line numbers sometimes. I was in the middle of something when I got this so I didn't investigate further. Might have something to do with scripts with 'call script' commands to files that don't exist. It was wrong by three lines once but by less than three at an earlier unassigned variable.

- Odd error:
Could not check parameters for call to: bunker.resupply.travel.squadjumpcost: Found but could not read from script file: C:\Documents and Settings\Bunker Private\Desktop\resupply\bunker.resupply.travel.suppliedjump.xml ('Found but could not read from script file: C:\Documents and Settings\Bunker Private\Desktop\resupply\bunker.resupply.travel.suppliedjump.xml ('Arithmetic operation resulted in an overflow.')')
bunker.resupply.travel.squadjumpcost does not exist in the scripts dir or the working dir. It seems to be trying to open the script I'm currently working on.

Same error happened when I tried to open a further file. It would open other files.

Closing and re-opening the editor fixed it, so it's not to do with the file,
and after that I didn't manage to reproduce it (any suggestions?).
User avatar
Moonrat
Posts: 1354
Joined: Sun, 20. Apr 08, 16:20
x4

Post by Moonrat »

Apologies......and you're doing such a great job. :)

I've noticed that if I edit a script like "plugin.escort.me" and then go and save it (either by "Close" or "Save as") it rather annoyingly strips the ".me" off the end leaving me to type the ".me" each time. Any way around this ?

As another contributor mentioned, using the SE within X3 is so clunky, it's like wading through treacle... more so when you are used to proper editors like 'vi' in UNIX...I can hear the howls of laughter from here !! It puts one off trying to create anything more than a few lines long. I'm sure this editor is going to end up increasing the speed, quality and variety of new/enhanced scripts being produced. Good stuff.
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

bunkerprivate wrote:Heh, well I'll show you the second most complicated code I wrote in your editor yet ^^
If that's the second most complex I'd hate to see the most complex... I am very impressed though, especially by the second version which emulates a linked list! The iterator in particular is very clever, so it only adds one "child" to the list at a time. :)
bunkerprivate wrote:- More info on the mysterious textfields: hiding and revealing the objects view thing triggers it. [s]Also the object list is made invisible when this happens. This might be a new one[/s]. Scratch that; it only happened once.
I've not managed to trigger it using the hidden object view mode; nevertheless, I think I've fixed this now, though I still think it was very odd - the locations of the boxes were going into minus territory for some reason whenever it was minimised.
bunkerprivate wrote:- When opening a new file, the compiler output text is wiped with you press Ctrl + O... come to think of it, there's not a huge amount of point keeping it if the opening process overwrites it anyway, though if you cancel then the output is still gone.
There's probably not much point, you're right, but I've altered it anyway to keep the previous output until you really do load/save etc.
bunkerprivate wrote:- 'Hide object view' is ticked when it is not hidden and vice versa after you click it for the first time.
Curse those pesky ! signs... :D
bunkerprivate wrote:- The unassigned parameter checker is reporting incorrect line numbers sometimes.
I've moved where this check takes place now (it happens earlier, not at the end), so hopefully it will be more accurate in reporting line numbers. It will still be a bit off if you use preprocessor macros since the line numbers refer to the expanded script (warnings don't force it to stay in expanded mode), but that's nothing new.
bunkerprivate wrote:- Odd error: ...
bunker.resupply.travel.squadjumpcost does not exist in the scripts dir or the working dir. It seems to be trying to open the script I'm currently working on.
I've not managed to reproduce this, but looking at the code there was an error in the error message itself - at least partly causing the confusion. I've fixed the error messages to report which file it's actually trying to load (not which file it's in) so hopefully if it happens again we'll have a better idea of what's going on; that arithmetic overflow it mentioned looks potentially nasty.
Moonrat wrote:I've noticed that if I edit a script like "plugin.escort.me" and then go and save it (either by "Close" or "Save as") it rather annoyingly strips the ".me" off the end leaving me to type the ".me" each time. Any way around this ?
I can't figure out why it's doing this for you - it works okay for me, and I've checked the code to make sure nothing weird could happen. The only possible explanation I can come up with is that the script name (the one in the box above the arguments area in the bottom right, same as in the tab's label) differs from the actual filename, since it uses that name to decide what goes in the save file name box. So if the script was called "plugin.escort" but you were saving it to "plugin.escort.me" then it wouldn't add the ".me" part. I don't know whether that's what was happening though; if not, let me know and I'll keep looking to try to figure out what it might be. :(


Finally, in response to the bugs Enrico777 found, I've improved things a little:
- undo/redo handling should be improved, at least a bit (for starters, it should be better at remembering where the cursor was now, and it should be less likely to unroll a script line by line)
- variables using underscores should be picked up all the time now, not just in expressions
- using the wrong number of parameters in a script command will now get picked up by the compiler, so it shouldn't just revert back to assuming everything is an expression (unless you type the command wrong, anyway)

So let the bug hunt for V1.019 commence. :D
bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate »

Whimsy wrote:If that's the second most complex I'd hate to see the most complex... I am very impressed though, especially by the second version which emulates a linked list! The iterator in particular is very clever, so it only adds one "child" to the list at a time. :)
Thank you! I'm sure it will appear on this forum at some point. I'm gradually working my way down the call-stack of a resupply script. The most complicated part is my 300-line behemoth which makes a ship go to get energy cells for itself and its squad before jumping somewhere. So much error-checking logic!
Whimsy wrote:locations of the boxes were going into minus territory for some reason whenever it was minimised.
I remember that happening when I first programmed visual basic (10 years ago?!)! Trust Microsoft to preserve bug-backward compatibility!

--

OK, for the bugs, I found a really good one today! A genuine bona fide crash-to-desktop.

- copy this script into the scriptdir: right click, save as
- load a savegame in X3 => crash
- open the script in exscriptor and re-save it
- load a savegame in X3 => no crash!
- open the script in MSCI and insert then delete a line (anything to make it let you save over it)
- exit savegame
- load savegame => crash!

This has been around since 0.013 but I thought it was a fluke the first time since re-saving with exscriptor fixes it. Probably I've put something erroneous in the comments again which MSCI lets through but exscriptor coverts to an XML entity or something -- I must stop documenting my code ^^. I forgot to test this but I think it is the actual code-text causing the error, rather than some weirdness in the file. I'm on Linux at the moment so I can't try it out.

Only one other thing I noticed: the script parameter checker doesn't say which line is wrong, or highlight the error. I can't actually remember if it ever did, but in a long script with lots of sub-calls, it takes a while to find which line exscriptor is complaining about.

And two suggestions:

- Warn about unused variables.

- auto-increment the version counter (optional, because not everyone tracks versions like that).
So let the bug hunt for V1.019 commence. :D
Excellent! My next job is to make a command which causes a TS to resupply a single ship, so... 1,000 lines?! ^^
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

bunkerprivate wrote:OK, for the bugs, I found a really good one today! A genuine bona fide crash-to-desktop.
I checked the file and finally tracked down the source of the problem: it's the "=>" in the comment on line 110. You're right that it's a codearray problem; evidently X3 saves it directly to the XML in the codearray (meaning the angle brackets no longer match up) whereas Exscriptor replaces it with a &gt; instead, so when you resave it in the Exscriptor it works, and when you resave it in X3 it doesn't.

In the process I also found that X3 won't show scripts in the script editor unless the filename matches the script name, possibly explaining why some people have had difficulty getting scripts to appear in game. To fix this I've added a check when you save to make sure they match.

Speaking of filenames I also found that X3 won't show the call script parameter descriptions unless the script name exactly matches the file name - it's case sensitive. So I've added a warning for this too.
bunkerprivate wrote:Only one other thing I noticed: the script parameter checker doesn't say which line is wrong, or highlight the error.
I've added in the line numbers now, so hopefully tracking these down will be easier. :)
bunkerprivate wrote:- Warn about unused variables.
I've added this too.
bunkerprivate wrote:- auto-increment the version counter (optional, because not everyone tracks versions like that).
Added this too - whenever you save, it will increment the version number. It's optional so you can disable it if you want.
bunkerprivate wrote:Excellent! My next job is to make a command which causes a TS to resupply a single ship, so... 1,000 lines?! ^^
Sounds like fun... :D Hopefully V1.020 will make the task less arduous! :wink:
draffutt
Posts: 4293
Joined: Wed, 21. Feb 07, 17:46
x4

Post by draffutt »

Thank you for posting and supporting this wonderful program.
i have a small bug to report:

using lv cheats as an example; file setup.lv.cheats
when i made a change (any line doesn't matter) and saved it. i viewed the changed .xml in the build-in scripter in X3 and found line 76 was truncated

before saving in Exscriptor and viewing in X3 scripter

Code: Select all

* global script map: set: key={A_LV_SPAWN_FODDER}, class={Moveable ship}, race={Player}, script='a.cheat.attack.nearest', prio=0
after saving in Exscriptor and viewing in X3 scripter

Code: Select all

* 
global script map: set: key={A_LV_SPAWN_FODDER}, class={Moveable s
wish list:
could you add close all tab function?
None of us is as smart as all of us. ~Ken Blanchard

TC player bug fixes
Reunion player bug fixes
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

draffutt wrote:i have a small bug to report:

using lv cheats as an example; file setup.lv.cheats
when i made a change (any line doesn't matter) and saved it. i viewed the changed .xml in the build-in scripter in X3 and found line 76 was truncated
This might look weird but it's actually fairly harmless. There're two things happening. Firstly, the Exscriptor doesn't handle commented out commands in the same way X3 does - it treats them as just text instead (otherwise there are severe complications with conditional commands). So when you open up and then save a script with a commented command in the Exscriptor, it will save it as a text comment instead.

The second thing that's going on is that X3's internal script editor only allows you to write text comments of a certain length (60-something characters I think), but there's no limit in the Exscriptor, so long comments get truncated when you look at them inside the game. It doesn't affect the script since the full comment is still saved to the file (and if you edit the comment in X3 you can still see the whole thing), so if you open it again in the Exscriptor it's all there. And since they're only comments so they don't affect the running of the script anyway.

The only thing I can do to fix it is get the Exscriptor to treat commented commands properly, but that's a fairly major task. Hopefully one day I'll solve it but in the mean time I'm afraid there's not much I can do about this problem. :(
draffutt wrote:wish list:
could you add close all tab function?
Sure, no problem - I'll add it to the next version. :)
draffutt
Posts: 4293
Joined: Wed, 21. Feb 07, 17:46
x4

Post by draffutt »

Thx for the replay.

since that issue is cosmetic i can easily live with that.

possible bug: when using the view / compare feature. the slider for the second window doesn't remain scrolled at the current position. (scrolls immediately back to the top every sec there is movement). im using 64bit vista.

Question: if i have make backups when saving turned off and i decide to turn it on with scripts currently opened why does it put a * next to all of them all of a sudden after clicking OK? is it because it doesn't know if there were changes made before hand? [edit: it appears it adds those * to the open scripts if you make any type of change in options from simply opening the options menu and closing it; to turning on/off syntax highlighting, etc....] Rather would it be possible to have it semi-turned on in the backround to monitor which ones where actually changed so if someone does decide to turn it on with scripts opened it only puts an * next to those that where actually changed? or if that is going to take a little bit more work then you have time then have it only start monitoring the ment it is turned on and only put a * durning the period it is monitoring?

i have another wish list items.

1st: if i make a change in a T-file and save; When i click on tools and reload x3 data all open scripts the changes apply to in Exscriptor get changed with the new data.

using lib.cycrow.raceinteger as an example. if i create a t-file that changes "race 3" to "test race" and i reload x3 data in exscriptor that info from the t-file changes line 34 in raceinteger from "race 3" to "test race".

also if you do include this feature at some point. would it be possible with an option to highlight those lines changes after a reload with the scripts currently open

2nd: under "view" / "compare with" when the open menu comes up can you include opening .bak files in the selection box as well?

thx
None of us is as smart as all of us. ~Ken Blanchard

TC player bug fixes
Reunion player bug fixes
Whimsy
Posts: 167
Joined: Mon, 9. Feb 04, 20:32
x3tc

Post by Whimsy »

draffutt wrote:possible bug: when using the view / compare feature. the slider for the second window doesn't remain scrolled at the current position.
This isn't a bug - the right-hand window is locked to the left hand one, so if you scroll with the left window the right one scrolls to the same place, so you don't need to scroll both windows separately. The trade-off is that you can only scroll with the left-hand window since the right-hand one will always snap back to wherever the left one is. :)
draffutt wrote:Question: if i have make backups when saving turned off and i decide to turn it on with scripts currently opened why does it put a * next to all of them all of a sudden after clicking OK?
It's actually down to the syntax highlighting option - if it's on, it relighted all the open scripts even if they were already highlighted (and if it was off, it dehighlights them). I've disabled the unsaved check for this now though.
draffutt wrote:1st: if i make a change in a T-file and save; When i click on tools and reload x3 data all open scripts the changes apply to in Exscriptor get changed with the new data.
You can often update a script like this just by refreshing it from file in the View menu. I've changed it to auto-refresh any open scripts that are in non-unsaved state (i.e. no changes to them) when you reload the data; if you've changed a script (i.e. it's in an unsaved state), then it leaves it alone, to preserve any changes. It can't save it automatically because if the {literals} have changed (like your race name example), it won't compile, in which case you'll have to update it manually; if no changed literals are used, you can just save and refresh it as normal.

Sadly, to do this whole process automatically would be a lot more difficult, but hopefully the extra refresh will at least make it easier some of the time. :(
draffutt wrote: 2nd: under "view" / "compare with" when the open menu comes up can you include opening .bak files in the selection box as well?
I've added this in now, and for normal open as well. It should be able to figure out the difference between a backup text and backup xml file, too. Also, your close all tabs function is in there too, as promised. :)


Finally, one last bug fix that I spotted myself: text files weren't saving the script arguments. Obviously I've added this in now but old scripts saved as text files will lack them. The change is backwards-compatible so you can still load text files in the older format.

V1.021 is here.
bunkerprivate
Posts: 27
Joined: Fri, 4. Jul 08, 16:01

Post by bunkerprivate »

I didn't play much with the editor lately, but I found a few new minor issues with 1.020. Sorry if you fixed them in 1.021 as I haven't had a go at that one yet!

- the command 'is new script version available' is never recognised by the editor (though it is in the CommandList)

- '[THIS]->is task 0 in use' reports
Error on line 52 - Insufficient parameters for command (should be 3)
I just missed the "=" sign, but the error is a bit confusing... presumably it counts the reference, param, and return value as parameters.

- unused var checker reports the error on line 0 unless you assigned it with a literal.

- '$undefined->some command' reports 'unused var $undefined' instead of the expected undefined var error.

- '$defined->some command' will report an unused variable unless it has been used as parameter somewhere else.

- rename checker has something against my script ^^
1. save bunker.resupply.tanker.cmd as bunker.resupply.tanker.cmd.xml
2. there is an error: renames to bunker.resupply.tanker
3. save again to bunker.resupply.tanker.cmd.xml
4. there is another error: renames to bunker.resupply.tanker.cmd
5. goto 1 ^^

I only found that it does this with that .cmd suffix.

- Also, the rename question does not say whether it will rename the scriptname to the filename, or the filename to the script name.

- if there is a script name check, there is no question to overwrite an existing file.

- Version incrementor does not work until you initially put a number into the box (in a new file, the box is simply empty to begin with).

- To (finally) reproduce the missing object list bug: hide object list, minimise, maximise, unhide object list.

The only one that causes trouble is the final one because I've taken to writing the scripts using the expanded text view now.

Thanks for continuing to bear my pedantry!

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