X4 - UI and scripting

This forum is the ideal place for all discussion relating to X4. You will also find additional information from developers here.

Moderator: Moderators for English X Forum

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

Post by euclid » Sat, 5. Aug 17, 22:01

XML/MD is fine by me; much better than the in-game scripting of previous X games. However, my worries concern:
  • 1# The UI modability, which is atm not only tedious but utterly limited.
    2# Limited features to trigger actions/events in mods. For example, no XML/MD commands that activate/trigger on key pressed.
But I'm still hoping some of the nice Devs will hear my prayers ;-)

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

Serath
Posts: 4
Joined: Sun, 13. Aug 17, 23:20

Post by Serath » Mon, 14. Aug 17, 01:11

Without becoming argumentative or trying to start a development debate about using XML for it's intended purposes, my view on it's use in XR is such:

As a developement/content designer tool I'm all for it, just not in the games runtime-environment.

if you added a middle step in the form of a binary encoder for modders so the game doesn't have to use a parser to load/save/manipulate data, it would be less of an issue. Humans still has the readability/tweakability of the XML and the game engine would load/save a lot quicker as it would be dealing compact binary instructions instead of longwinded data needing to be parsed.

Personally there are much better ways to allow for mod/script ability than XML. XML is for human readability when human intervention is required in data transfer between encoded states. Machines neither need nor particularly care for multi character instructions when a single/double character would suffice (ofc not referring to operands, that's a different story).

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Mon, 14. Aug 17, 16:28

Killijaeden: did you ever open your much praised X2/X3 Scripts externally? they are also XML, and the actual Script Code is much less readable than XR Code because it baiscally abstracts all Script Commands with numerical ids.. [irony]yeah, much better than XR[/irony]
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Serath
Posts: 4
Joined: Sun, 13. Aug 17, 23:20

Post by Serath » Mon, 14. Aug 17, 19:31

Just curious then why the numerical id's were dropped. It's at least more efficient encoding to machines and to be honest, a script/xml editor front-end that hides the underlying structures/method would have resolved the issue of syntax/readability and the debates around it.

Games have included editor front ends since the dawning of Win 95, if not earlier, which is a much more effective way to allow, not only users but the content designers especially, to modify game behavior and creating custom content with the added bonus of making it possible to store data in a more compact format.

I'm pretty sure though that were I a in-house content developer, I would have appreciated a abstraction layer, apart from generic XML schema editors as not only is it less key-mashing but also considerably less error prone, which is a pretty major concern when allowing your end user to prod and probe around the "inner workings" so to speak.

Granted, I completely understand the complexities when it comes to developer time, the mantra of "if it ain't broke don't fix it", pressures from management etc. I am still however baffled at some of the design, coding and game-play decisions made in this game by such a seasoned company. Still I can not judge as there are no "right" or "wrong" way in coding and things are never as simple as it seems from the outside. Yet, there is most certainly efficient and less-efficient ways.

With that said, I'm also amazed that during the lifespan of the game none of the modding community, and from the looks of it there's quite a few competent coders among them, has created a front-end for the XML Schema (or at least none willing to share it with the rest of the community). At bare bones level, it's not rocket science to a competent coder ... it's a XML Schema after all.

Assailer
Posts: 476
Joined: Sun, 25. May 14, 17:45
x4

Post by Assailer » Tue, 15. Aug 17, 06:15

Serath, It's been answered by Devs there is XML parsing only upon loading to internal binary tree. The agent only executes this efficient binary tree, never needs to parse further the XML itself. To me it's all good.

In addition XML shines when you need to patch bits of code (add,delete,insert and match).

Serath
Posts: 4
Joined: Sun, 13. Aug 17, 23:20

Post by Serath » Tue, 15. Aug 17, 17:24

Assailar, I understand the reasoning for the use of it and that it doesn't impact during the runtime as such. It has however compromised the loading time of the game and savegames, which is still part of the run-time environment. It's a fundamental part of software design to not compromise on loading speed.

It's frustrating as heck when needing to reload a save game or even alt-tab (though the alt tabbing could be down to other factors). I won't go further into the subject though as it becomes a development debate but to me there is still a lot more effecient ways while even still retaining the XML as a patching/modding tool.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Tue, 15. Aug 17, 19:15

the Scripts dot take that long to load.. for me its 2.4s on a new Game and 3.5s total on a Savegame. (i dont think i have loaded a save yet, so these might be some default values)
if you are interested for the timings for you have a look in the progressbar.xml right next to your savegame folder.
The Time for the last new game startup / savegame loading is stored there to display a more accurate progress bar i guess.. here are my values:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<progressbar>
  <type name="newgame" loaded="8">
    <step name="init" duration="9.08652"/>
    <step name="map" duration="3.49948"/>
    <step name="cutscenes" duration="0.0574339"/>
    <step name="scripts" duration="2.4005"/>
    <step name="jobs" duration="2.42529"/>
    <step name="starting" duration="2.12149"/>
  </type>
  <type name="savedgame">
    <step name="init" duration="0.5"/>
    <step name="map" duration="15"/>
    <step name="scripts" duration="1.2"/>
    <step name="init2" duration="0.3"/>
    <step name="map2" duration="4.5"/>
    <step name="scripts2" duration="1.1"/>
    <step name="patch" duration="2.3"/>
    <step name="scripts3" duration="1.1"/>
    <step name="jobs" duration="3"/>
  </type>
</progressbar>

EDIT: one more thing: using the debug command line command "reloadui" causes a short freeze of a few seconds, but using reloadai or reloadmd is only a barely noticeable hiccup. the former reloads the lua scripts for the ui, the latter the xml scripts.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

User avatar
Killjaeden
Posts: 5366
Joined: Sun, 3. Sep 06, 18:19
x3tc

Post by Killjaeden » Thu, 17. Aug 17, 11:11

UniTrader wrote:Killijaeden: did you ever open your much praised X2/X3 Scripts externally? they are also XML, and the actual Script Code is much less readable than XR Code because it baiscally abstracts all Script Commands with numerical ids.. [irony]yeah, much better than XR[/irony]
No and i can tell you why: i didnt have to, to achieve the things i wanted. I could care less if its all converted to traditional chinese first and then to Punjabi in the background. As long as i can write a script or mod without dealing with all that. So either a) use a proper programming language or b) provide the tools to make it seem like a proper programming language.
[ external image ]
X-Tended TC Mod Team Veteran.
Modeller of X3AP Split Acinonyx, Split Drake, Argon Lotan, Teladi Tern. My current work:
Image

