Results 1 to 10 of 10

Thread: XML programing help, xrebirth linux edition

  1. #1

    Default XML programing help, xrebirth linux edition

    I want to modify a mod called 'improved engineer'. I know many programming languages and many years of experience in linux and mswin. I can't make any sense of the syntax. I need a good guild to XML programming and with many examples, a free download.

    Also, It would help if someone could break down parts of that code.

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,788

    Default Re: XML programing help, xrebirth linux edition

    Personally I would not call XML a programming language. Like I would not call HTML a programming language.

    https://en.wikipedia.org/wiki/XML

    https://www.w3schools.com/xml/
    Henk van Velden

  3. #3
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,295
    Blog Entries
    2

    Default Re: XML programing help, xrebirth linux edition

    The second link provided by Henk is an instructive example,
    XML is is data stored in a way that is hierarchical, using "markup" which means that each data point is enclosed in tags.
    The hierarchical nature has advantages over other "flat" text based data arrays like delimited text.
    Because markup is text-based and easy to understand, it has become a favorite way for not only storing data but also transferring data between systems because tags are easy to parse, clearly allowing the data that remains to be converted into other formats and data types.

    As such, data is static but can be consumed by a program for any purpose.

    So,
    You have various XML variations that adhere to a schema, like JSON.
    You can also use XML to store web page code, but that is not seen too much today because of its many uncomfortable restrictions with little additional benefit compared to HTML.

    HTH,
    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  4. #4

    Arrow Re: XML programing help, xrebirth linux edition

    Thanks, that was very useful. 'improved engineer' here is some of that code. You can get this off 'nexus mods - xrebirth'

    content.xml authors info page
    <?xml version="1.0" encoding="utf-8"?>
    <content id="ImprovedEngineer" name="Improved Engineer" description="Complete rewrite of the engineer ai.
    Include support for emergency repairs and repair using in flight drones, as well as engineer skills and morale.

    See mod forum post on egosoft for more details" author="Jey123456" version="0.98" date="2013-11-23">
    <text language="44" name="Improved Engineer" description="Complete rewrite of the engineer ai.
    Include support for emergency repairs and repair using in flight drones, as well as engineer skills and morale.

    See mod forum post on egosoft for more details" author="Jey123456" version="0.98" />
    </content>

    <interrupt_after_time time="(0+@$iterationSpeed) + 1s"/> ??


    <set_value name="$EngineerWreckRestoreDelay" exact="30"/> $EngineerWreckRestoreDelay="30" (DEC) Right?

    <set_value name="$overallRepairRate" exact="45f" /> $overallRepairRate="45.00" (FLOAT)

    set_value name="$moralInc" exact="(1f+this.skill.morale)/5f"/> <!-- how much morale is added for every cycle where the engineer is not busy -->
    $moralInc= (1.00 + this.skill.morale) / 5.00" this->skill->morale

    <do_if value="not $accumulatedPerc?"> if value nonzero?
    <set_value name="$lastEngineerWreckRestore" exact="player.age"/>
    <set_value name="$lastEngineerRepair" exact="player.age"/>
    <set_value name="$lastEngineerDrone" exact="player.age - $EngineerRepairRate"/>
    <set_value name="$lastEngineerStatus" exact="player.age - $EngineerCheckStatus"/>
    <set_value name="$lastEngineerMorale" exact="player.age"/>
    <set_value name="$welderdronesScore" exact="0"/>
    <set_value name="$welderdronesLaunched" exact="0"/>
    <set_value name="$morallevel" exact="100f"/> <!-- A value from 125 to 25 that slowly increase when not busy, and decrease when busy, the rate at which it increase and decrease is affected by morale skill 125 mean 25% better at everything. 25 mean 1/4 as good at everything-->
    <set_value name="$nextRepairTargetValue" exact="0"/>
    <create_group groupname="$damagedelements" />
    <create_group groupname="$wreckedelements" />
    <set_value name="$lastEngineerMessage" exact="'Setting up'"/>
    <set_value name="$lastEngineerDebugDelta" exact="''"/>
    <set_value name="$lastEngineerDebug" exact="''"/> <!-- used to output all sort of debug info depending on what we want. Just set the value and uncomment the line that print it to the info panel -->
    <set_value name="$lastEngineerMessageTime" exact="player.age - 30"/>
    <set_value name="$accumulatedPerc" exact="0f"/>
    </do_if>


    <do_if value="$welderdronesScore ge 1"> <!-- We have welding drones on board, so we can repair the hull a lot more -->
    <set_value name="$EngineerRepairHullMaxPerc" exact="50"/>
    </do_if>

    if $welderdronesScore >= 1 then
    $EngineerRepairHullMaxPerc"="50"
    endif


    <do_if value="this.ship != null">
    <do_if value="(this.ship.exists) and (this.ship.isplayerowned)">
    <set_value name="$distanceToPlayerShip" exact="player.primaryship.distanceto.{this.ship}"/>
    <set_value name="$withinDecentRange" exact="($distanceToPlayerShip != null) and ($distanceToPlayerShip le 60000m)" /> <!-- beyond 60km... we can slowdown our iteration rate a bit and it wouldnt really matter, average repair will be the same just not as smooth -->
    <set_value name="$withinCommRange" exact="($distanceToPlayerShip != null) and ($distanceToPlayerShip le 1500m)" />
    <set_value name="$extremelyClose" exact="($distanceToPlayerShip != null) and ($distanceToPlayerShip le 150m)" />
    </do_if>
    </do_if>


    if this->ship != null # valid ship?
    if (this.ship.exists != 0) and (this.ship.isplayerowned != 0)">

    <set_value name="$withinDecentRange" exact="($distanceToPlayerShip != null) and ($distanceToPlayerShip le 60000m)" />
    Both values true.

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,788

    Default Re: XML programing help, xrebirth linux edition

    I have no idea what you want to tell us, but as long as you do not post computer code parts between CODE tags, I am not even trying to read this.
    Henk van Velden

  6. #6
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,788

    Default Re: XML programing help, xrebirth linux edition

    Quote Originally Posted by tsu2 View Post
    The second link provided by Henk is an instructive example,
    Offering the link wasn't really magic. Using Google to search for XML of course showed the Wikipedia one and the top one said "XML tutorial". Something that everyone knowing many programming languages and having many years of experience in linux and mswin could easily have done.
    Henk van Velden

  7. #7

    Default Re: XML programing help, xrebirth linux edition

    Based on your experience with XML, am I interpreting the XML correctly? XML is more a general database storage system. It can be used as programming system by the program that uses reads. That's correct?

    Does it appear that i'm reading the code snips correctly? Based on your programming experience.

  8. #8
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,295
    Blog Entries
    2

    Default Re: XML programing help, xrebirth linux edition

    The XML you posted appears to be an example of what I described in my prior post, it's possible to create a web page using xml in place of the more common html (or even sgml).

    The first line declares the xml schema, but a declaration of the script engine to use is missing. It's likely assumed that javascript will be used as default or is defined elsewhere, possibly globally.

    The various elements in the xml include markup tags, many of which are common to most major markup languages.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,788

    Default Re: XML programing help, xrebirth linux edition

    Quote Originally Posted by lord_valarian View Post
    Based on your experience with XML, am I interpreting the XML correctly? XML is more a general database storage system. It can be used as programming system by the program that uses reads. That's correct?

    Does it appear that i'm reading the code snips correctly? Based on your programming experience.
    As I said, i will not try to unravel your post without it being posted with proper usage of CODE tags.

    Also, I have no experience with XML (I have btw with HTML), but I have (end-user) experience in using Google, thus I was able to find within seconds an article about what XML is (in Wikipedia) and a tutorial (as you asked for). One does not need any experience with cooking to be able to find cooking recipes on the internet.
    Henk van Velden

  10. #10
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,576

    Smile Re: XML programing help, xrebirth linux edition

    Quote Originally Posted by lord_valarian View Post
    am I interpreting the XML correctly? XML is more a general database storage system. It can be used as programming system by the program that uses reads. That's correct?
    No, XML is nothing more or less than a (powerful) markup language -- the 'X' means "Extended" -- with everything that means in a markup sense . . .
    Yes, W3C have defined the means to import things such as "schema" which then influence the behaviour of the markup at execution time; the details are in the W3C Recommendations. Things such as SOAP use XML for message formatting.

    There's an O'Reilly reference book for XML: "XML in a Nutshell": ISBN: 978-0596007645.

    An (Open Source) XML editor? Apart from 'vim' or 'Emacs', there's "KXml Editor", "Bluefish", "Quanta".
    A good XML editor however, costs money, real money: OxygenXML -- (XMLSpy is "Redmond-only").
    "You pays your money and, you takes your choice!!!"

    BTW, there's a W3C News Feed for all the latest in that world: <https://www.w3.org/blog/news/feed>.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •