Skip to content

Commit efeab94

Browse files
Refactor OOP classes
1 parent 52b1d0b commit efeab94

35 files changed

+203
-296
lines changed

.github/workflows/validate.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ on:
66
- 'elements/**/*.yaml'
77
- 'events/**/*.yaml'
88
- 'functions/**/*.yaml'
9-
- 'classes/**/*.yaml'
109
- 'schemas/**/*.yaml'
1110
pull_request:
1211
paths:
1312
- 'elements/**/*.yaml'
1413
- 'events/**/*.yaml'
1514
- 'functions/**/*.yaml'
16-
- 'classes/**/*.yaml'
1715
- 'schemas/**/*.yaml'
1816
workflow_dispatch:
1917

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
"schemas/function.yaml": "/functions/**/*",
44
"schemas/element.yaml": "/elements/**/*",
55
"schemas/event.yaml": "/events/**/*",
6-
"schemas/class.yaml": "/classes/**/*",
76
}
87
}

classes/Vector/Vector4.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

classes/Matrix/Matrix.yaml renamed to elements/Matrix/Matrix.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'matrix'
22
description: |
33
Matrices are one of the most powerful features of MTA [OOP](/OOP). We did have a presence of Matrices before with [getElementMatrix](/getElementMatrix), but we were given an ugly disgusting table to play with. Now, with the new Matrix class, we can make and magically manipulate Matrices.
44
5-
methods:
5+
oop_methods:
66
- name: create
77
description: |
88
Default constructor for the Matrix class. Returns a Matrix object.

classes/Vector/Vector2.yaml renamed to elements/Vector/Vector2.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
name: 'vector2'
22
description: |
33
This is a 2D [Vector](/Vector) class.
4-
methods:
4+
oop_methods:
55
- name: create
66
description: |
77
Default constructor for the Vector2 class. Returns a Vector2 object.
8-
overloads:
9-
- signature: Vector2(mixed vectorOrX[, float y])
10-
parameters:
11-
- name: vectorOrX
12-
type: float | table | vector2
13-
description: Vector2, table, or float indicating vector's coordinates
14-
- name: y
15-
type: float
16-
optional: true
17-
description: If vectorOrX is a float, this is the Y coordinate
8+
signature: Vector2(mixed vectorOrX[, float y])
9+
parameters:
10+
- name: vectorOrX
11+
type: float | table | vector2
12+
description: Vector2, table, or float indicating vector's coordinates
13+
- name: y
14+
type: float
15+
optional: true
16+
description: If vectorOrX is a float, this is the Y coordinate
1817

1918
- name: normalize
2019
description: Normalizes the vector

classes/Vector/Vector3.yaml renamed to elements/Vector/Vector3.yaml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@ name: Vector3
22
type: class
33
description: |
44
Represents a 3D [Vector](/Vector). Used for storing and manipulating three-dimensional coordinates (x, y, z).
5-
methods:
5+
oop_methods:
66
- name: create
77
description: |
88
Default constructor for the Vector3 class. Returns a Vector3 object.
9-
overloads:
10-
- signature: Vector3(mixed vectorOrX[, float y, float z])
11-
parameters:
12-
- name: vectorOrX
13-
type: float | table | vector3
14-
description: Vector3, table, or floats indicating vector's coordinates
15-
- name: y
16-
type: float
17-
optional: true
18-
description: If vectorOrX is a float, this is the Y coordinate
19-
- name: z
20-
type: float
21-
optional: true
22-
description: If vectorOrX is a float, this is the Z coordinate
9+
signature: Vector3(mixed vectorOrX[, float y, float z])
10+
parameters:
11+
- name: vectorOrX
12+
type: float | table | vector3
13+
description: Vector3, table, or floats indicating vector's coordinates
14+
- name: y
15+
type: float
16+
optional: true
17+
description: If vectorOrX is a float, this is the Y coordinate
18+
- name: z
19+
type: float
20+
optional: true
21+
description: If vectorOrX is a float, this is the Z coordinate
2322

