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

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Sat, 5. Aug 17, 01:35

Killjaeden wrote: even X3 SE code was much more readable than this <comment/> <make_italic/> <text="mess"/></make_italic></comment>
Why would you try to read things like that line when you can stick stuff in something like Notepad++? That makes it look harder than it is.

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

Post by Killjaeden » Sat, 5. Aug 17, 01:51

Why would you try to read things like that line when you can stick stuff in something like Notepad++?
Oh yes it shows the tree view for you. So why did you choose to xml it up in the first place like that? XML is like removing all Text formating and instead describing it with words, so the tools can then interpret your words as formating. Does that sound usefull to you? To me it seems like a giant waste of time and space.

Code: Select all

<reply>
	<sentence>
		<question>
			<string ="why do you need this bollocks when you format it eitherway and therefore context is given already without need for this bollocks"/>
		</question>
   <new line/>
	<sentence>
		<statement>
			<string = "This is a waste of time to write and read and does not help comprehension one bit"/>
		</statement>
	</sentence>
</reply>
[ external image ]
X-Tended TC Mod Team Veteran.
Modeller of X3AP Split Acinonyx, Split Drake, Argon Lotan, Teladi Tern. My current work:
Image

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

Post by jack775544 » Sat, 5. Aug 17, 11:09

Ketraar wrote:The problem most people that are rather trained in programming forget that many modders (like myself) have ZERO programming skills and still would like to keep modding without having to turn it into a full time job or require degree to do it. So I for one am glad they switched to xml verbose, but somewhat "casual" structure and allow non programmers to do stuff. :-)

MFG

Ketraar
That is a fair enough point, but I think you underestimate the ease of use that some mainstream programming languages have. Python is commonly used to introduce programming to high school students nowadays, but at the same time it is powerful enough to be used by almost every large tech company for some role or another.
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

Taleth
Posts: 2
Joined: Fri, 25. Mar 16, 11:14

Post by Taleth » Sat, 5. Aug 17, 11:12

Quite dissapointed with the responses here. XML scripting should be retained as a legacy scripting method. But scripting/modding should be done through a proper programming language like python or even better, C#.

See the most modded game on Steam, Space Engineers, for an example of how this works very well, even for people who don't yet know C# it can be picked up easily. It's not difficult at the outset and the tooling support for it is far and away better for a staticly typed language then for XML which speeds up learning.

There is a game called 'Empyrion Galatic Survival' which supports this style of modding, with it I managed to send the events generated by the game to a message bus (MSMQ) which is read by a webserver that hosts a single page application. Imagine a dashboard like this http://wrapbootstrap.com/preview/WB0R5L90S to get an idea of what I'm talking about. Keeping in mind this is accessible from any browser like your phone, the steam browser or your smart tv. Imagine it populated with data from your ships, stations and warehouses ... yeah.

CBJ
EGOSOFT
EGOSOFT
Posts: 51741
Joined: Tue, 29. Apr 03, 00:56
x4

Post by CBJ » Sat, 5. Aug 17, 18:41

Since all of it still applies, I will quote the answer I gave last time this discussion came up:
CBJ wrote:Some of the original reasons for choosing XML for the MD were:

- Domain-specific structure (it's laid out in the form of the conditions and actions required for mission progress) and syntax (many of the conditions and actions are directly mapped to mission activities rather than just being generic programming terms)
- Missions can be created with very limited programming knowledge (while it's possible to do programmer-y things like loops, it is also possible to create simple missions entirely without this, which helps with the learning curve)
- Editing comes with built-in self-documentation as well as syntax auto-completion (most self-respecting XML editors understand schemas, and the schemas can also be used to provide the documentation)
- Easy to parse and convert to internal format (it is loaded and parsed very simply using standard XML libraries, then converted into an internal form that is that is, like the raw syntax, closely tied to its purpose, rather than using a generic third party interpreter or JIT compiler)

Now, bearing in mind that we have been working with the MD, in one form or another, for nearly 10 years, the reason we continue to use it is very simple: we have it, it works, and it does what mission developers need it to. The AI scripting system shares some key elements, such as actions and conditions, with the MD, saving a lot of effort in maintenance and development, but is, again, tailored to the task in hand. It would be a very poor use of developer time to throw all that away in favour of something different, with all the issues and unknowns that would come with it, just because some people turn their noses up at it for being XML rather than a "proper" programming language.

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.

Post Reply

Return to “X4: Foundations”