Skip to content

Commit 72a792e

Browse files
Fix function and events see_also behavior
1 parent 954eef8 commit 72a792e

39 files changed

+91
-104
lines changed

elements/blip.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ description: |
77
The list of blip icons are available on the [Radar Blips](/radar_blips) page.
88
99
TODO
10-
see_also:
11-
- 'category:Blip functions'
12-
- 'category:Blip events'

elements/building.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@ notes:
1818
Created buildings can have **LOD models**. The procedure is as follows: spawn the LOD building using [createBuilding](/createBuilding), then use [setLowLODElement](/setLowLODElement) to associate it with the non-LOD building element you created beforehand. LOD model distance changed with [engineSetModelLODDistance](/engineSetModelLODDistance) works for buildings.
1919
- |
2020
Buildings cannot appear in certain a [dimension](/dimension), and not show in others. Function [setElementDimension](/setElementDimension) returns false on any building. A building is created in a specific [interior world](/interior) (such as 0, the main world), like the default GTA:SA landscape objects. **All buildings appear in EVERY DIMENSION.**
21-
see_also:
22-
- 'category:Building functions'
23-
- 'category:Building events'

elements/camera.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"camera"**.
66
77
TODO
8-
see_also:
9-
- 'category:Camera functions'
10-
- 'category:Camera events'

elements/col.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,3 @@ description: |
1212
The element type of this class is **"col"**.
1313
1414
TODO
15-
see_also:
16-
- 'category:Col functions'
17-
- 'category:Col events'

elements/collision_shape.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type for this class is **"colshape"**.
66
77
TODO
8-
see_also:
9-
- 'category:Collision_shape functions'
10-
- 'category:Collision_shape events'

elements/console.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,3 @@ description: |
1212
preview_images:
1313
- path: '/assets/server_console_help.jpg'
1414
description: 'Help output inside server console:'
15-
see_also:
16-
- 'category:Console functions'
17-
- 'category:Console events'

elements/dff.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ description: |
77
The element type of this class is **"dff"**.
88
99
TODO
10-
see_also:
11-
- 'category:Dff functions'
12-
- 'category:Dff events'

elements/effect.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"effect"**.
66
77
TODO: add all the effects as a table...
8-
see_also:
9-
- 'category:Effect functions'
10-
- 'category:Effect events'

elements/light.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"light"**.
66
77
TODO
8-
see_also:
9-
- 'category:Light functions'
10-
- 'category:Light events'

elements/marker.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"marker"**.
66
77
TODO
8-
see_also:
9-
- 'category:Marker functions'
10-
- 'category:Marker events'

elements/object.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,4 @@ notes:
1111
- |
1212
There is a distinction in GTA: San Andreas between static and dynamic models. The alternative [createBuilding](/createBuilding) function allows you to create objects that are non-dynamic, utilizing the GTA Building pool, which makes better use of memory.
1313
- |
14-
The [createObject](/createObject) function can also create non-dynamic objects, but for optimization reasons **it is recommended to spawn [Buildings](/building) when creating static objects that don't rely on the [Dimension](/dimension) system** (buildings don't use the same MTA object-streaming system).
15-
see_also:
16-
- 'category:Object functions'
17-
- 'category:Object events'
14+
The [createObject](/createObject) function can also create non-dynamic objects, but for optimization reasons **it is recommended to spawn [Buildings](/building) when creating static objects that don't rely on the [Dimension](/dimension) system** (buildings don't use the same MTA object-streaming system).

elements/ped.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ description: |
77
The element type of a NPC is **"ped"**.
88
99
TODO
10-
see_also:
11-
- 'category:Ped functions'
12-
- 'category:Ped events'

elements/pickup.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"pickup"**.
66
77
TODO
8-
see_also:
9-
- 'category:Pickup functions'
10-
- 'category:Pickup events'

elements/player.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"player"**.
66
77
TODO
8-
see_also:
9-
- 'category:Player functions'
10-
- 'category:Player events'

elements/projectile.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@ notes:
2121
- |
2222
**39: Satchel Charge**
2323
- |
24-
**58: Flare from Hydra**
25-
see_also:
26-
- 'category:Projectile functions'
27-
- 'category:Projectile events'
24+
**58: Flare from Hydra**

elements/radar_area.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"radararea"**.
66
77
TODO
8-
see_also:
9-
- 'category:Radar_area functions'
10-
- 'category:Radar_area events'

elements/searchlight.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"searchlight"**.
66
77
TODO
8-
see_also:
9-
- 'category:Searchlight functions'
10-
- 'category:Searchlight events'