2423
- name: cross
2524
type: method

elements/Vector/Vector4.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Vector4
2+
type: class
3+
description: |
4+
Represents a 4D [Vector](/Vector).
5+
oop_methods:
6+
- name: create
7+
description: |
8+
Default constructor for the Vector4 class. Returns a Vector4 object.
9+
signature: Vector4(mixed vectorOrX[, float y, float z, float w])
10+
parameters:
11+
- name: vectorOrX
12+
type: float | table | vector4
13+
description: Vector4, table, or floats indicating vector's coordinates
14+
- name: y
15+
type: float
16+
optional: true
17+
description: If vectorOrX is a float, this is the Y coordinate
18+
- name: z
19+
type: float
20+
optional: true
21+
description: If vectorOrX is a float, this is the Z coordinate
22+
- name: w
23+
type: float
24+
optional: true
25+
description: If vectorOrX is a float, this is the W coordinate
26+
27+
examples:
28+
- path: examples/vector4-1.lua
29+
description: This example adds a command called "/garage", allowing you to get any garage bounding box.

schemas/class.yaml

Lines changed: 0 additions & 59 deletions
This file was deleted.

schemas/element.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,47 @@ properties:
1717
description: A list of noteworthy pieces of information for the item.
1818
items:
1919
type: string
20+
examples:
21+
$ref: 'common-defs.yaml#/$defs/examples'
2022
see_also:
2123
$ref: 'common-defs.yaml#/$defs/see_also'
24+
oop_methods:
25+
type: array
26+
items:
27+
type: object
28+
required:
29+
- name
30+
properties:
31+
name:
32+
type: string
33+
description:
34+
type: string
35+
signature:
36+
type: string
37+
overloads:
38+
type: array
39+
items:
40+
type: object
41+
required:
42+
- signature
43+
properties:
44+
signature:
45+
type: string
46+
description:
47+
type: string
48+
parameters:
49+
type: array
50+
items:
51+
type: object
52+
required:
53+
- name
54+
- type
55+
properties:
56+
name:
57+
type: string
58+
type:
59+
type: string
60+
description:
61+
type: string
62+
optional:
63+
type: boolean

tools/validate.cmd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,3 @@ for /r "elements" %%f in (*.yaml) do (
1111
for /r "events" %%f in (*.yaml) do (
1212
.\tools\yajsv.exe -s schemas/event.yaml -r schemas/common-defs.yaml "%%f"
1313
)
14-
15-
for /r "classes" %%f in (*.yaml) do (
16-
.\tools\yajsv.exe -s schemas/class.yaml -r schemas/common-defs.yaml "%%f"
17-
)

tools/validate.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
find 'functions/' -name '*.yaml' -type f -print0 | xargs -0 -I {} tools/yajsv -s schemas/function.yaml -r schemas/common-defs.yaml {}
44
find 'elements/' -name '*.yaml' -type f -print0 | xargs -0 -I {} tools/yajsv -s schemas/element.yaml -r schemas/common-defs.yaml {}
55
find 'events/' -name '*.yaml' -type f -print0 | xargs -0 -I {} tools/yajsv -s schemas/event.yaml -r schemas/common-defs.yaml {}
6-
find 'classes/' -name '*.yaml' -type f -print0 | xargs -0 -I {} tools/yajsv -s schemas/class.yaml -r schemas/common-defs.yaml {}

web/public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/wiki/ /
22
/wiki/* /:splat
3+
/Main_Page /
34

45
/MTA_Classes /Element
56
/Element/:elementname /:elementname

web/src/content.config.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,4 @@ export const collections = {
3535
}
3636
}),
3737
}),
38-
classes: defineCollection({
39-
loader: glob({
40-
pattern: "**/*.yaml",
41-
base: "../classes",
42-
generateId: ({ entry }) => {
43-
// Extract the file name without the folder
44-
return ((entry.split('/') || []).pop() || '').replace(/\.yaml$/, '');
45-
}
46-
})
47-
}),
4838
};

