Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guide/scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Each example mod shows one part of the scripting. Its files have comments:
| [`interceptor`](../../examples/mods/interceptor) | A mod's ship type, flown in a [game mode](#game-modes) |
| [`main-menu`](../../examples/mods/main-menu) | [Replacing a screen](#replacing-a-screen) of the front end |
| [`music`](../../examples/mods/music) | A piece of music that replaces the game's and keeps its [loop point](modding.md#music), and a track of [the CD player](#the-cd-players-tracks) that plays it, from a load script |
| [`rules`](../../examples/mods/rules) | [Hooks](#hooks) on the game's functions |
| [`rules`](../../examples/mods/rules) | [Hooks](#hooks) on damage and orders, [order targets](#targets), and mission events |
| [`strafe-run`](../../examples/mods/strafe-run) | A custom order, a [HUD display](#hud-displays), a [camera view](#camera-views), a [screen](#screens) and [actions](#keys-and-actions), through the [built-in interfaces](#built-in-interfaces) |
| [`tally`](../../examples/mods/tally) | [Saved games](#saved-games), [storage](#storage) and [timers](#timers) |
| [`teapot`](../../examples/mods/teapot) | A mod's ship type with its own model, and the [`radio_say`](#changing-what-the-radio-says) hook |
Expand Down
1 change: 1 addition & 0 deletions docs/guide/what-mods-can-do.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ A mod never changes the files of the game on disk. On the mods screen, players t
| A mod can | Read | Example |
|---|---|---|
| Hook the functions of the game, such as damage, shots, missile launches, orders and the commands of the mission script, to change or stop them | [Hooks](scripting.md#hooks) | [`rules`](../../examples/mods/rules) |
| Inspect an order's target and react when orders are pushed or popped | [Targets](scripting.md#targets) | [`rules`](../../examples/mods/rules) |
| React to the events of the mission, such as a destroyed or docked ship | [Mission and engine events](scripting.md#mission-and-engine-events) | [`rules`](../../examples/mods/rules), [`tally`](../../examples/mods/tally) |
| Change what the radio says | [Changing what the radio says](scripting.md#changing-what-the-radio-says) | [`arena`](../../examples/mods/arena), [`teapot`](../../examples/mods/teapot) |
| Run a script on each ship of a class or a type | [Object scripts](scripting.md#object-scripts) | [`wingmen`](../../examples/mods/wingmen) |
Expand Down
2 changes: 1 addition & 1 deletion examples/mods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ or go away in any release. Copy one as a starting point for your own mod.
| [`interceptor`](interceptor) | A new ship type, based on the Predator, flown in a game mode |
| [`main-menu`](main-menu) | A main menu of the mod's own in place of the game's |
| [`music`](music) | A piece of music in place of the main menu's, which loops back where the game's does, and a track of the CD player that plays it |
| [`rules`](rules) | Hooks on the game's functions |
| [`rules`](rules) | Hooks on damage and orders, order targets, and mission events |
| [`strafe-run`](strafe-run) | A custom order with a HUD display, a chase camera and rebindable actions |
| [`tally`](tally) | Storage kept with each saved game and across every game |
| [`teapot`](teapot) | A ship type with a model of its own, built from OBJ (`sltool shp from-obj`), and its own cockpit, display pictures and engine sound, offered on the loadout screen |
Expand Down
17 changes: 17 additions & 0 deletions examples/mods/rules/rules.luau
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ for _, name in { "object_damage", "object_armor_damage", "component_damage" } do
end)
end

-- Show the target of orders pushed for the player's ship. The target table can
-- also name a flight group or a squadron, and every field is nil without one.
hooks.add("order_push", function(e)
if e.object.is_player then
local target = e.target.object and "a ship" or "no ship object"
print("Order pushed: " .. tostring(e.order) .. "; target: " .. target)
end
end)

-- order_pop has no order or target fields. It runs when an order ends, and its
-- result says whether the object had an order to pop.
hooks.add("order_pop", function(e)
if e.object.is_player then
print("Order popped for the player's ship")
end
end)

-- The player's kill streak in this mission, from the mission's event destroyed.
local streak = 0
hooks.add("destroyed", function(e)
Expand Down