elements/sound.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ description: |
99
The element type of this class is **"sound"**.
1010
1111
TODO
12-
see_also:
13-
- 'category:Sound functions'
14-
- 'category:Sound events'

elements/team.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ description: |
77
The element type of this class is **"team"**.
88
99
TODO
10-
see_also:
11-
- 'category:Team functions'
12-
- 'category:Team events'

elements/txd.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"txd"**.
66
77
TODO
8-
see_also:
9-
- 'category:Txd functions'
10-
- 'category:Txd events'

elements/vehicle.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"vehicle"**.
66
77
TODO
8-
see_also:
9-
- 'category:Vehicle functions'
10-
- 'category:Vehicle events'

elements/water.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ description: |
77
The element type of this class is **"water"**.
88
99
TODO
10-
see_also:
11-
- 'category:Water functions'
12-
- 'category:Water events'

elements/weapon.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ description: |
55
The element type of this class is **"weapon"**.
66
77
TODO
8-
see_also:
9-
- 'category:Weapon functions'
10-
- 'category:Weapon events'

events/Element/onClientElementInteriorChange.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,3 @@ examples:
1717
description: >
1818
Demonstrates how to detect and respond to an element's interior change.
1919
Includes vehicle creation and an event handler that reports the interior transition.
20-
notes: []
21-
preview_images: []
22-
version: {}
23-
issues: []
24-
see_also: []

events/Element/onElementInteriorChange.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,3 @@ examples:
2020
notes:
2121
- type: 'info'
2222
content: 'This is a test!'
23-
preview_images: []
24-
version: {}
25-
issues: []
26-
see_also: []

functions/Cursor/getCursorAlpha.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ client:
1616
- path: 'examples/getCursorAlpha.lua'
1717
description: |
1818
This example prints the cursor alpha to chatbox using */cursoralpha* command:
19-
see_also:
20-
- 'functions:any:Cursor'

functions/Cursor/getCursorPosition.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,4 @@ client:
3232
This example prints your cursors current world coordinates and relative screen coordinates to chatbox after using */cursorpos* command.
3333
- path: 'examples/getCursorPosition-2.lua'
3434
description: |
35-
This (untested) example uses [processLineOfSight](/processLineOfSight) to calculate the exact world location: Warning, this script causes high CPU usage!
36-
see_also:
37-
- 'functions:any:Cursor'
35+
This (untested) example uses [processLineOfSight](/processLineOfSight) to calculate the exact world location: Warning, this script causes high CPU usage!

functions/Cursor/isCursorShowing.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ shared: &shared
1313
values:
1414
- type: 'bool'
1515
name: 'result'
16-
see_also:
17-
- 'functions:any:Cursor'
1816

1917
server:
2018
<<: *shared

functions/Cursor/setCursorAlpha.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ client:
2020
- path: 'examples/setCursorAlpha.lua'
2121
description: |
2222
This example sets the cursor alpha to 100 using */cursoralpha* command:
23-
see_also:
24-
- 'functions:any:Cursor'

functions/Cursor/setCursorPosition.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,3 @@ client:
1818
- path: 'examples/setCursorPosition.lua'
1919
description: |
2020
This example sets your cursor position to the center of your screen after using the */cursorpos* command.
21-
see_also:
22-
- 'functions:any:Cursor'

functions/Element/getElementHealth.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ shared: &shared
2424
description: 'setElementHealth in onClientPlayerDamage bug'
2525
- id: 1423
2626
description: 'When you setElementHealth under onClientPlayerDamage, the local (hit) player rotates automatically'
27-
see_also:
28-
- 'functions:any:Element'
2927

3028
server:
3129
<<: *shared

functions/Element/getElementPosition.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ shared: &shared
3333
issues:
3434
- id: 928
3535
description: 'Position desync with dead players'
36-
see_also:
37-
- 'functions:any:Element'
3836

3937
server:
4038
<<: *shared

functions/Element/setElementHealth.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ shared: &shared
4141
description: 'When you setElementHealth under onClientPlayerDamage, the local (hit) player rotates automatically'
4242
- id: 448
4343
description: 'Crash when plane explode'
44-
see_also:
45-
- 'functions:any:Element'
4644

4745
server:
4846
<<: *shared

functions/Element/setElementPosition.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ shared: &shared
4040
description: 'Changing player position when they have a jetpack will remove the jetpack and bug when skin is changed'
4141
- id: 529
4242
description: 'Player falls from bike when the bike is teleported using setElementPosition'
43-
see_also:
44-
- 'functions:any:Element'
4543