Kitty
Posts: 304
Joined: Mon, 5. Sep 05, 19:59
x3tc

Post by Kitty » Tue, 29. Aug 17, 00:05

Just a sidenote and opinion:
I don't care if the scripts are XML or whatever.
I think that it is important that X4 can be modded by moderately educated people. In X2 and in X3 we can add scripts and ships without being an expert in programming and/or in 3D design. This is part of the pleasure of a sandbox. It would be very sad to loose that.
This aim is more important for me than the technical detail.

[/i]

User avatar
Observe
Posts: 5079
Joined: Fri, 30. Dec 05, 17:47
xr

Post by Observe » Tue, 29. Aug 17, 00:13

Mission Director XML is good with me. I am happy to hear they are keeping it. While I used it to the extent I needed, I was never a big fan of X3 scripting and was happy to see it dropped.

xirsoi
Posts: 9
Joined: Wed, 25. Mar 15, 23:18
xr

Post by xirsoi » Tue, 29. Aug 17, 06:00

j.harshaw wrote:yes. but i'm still curious.
Almost anything else? Honestly, XML is ugly and repetitive and hard to read. Of course, I don't expect you to go and roll your own DSL like Paradox does for Clauswitz (even though it is much nicer to work with), but maybe you could convert to using JSON?

There are a thousand libraries for dozens of languages for parsing JSON (i'm fond of Newtsonoft.JSON myself, use the C# implementation at work a lot) and it's super easy to work with.
stodi no na ka cenba

User avatar
JSDD
Posts: 1378
Joined: Fri, 21. Mar 14, 20:51
x3tc

Post by JSDD » Tue, 29. Aug 17, 10:23

Observe wrote:Mission Director XML is good with me. I am happy to hear they are keeping it. While I used it to the extent I needed, I was never a big fan of X3 scripting and was happy to see it dropped.
md scripting was hard to understand at first, and once you've understood the workflow, the next big problem was to keep the "overview": the bigger the script, the more likely you loose the context and make some mistakes. in msci scripting, you can easily keep parts a bit in order, for example with "gosub / endsub". besides that, there were no <xml-tags/> and you didnt had to reload the game in order to test your stuff

xirsoi wrote:Honestly, XML is ugly and repetitive and hard to read.
exactly, X3 msci scripting was also internally stored as xml, but you never had to deal with that because there was an ingame editor which displayed the script very well (procedural, kind of C-style), we could easily make changes and test them immediately, without having to reload


these posts were cut out from this topic into the S&M forum:
https://forum.egosoft.com/viewtopic.php?t=395980
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.


Mission Director Beispiele

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Tue, 29. Aug 17, 10:32

Thanks for confimring both scripting systems :) Time to dust off the knowledge in antcipation of tinkering to come!
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

