btech package

require("btech") returns the built-in BattleTech API. It is available to running Lua callbacks, but not during @lua/check. The package adapts the server’s trusted BattleTech scripting handlers to Lua and invokes them with server authority.

Arguments use Lua strings, numbers, and booleans; object arguments are native dbrefs rather than Object handles. Invalid objects, arguments, or legacy error results raise Lua errors. Successful results are converted to the type documented for each function. Mutation-only operations return true. List operations split the legacy result on whitespace and |, convert numeric tokens (including #123) to Lua numbers, and return a flat array.

Functions

Unit data

FunctionDescription
btech.armor_statusReturns serialized armor values for one section of a live unit.
btech.armor_status_refReturns serialized armor values for one section of a unit template.
btech.crit_slotDescribes one critical slot on a live unit.
btech.crit_slot_refDescribes one critical slot in a unit template.
btech.section_statusReturns serialized status for one section of a live unit.
btech.crit_statusReturns serialized critical-slot status for one section of a live unit.
btech.crit_status_refReturns serialized critical-slot status for one section of a unit template.
btech.damage_mechApplies clustered damage to a live unit.
btech.damagesReturns the formatted repair-job description for a live unit.
btech.engine_ratingReturns the engine rating of a live unit.
btech.engine_rating_refReturns the engine rating of a unit template.
btech.real_max_speedReturns a live unit’s effective maximum speed.
btech.get_weightReturns a part’s weight in tons.
btech.payload_refReturns the weapon and ammunition payload of a unit template.
btech.show_crit_status_refSends a template’s critical-status display to a player.
btech.show_status_refSends a unit template’s status display to a player.
btech.show_weapon_specs_refSends a unit template’s weapon-specification display to a player.
btech.thresholdReturns the configured experience threshold for a skill.
btech.tic_weaponsLists the weapons assigned to a unit’s target-interlock circuit.
btech.weapon_statusReturns serialized weapon status for a live unit or one section.
btech.weapon_status_refReturns serialized weapon status for a unit template or one section.
btech.weapon_statReturns one numeric weapon-catalog statistic as text.

Unit mutation and loading

FunctionDescription
btech.xcode_valueReads a script-visible native field from a live special object.
btech.xcode_value_refReads a script-visible native field from a unit template.
btech.load_mapLoads a map file into a map object and clears its units and map objects.
btech.load_mechLoads a unit template into a live unit object.
btech.set_armor_statusSets one armor-status field on a live unit section.
btech.set_max_speedSets a live unit’s maximum speed and corrects its current speed.
btech.set_tonsSets a live unit’s tonnage and original weight.
btech.set_xcode_valueWrites a script-writable native field on a live special object.
btech.set_xyPlaces a live unit on a map at specified coordinates.
btech.update_linksRecursively updates links associated with a map.

Maps and geometry

FunctionDescription
btech.rangeCalculates distance between units or map coordinates.
btech.hex_emitBroadcasts a message from one map hex.
btech.hex_in_blast_zoneTests whether a map hex lies in a configured blast zone.
btech.hex_line_of_sightTests whether a live unit has unobstructed line of sight to a map hex.
btech.blast_zonesLists blast-zone coordinates and radii on a map.
btech.mech_line_of_sightTests line of sight between two live units.
btech.map_elevationReturns the elevation of a map hex.
btech.map_emitBroadcasts a message to all or nearby units on a map.
btech.map_terrainReturns the terrain code of a map hex.
btech.map_unitsLists all units on a map or those within a 2D or 3D range.

Parts, stores, and economy

FunctionDescription
btech.add_storesAdds a quantity of a part to an object’s stores.
btech.fasa_base_cost_refCalculates the FASA base cost of a unit template.
btech.battle_valueCalculates the battle value of a live unit.
btech.battle_value_refCalculates the battle value of a unit template.
btech.battle_value2_refCalculates the second-generation battle value of a unit template.
btech.defensive_battle_value_refCalculates the defensive battle-value component of a unit template.
btech.offensive_battle_value_refCalculates the offensive battle-value component of a unit template.
btech.part_costReturns the configured cost of a part.
btech.part_typeReturns the broad category of a part.
btech.part_matchFinds packed part IDs whose names match a string.
btech.part_nameReturns a name for a packed part ID.
btech.part_categoriesLists the canonical categories accepted by btech.parts.
btech.partsLists canonical long part names in one category.
btech.part_weightReturns a part’s weight in tons.
btech.remove_storesRemoves a quantity of a part from an object’s stores.
btech.set_part_costSets the configured cost of a part.
btech.storesReturns a part quantity or lists an object’s stored parts.
btech.stores_shortReturns a part quantity or lists stored parts using short names.
btech.unit_fixableTests whether a live unit can be repaired.
btech.unit_partsLists the parts installed on a live unit.
btech.unit_parts_refLists the parts installed in a unit template.

Characters and repair

FunctionDescription
btech.char_listLists character value names in a requested category.
btech.char_valueGets a character attribute, skill level, target, experience, or experience threshold.
btech.make_pilot_rollMakes a piloting roll and causes a fall when it fails.
btech.repair_job_countReturns the number of pending repair jobs on a live unit.
btech.set_char_valueSets a character value or adjusts skill experience.
btech.tech_listLists the parts needed to repair a live unit.
btech.tech_list_refLists the parts needed to repair a unit template.
btech.tech_statusReturns formatted repair status for a live unit.
btech.tech_timeRuns the legacy technician-time query.
btech.under_repairTests whether a live unit has an active repair event.

Utilities

FunctionDescription
btech.design_existsTests whether a unit template exists.
btech.id_to_dbrefResolves a two-character tactical ID on a unit’s map.
btech.lagReturns the current BattleTech event lag.
btech.mech_frequenciesLists the configured radio channels of a live unit.
btech.zone_mechsLists live unit objects assigned to a zone.