4644
server:
4745
<<: *shared

schemas/common-defs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ $defs:
111111
introduce this property, then you have to be explicit about it.
112112
items:
113113
type: string
114-
pattern: "^functions:(client|server|any):[A-Za-z0-9_]+$"
114+
pattern: "^(functions|events):(client|server|any):[A-Za-z0-9_]+$"
115115
uniqueItems: true

web/src/pages/[event].astro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import fs from "fs";
66
import path from "path";
77
import { Code } from '@astrojs/starlight/components';
88
import '@src/styles/function-page.css';
9+
import { getEventSeeAlsoLinks } from '@src/utils/events';
910
1011
import NoteBox from '@src/components/NoteBox.astro';
1112
import type { NotesType } from '@src/utils/types';
@@ -55,6 +56,8 @@ let notesContent: NotesType = [];
5556
if (Array.isArray(event.data.notes) && event.data.notes.length > 0) {
5657
notesContent = event.data.notes;
5758
}
59+
60+
const seeAlsoLinks = getEventSeeAlsoLinks(event);
5861
---
5962

6063
<div class={"show-type-badge-" + eventType}>
@@ -111,5 +114,25 @@ if (Array.isArray(event.data.notes) && event.data.notes.length > 0) {
111114
))}
112115
</div>
113116
)}
117+
118+
<!-- See Also -->
119+
{seeAlsoLinks.length > 0 && (
120+
<div class="see-also-section">
121+
<h4>See Also</h4>
122+
<ul>
123+
{seeAlsoLinks.map((link: any) => (
124+
(link.name === event.id) && (
125+
<li>
126+
<strong>{link.name}</strong>
127+
</li>
128+
) || (
129+
<li>
130+
<a href={link.link}>{link.name}</a>
131+
</li>
132+
)
133+
))}
134+
</ul>
135+
</div>
136+
)}
114137
</StarlightPage>
115138
</div>

web/src/pages/[func].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ const seeAlsoLinks = getFunctionSeeAlsoLinks(func);
188188
</div>
189189
)}
190190

191-
<!-- See Also links list -->
191+
<!-- See Also -->
192192
{seeAlsoLinks.length > 0 && (
193193
<div class="see-also-section">
194194
<h4>See Also</h4>

web/src/utils/events.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,56 @@ export function getEventsByCategory(): EventsByCategory {
4545
export function getEventsByTypeByCategory(): EventsByTypeByCategory {
4646
return eventsByTypeByCategory;
4747
}
48+
49+
50+
// Gets related functions and other items (links) according to the see_also field
51+
export function getEventSeeAlsoLinks(
52+
event: EventItem
53+
): { name: string; link: string }[] {
54+
let seeAlso: string[] = event.data.see_also || [];
55+
// Add the event's own category if not already present
56+
const folder = path.basename(path.dirname(event.filePath || ''));
57+
const ownSeeAlso = 'events:any:' + folder;
58+
if (seeAlso && !seeAlso.includes(ownSeeAlso)) {
59+
seeAlso.push(ownSeeAlso);
60+
}
61+
if (!seeAlso || seeAlso.length === 0) {
62+
return [];
63+
}
64+
65+
const links = seeAlso.map((item: string) => {
66+
const parts = item.split(':');
67+
if (parts.length !== 3) return null;
68+
69+
const [itemType, eventType, eventCategory] = parts;
70+
if (itemType !== 'events') return null;
71+
72+
let eventsInCategory: EventItem[] = [];
73+
74+
switch (eventType) {
75+
case 'client':
76+
eventsInCategory = eventsByTypeByCategory.client[eventCategory] || [];
77+
break;
78+
case 'server':
79+
eventsInCategory = eventsByTypeByCategory.server[eventCategory] || [];
80+
break;
81+
case 'any':
82+
eventsInCategory = [
83+
...(eventsByTypeByCategory.client[eventCategory] || []),
84+
...(eventsByTypeByCategory.server[eventCategory] || []),
85+
];
86+
break;
87+
default:
88+
return null;
89+
}
90+
91+
return eventsInCategory.map(f => ({
92+
name: f.id,
93+
link: `/${f.id}`,
94+
}));
95+
})
96+
.filter(linkGroup => linkGroup !== null)
97+
.flat();
98+
99+
return links.sort((a, b) => a.name.localeCompare(b.name));
100+
}

0 commit comments

Comments
 (0)