web/src/overrides/Pagination.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { CardGrid } from '@astrojs/starlight/components';
33
import IconLinkCard from '@src/components/IconLinkCard.astro';
44
---
5+
<hr>
56

67
<CardGrid>
78
<IconLinkCard

web/src/pages/Element.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
33
import { getSeeAlsoLinksFromList } from '@src/utils/general';
44
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
5-
import { getElementsByCategory } from '@src/utils/elements';
5+
import { getElementsByCategory, hasOopMethods } from '@src/utils/elements';
66
const elementsByCategory = getElementsByCategory();
77
---
88
<StarlightPage frontmatter={{
@@ -22,6 +22,7 @@ const elementsByCategory = getElementsByCategory();
2222
{elements.map(element => (
2323
<li>
2424
<a href={`/${element.id}`}>{element.id}</a>
25+
{hasOopMethods(element) ? <span class="small-text">[OOP]</span> : ''}
2526
</li>
2627
))}
2728
</ul>

web/src/pages/OOP_Classes.astro

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
33
import { getSeeAlsoLinksFromList } from '@src/utils/general';
44
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
5-
import { getOOPClassesByCategory } from '@src/utils/classes';
6-
const classesByCategory = getOOPClassesByCategory();
5+
import { getOOPElementsByCategory } from '@src/utils/elements';
6+
const elementsByCategory = getOOPElementsByCategory();
77
---
88
<StarlightPage frontmatter={{
99
template: 'doc',
1010
title: 'OOP Classes',
1111
tableOfContents: false,
1212
}}>
13-
<p>This page lists all <strong><a href="/OOP">OOP</a> Classes</strong> available in the <a href="/Lua_API">Lua API</a> organized by category.</p>
14-
<p>Vectors and Matrices make it easier to drop the complex maths and go straight ahead with fun part of maths. OOP does not have to be enabled in the server config for this to be enabled.</p>
13+
<p>This page lists all <strong>Classes</strong> available in the <a href="/Lua_API">Lua API</a> using <a href="/OOP_Introduction">OOP</a> organized by category.</p>
14+
15+
<p><strong>Vectors</strong> and <strong>Matrices</strong> make it easier to drop the complex maths and go straight ahead with fun part of maths. OOP does not have to be enabled in the server config for this to be enabled.</p>
1516

16-
{Object.entries(classesByCategory).map(([category, oopClasses]) => (
17+
{Object.entries(elementsByCategory).map(([category, elements]) => (
1718
<section>
18-
<details>
19+
<details open>
1920
<summary>{category} classes</summary>
2021
<ul>
21-
{oopClasses.map(oopClass => (
22-
<li><a href={`/${oopClass.id}`}>{oopClass.id}</a></li>
22+
{elements.map(element => (
23+
<li><a href={`/${element.id}`}>{element.id}</a></li>
2324
))}
2425
</ul>
2526
</details>
@@ -29,5 +30,6 @@ const classesByCategory = getOOPClassesByCategory();
2930

3031
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksFromList([
3132
'article:OOP_Introduction',
33+
'article:Element',
3234
])} currentId='' />
3335
</StarlightPage>

web/src/pages/Vector.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ A vector represents a <a href="https://en.wikipedia.org/wiki/Euclidean_vector" t
1717
**Tip**: if you are using vectors a lot, you can use `collectgarbage("setpause",100)` to tell Lua to garbage collect intermediary vectors frequently. Run that once per resource (or just in the resource you need it for). This has other performance implications as Lua will be stopping the world more frequently.
1818

1919
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksFromList([
20-
'article:OOP',
2120
'article:OOP_Introduction',
22-
'classes:any:Vector',
23-
'classes:any:Matrix'
21+
'elements:any:Vector',
22+
'elements:any:Matrix'
2423
])} currentId='' />
2524

2625
</StarlightPage>

0 commit comments

Comments
 (0)