User avatar
JSDD
Posts: 1378
Joined: Fri, 21. Mar 14, 20:51
x3tc

Post by JSDD » Tue, 29. Aug 17, 10:51

what we know now is that there wont be "MSCI"-style scripting, only "MD"-style
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.


Mission Director Beispiele

Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod » Sat, 11. Nov 17, 18:13

XML wouldn't be my first choice as an end-user language.

They used it for WIX installer but that felt like they probably planned to put a UI over the top and use it as a save format, but never got round to writing the UI.

gbjbaanb
Posts: 667
Joined: Sat, 25. Dec 10, 23:07
x3tc

Post by gbjbaanb » Sun, 12. Nov 17, 01:50

Shimrod wrote:XML wouldn't be my first choice as an end-user language.

They used it for WIX installer but that felt like they probably planned to put a UI over the top and use it as a save format, but never got round to writing the UI.
There are UIs for Wix. I think they made it XML so it was a standardised "command line" type interface that could be generated by something else.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 12. Nov 17, 11:49

JSDD wrote: and you didnt had to reload the game in order to test your stuff
...
without having to reload
If you just changed already existing Scripts Loading a Savegame is enough, or even faster: use the Debug Commands "reloadai" "reloadmd" and "reloadui". If new Files are added this doesnt work though, i guess because Files are indexed on Startup..
i am also pretty sure i gave you that hint multiple times already. (i even mentoined them on the previous Page)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

plamen
Posts: 7
Joined: Sun, 8. Sep 13, 20:24
x4

Post by plamen » Thu, 30. Nov 17, 17:20

Maybe someone should make a C# / Python / JavaScript / Whatever-Language compiler to XML MD.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Thu, 30. Nov 17, 19:07

plamen wrote:Maybe someone should make a C# / Python / JavaScript / Whatever-Language compiler to XML MD.
because its very unlikely it would properly utilize the mechanics of MD (Event-Based, Namespaces, MD-Instances, Expression Chains...) this would probably result in weird and inefficient code...
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Post by SirNukes » Sat, 2. Dec 17, 02:55

Conservatively compiled MD code wouldn't lose anything, unless the compiler were half baked. In general, a compiler is just a translator from some format to another format, the latter generally being closer to execution ready. If you take the trivial case of the input and output formats being matched (eg. the compiler takes MD xml code as input, and spits it back out), every MD capability would be preserved.

Xml has a lot of excess cruft that could be trimmed off, so a rudimentary compiler input format might just be a 1:1 mapping of MD nodes with an alternate syntax. Eg. a python-like syntax for block indentation would allow removal of the block closing tags like </do_all>, most of the node start/end tags ('<', '/>') could be trimmed (when not multi-lined), and most of the quotation marks could be omitted (when a space isn't present in the string).

Once the syntax is cleaned up a bit, the compiler could be expanded with extra coder convenience features, eg. function calls to be inlined at compile time, support for splitting code across multiple source files, etc. It could even have an editor built for it, similar to Exscriptor for X3, though it might be better to try to integrate into an existing developed editor, eg. setting up a custom language format for Notepad++.


On the other end of the spectrum would be a compiler that could take generic C++/Python/etc. code and process its AST into MD nodes. That would be an effort to get functional, and hard to make efficient, so it is probably too much effort for anyone to put into modding a niche spaceships game for no pay.

Post Reply

Return to “X4: Foundations”