Notice to Modders: Version 4.21 now on public beta! - Last updated 2017-09-08

The place to discuss scripting and game modifications for X Rebirth.

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

Posts: 39683
Joined: Tue, 29. Apr 03, 00:56

Notice to Modders: Version 4.21 now on public beta! - Last updated 2017-09-08

Post by CBJ » Tue, 13. May 14, 13:17

Keep an eye out for Beta updates in the Patch Public Beta forum. You now have the opportunity to test your mods with the new version before your players do!


Starting from Patch 2.0 we have been taking the opportunity to list some of the modding-related changes which normally go unannounced into patches.

Please note that this will always be just a subset of the changes which may have an impact on mods, but at least it provides a little more information to modders.

Release Notes

Update 2.00 (183618)
  • Added gamestarts.xml file to libraries folder allowing additional gamestarts to be defined.
  • Improved DebugLog to report the date/time when an error occurred (instead of a hard to read timestamp)
Update 2.10 (184088)
  • Fixed video-capture mode disabling/reenabling itself while keeping the assigned key pressed.
Update 2.20 (184360)
no modding related changes

Update 2.50 (187052)
  • Scripting
    • Changed mining actions to not use regions. Actions <get_resource_gatherrate>, <deplete_yield>, <find_closest_resource>, <find_resource> no longer use 'region'.
    • Action <find_asteroid_in_region> deprecated, replaced with <find_asteroid_in_cluster>
    • Changed behaviour of the negate attribute in <match_*> filters, e.g. in <find_*> actions and <count_*> conditions. The negation now affects the whole <match_*> element, which is more intuitive than the previous behaviour. For example <match_content class="class.ship" negate="true" /> now matches objects that do NOT contain a ship. (Previously it matched objects that contain any non-ship component.) Note that the negate attribute is not supported any more for <match_seller> and <match_buyer>.
    • In <set_actor_account>, attributes min/max are deprecated and have no effect any more. Use <set_actor_min/max_budget> instead.
    • Adding an object to a script group now requires that it exists (i.e. it's connected to the universe), so adding unconnected cue actors does not work any more.
    • <init> actions of AI scripts are now performed as early as possible and can be used to initialise variables for global interrupt events
    • Script <debug_text> messages will be logged if the debug filter "scripts" is enabled via launch parameters (e.g. -logfile debuglog.txt -debug scripts)
    • Script property $object.objectpurpose was renamed as .primarypurpose
    • Fixed event properties of AI scripts such as "event.param" causing errors in global interrupt conditions
  • DebugLog
    • Added gamestart counter to DebugLog which helps to see if an error occurred in the same (or a following) gamestart.
    • Added auto-clear of DebugLog data, upon game version update. (note: data won't be cleared between beta-updates).
    • removed superfluous colon from UI error message
    • Fixed DebugLog error "GetCellText() invalid table ID[...]" which could pop-up instead of a proper error message.
    • Fixed DebugLog no longer updating the displayed error, when reaching 1000 entries.
    • Fixed DebugLog popping-up again for an already shown error, after having been closed.
    • Fixed errors when old DebugLog data is corrupted.
Update 2.51 (187332)
no modding related changes

Update 3.00 (189926)
  • Scripting
    • Fixed event properties of AI scripts such as "event.param" causing errors when used in global interrupt conditions.
    • Added command "refreshai" to reload AI scripts and apply changes at run-time, see command line documentation.
    • During the removal of an object from the game (e.g. during <event_object_destroyed> without leaving a wreck), the object can no longer be added to a group, to prevent potential crashes.
    • In <add_[player_]discount> and <add_[player_]commission> the semantics of the amount attribute have changed, see XSD. Note: this change is part of the improved price calculation in v3.0.
    • Added <patch_macro> to patch single objects/components, and <patch_macros> to patch all objects in the galaxy matching the provided filter criteria. For extensions that modify existing macros, patching objects may be required after loading a savegame.
    • Changed $station.hull, $station.maxhull and $station.hullpercentage to use the total hull of all sub-components, since the actual station hull is neither visible nor possible to damage.
  • DebugLog
    • Fixed stuck X-button on screen in some cases when DebugLog closes automatically.
    • Fixed errors when pressing the down-arrow or moving the mouse-wheel down in the DebugLog.
  • Other
    • Fixed case where mods could cause multiple issues with the UI target
    • UI addons provided by Egosoft now have an "ego_" prefix.
Update 3.10 (190048)
no modding related changes

Update 3.20 (190820)
  • Scripting
    • Fixed 'finishonapproach' attribute on script move actions to use script expressions.
    • Added script support for power operator ^ (highest precedence) and function-style operators exp() and log() (natural logarithm). Results are of data type largefloat (double precision).
    • Changed sqrt() to use largefloat as well.
    • Improved script math error messages.
    • Moved "silent" attribute for interactive notifications from <show_notification> to <interaction> node. The deprecated attribute in <show_notification> still works but is removed from the XSD.
  • Other
    • Fixed Lua error: "ui/addons/ego_helpText/helptext.lua(41) - HideView(): invalid parameters".
    • Fixed certain Lua errors showing the wrong function name in the error message.
    • Changed filename for UI addons - see this thread for details.
Update 3.50 RC3 (192864)
  • Scripting
    • Fixed <debug_text> non-error messages in <conditions> having no effect.
    • Added new collision event 'event_object_collided' for detecting collisions between two objects.
    • New script datatype "table" mapping arbitrary keys to values
      • You can assign values to arbitrary keys, e.g. to $table.{1} or $table.{player.primaryship}
      • You can assign values to variable-type keys, e.g. to $table.$foo (shortcut for $table.{'$foo'})
      • Almost all values are allowed as table keys - exceptions:
        - Strings must start with '$' (bad: $, good: $table.$foo)
        - Lists, tables, groups and buildplans cannot be used as table keys
        - null cannot be used as table key (but the number 0 is valid)
      • Example syntax for creating and initialising a table:
        - "table[]" (empty table)
        - "table[$foo = 42]" (a table that maps string '$foo' to 42)
        - "table[$bar = $bar, {10} = []]" (mapping '$bar' to the value of the variable $bar, and the number 10 to an empty list)
        - "table[{$baz} = null]" (mapping the value of $baz to null)
      • Use <set_value> and <remove_value> to add/remove table entries, and "?" to check for existence of a key
      • See scriptproperties documentation for available table properties
    • MD/AI script operators "and" and "or" now have short-circuit semantics.
      • Before 3.50, both operands were evaluated before calculating the boolean result
      • "A and B": if A is false then B is not evaluated
        - Example: "$zone.isclass.highway and $zone.destination == $otherzone" (.destination is only evaluated if $zone is a highway)
      • "A or B": if A is true then B is not evaluated
        - Example: "$list == null or $list.count == 0" (.count is not evaluated if $list is null)
      • The operator results are true (1) or false (0), respectively, as before.
    • Script param $Anchor removed for move.idle - the script always operates in the current zone of the ship
    • New interfaces between Lua and MD/AI scripts: Script action <raise_lua_event> and Lua function SignalObject()
    • <find_object_component> and <count_object_components> without the recursive flag do not find contained objects any more (e.g. docked ships or drones). If this is required, use the new attribute includeobjects.
    • Improved object event conditions: Added optional check attribute to suppress errors, clarified documentation
    • Support for conditional expressions ("inline if")
      • Syntax: "if $A then $B else $C"
        - if $A is non-zero then $B is evaluated, otherwise $C is evaluated
      • Syntax without else: "if $A then $B"
        - if the condition is false then the result is null
      • There is no keyword to end the conditional expression, so use parentheses if you want to use if/then/else in a sub-expression
        - Example: "$object == (if $trade.buyer then $trade.buyer else $trade.seller) and $object.isplayerowned"
  • Other
    • New UI modding system: see this thread for details.
    • New <production> section in wares.xml allows available production methods to be modified.
    • Added several low attention combat parameters to parameters.xml.
    • Fixed and improved multiple cases of error messages.
Update 3.53 RC1 (193468)
  • Improved order in which extensions are processed: Dependencies are loaded and processed before the corresponding dependent extensions (for example The Teladi Outpost is loaded before any mods that depend on it).
  • Extensions with circular dependencies are not allowed any more and cannot be loaded.
Update 3.60 RC1 (198294)
  • Scripting
    • Removed the (broken and unused) flak functionality and associated script functionality. Wherever these outdated script actions are used they will produce errors in the log but will be skipped over at runtime, not impacting any other script functionality.
      • Removed action <activate_flaks />
      • Removed action <find_summarised_flakcontroller />
      • Removed action <set_summarised_flakcontroller_state />
      • Removed search filter <match_summarised_flakcontroller />
      • Removed property $defensible.summary.numflakcontrollers.*
    • Fixed <run_script> blocking forever if AI script does not exist.
    • Added property "$container.productionmoney" to distinguish a stable amount of money needed for continuous operation of a station (based on a 2 hour production window) as opposed to "$container.wantedmoney", which determines how much money is required to buy missing resources for completing build tasks and/or a 2-hour production window (once).
    • Removed support for attributes seller and buyer in <update_trade> that could break the trade system
    • Removed problematic script action <add_trade_offer> (only <create_trade_offer> should be used to create trade offers)
  • UI Modding
Update 4.00 RC3 (208311)
  • Scripting
    • Note that the Mission Director Guide is now available in the XR Wiki, where it is kept up to date.
    • In AI scripts, a global interrupt handler can now be triggered more than once per frame. However, as before, the interrupt actions are deferred, they are performed in correct order within the next frame. Now there is a hardcoded limit of 1024 interrupts per frame for each handler (instead of just one interrupt). The once-per-frame limitations of <run_interrupt_script> and <abort_called_scripts> still apply.
    • Improved parsing of property lookups in script expressions:
      • Lookup of constants at parse time now works for more properties than before (e.g. entitytype.pilot.skillrelevance.combat), so errors can be detected earlier in these cases.
      • Operators "@" and "?" can now also be applied to lookups that are performed at parse time, e.g. to macros, factions and wares. That way, the presence of content that was added in (other) extensions can be detected without error output.
      • Note: As a consequence, "@" must be followed by a lookup without parentheses. "@($" is not supported any more, use "@$" instead. However, "@($" is allowed; the "@" only affects the lookup of the "baz" property.
    • Added several number formatting options. For details, see the MD guide (sections "Strings and formatting" and "Money and time formatting").
    • Added a parser warning if a possibly incorrect use of the "not" operator is detected, for example in "not $a == $b". Analogously to other programming languages, "not" has a higher precedence than comparison operators, which may be unexpected. The example above is parsed as "(not $a) == $b". Instead, you should write "$a != $b" or use parentheses.
    • In jobs.xml, AI script parameters can now be defined as script expressions in a value attribute (but string/int/float/... attributes are still supported).
    • Fixed <match_any> always matching if a contained <match_*> element used both min and max attributes, e.g. <match_shield min="40" max="60" />
    • Fixed several <find_*> and <get_*> actions returning null instead of an empty list if nothing was found.
    • Removed "textpage" datatype; the expression "readtext.{$number}" without a following text ID is not supported any more.
    • The type property ($entity.type) is now null for characters that don't have an entity type (instead of an "unknown" value that can't be represented in script expressions).
    • In <find_*> actions and <count_*> conditions, entitytype="null" is now allowed and restricts the search to entities without a type.
    • <add_buy/sell_order> and <remove_trade_order> can now be used on player-owned ships that have a commander that is not the player.
    • Added distinction between ware reservations of types "buy" and "sell".
      • When loading savegames from versions before 4.0 B4 HF2, all ware reservations are wiped and restored by patch code.
      • Mod scripts should use patch actions to restore their own reservations if required.
      • <add|get_ware_reservation> actions require the type ("buy" or "sell") to be specified.
      • <remove_ware_reservation> supports the type attribute as optional filter.
    • Fixed "hasmasstraffic" property being true for stations without mass traffic ships.
  • UI Modding
  • Other
    • Extensions can now have "optional" dependencies in content.xml (with optional="true"). Such dependencies are not required and not shown in the UI, but they affect the loading order (i.e. the order in which XML files are patched); dependencies are loaded first. The version is checked only if the dependency is present.
    • XML patching: Elements <add>, <remove> and <replace> can now have the attribute silent="true" to suppress error output if the XPath cannot be matched (e.g. because it affects an optional dependency that is not present).
    • XML patching: Fixed incorrect patching when <add> or <replace> contain multiple elements (changes were applied in wrong order).
    • Extensions in the personal folder are now fully supported (if placed in a sub-folder "extensions", alongside your "save" folder).
    • targetpoints.xml: Sequence and stage can now be defined in attributes (old file format is still supported).
    • Added game time to debug log entries in log files (parameter -logfile <filename>).
Update 4.10 RC1 (229356)
  • Scripting
    • Changed the way AI script parameters are evaluated: Default values are only assigned to parameters that were not provided by the caller (previously all default values were evaluated, possibly causing errors).
  • UI Modding
Update 4.21 Beta 1 (246976)
Last edited by CBJ on Fri, 7. Nov 14, 14:21, edited 11 times in total.


Return to “X Rebirth - Scripts and Modding”