Skip to content

Commit a1a1d1d

Browse files
Add info pages for the basic types
1 parent 13a8c3e commit a1a1d1d

11 files changed

+104
-0
lines changed

types/bool.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# No information - redirects to boolean

types/boolean.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
description: |
2+
A *boolean* or *bool* is a datatype whose value can be either *true* or *false*. These are often returned by functions to indicate whether the operation was successful or not.
3+
4+
Using the Lua functions `tostring()` and `type()` can help you to find out what datatype something is:
5+
6+
```lua
7+
local theReturn = isPedDead(getRandomPlayer())
8+
outputChatBox("The return was: "..tostring(theReturn)) -- Will say: "true" or "false"
9+
outputChatBox("The datatype of this return was: "..type(theReturn)) -- Will say "boolean"
10+
```
11+
12+
Reversing booleans:
13+
14+
```lua
15+
bool = true
16+
-- if you want to reverse it you can either do
17+
bool = false
18+
-- or
19+
bool = not bool
20+
```

types/element.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# No information - redirects to Element

types/float.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
description: |
2+
Float is an abbreviation of 'Floating Point Number'. A floating point number is one with a decimal point, i.e. it can contain values such as 5.5 or 3.142.
3+
4+
An [int](/int) on the other hand can only hold whole numbers.

types/int.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description: |
2+
An **int**eger is any whole number (i.e. without a decimal point). It can be positive, zero, or negative.
3+
4+
A number with a decimal point and following numbers is referred to as a [float](/float) number.
5+
6+
Lua allows you to use these interchangeably and will convert between the two as needed.

types/number.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
description: |
2+
A [**number**](https://www.lua.org/pil/2.3.html) is a numeric value that can be either an integer or a floating point number. It is a fundamental data type in Lua and is used to represent quantities, measurements, and other numerical values.

types/string.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
description: |
2+
A string is a sequence of characters, for example "Hello, World!" is a string.
3+
Here is a list of every default string manipulation function present in Lua.
4+
5+
* [string.byte](http://www.lua.org/manual/5.1/manual.html#pdf-string.byte)
6+
* [string.char](http://www.lua.org/manual/5.1/manual.html#pdf-string.char)
7+
* [string.dump](http://www.lua.org/manual/5.1/manual.html#pdf-string.dump)
8+
* [string.find](http://www.lua.org/manual/5.1/manual.html#pdf-string.find)
9+
* [string.format](http://www.lua.org/manual/5.1/manual.html#pdf-string.format)
10+
* [string.gmatch](http://www.lua.org/manual/5.1/manual.html#pdf-string.gmatch)
11+
* [string.gsub](http://www.lua.org/manual/5.1/manual.html#pdf-string.gsub)
12+
* [string.len](http://www.lua.org/manual/5.1/manual.html#pdf-string.len)
13+
* [string.lower](http://www.lua.org/manual/5.1/manual.html#pdf-string.lower)
14+
* [string.match](http://www.lua.org/manual/5.1/manual.html#pdf-string.match)
15+
* [string.rep](http://www.lua.org/manual/5.1/manual.html#pdf-string.rep)
16+
* [string.reverse](http://www.lua.org/manual/5.1/manual.html#pdf-string.reverse)
17+
* [string.sub](http://www.lua.org/manual/5.1/manual.html#pdf-string.sub)
18+
* [string.upper](http://www.lua.org/manual/5.1/manual.html#pdf-string.upper)

types/table.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
description: |
2+
A table is an array-like data storage type. They are mostly used for bigger data storage.
3+
Tables can be indexed not only with numbers but also with other data types, for example with strings and MTA [[elements]].
4+
5+
Here is a list of every default table manipulation function present in Lua.
6+
7+
* [table.concat](http://www.lua.org/manual/5.1/manual.html#pdf-table.concat)
8+
* [table.insert](http://www.lua.org/manual/5.1/manual.html#pdf-table.insert)
9+
* [table.maxn](http://www.lua.org/manual/5.1/manual.html#pdf-table.maxn)
10+
* [table.remove](http://www.lua.org/manual/5.1/manual.html#pdf-table.remove)
11+
* [table.sort](http://www.lua.org/manual/5.1/manual.html#pdf-table.sort)
12+
* [unpack](http://www.lua.org/manual/5.1/manual.html#pdf-unpack)
13+
14+
[Tables at lua.org](http://www.lua.org/pil/2.5.html)

web/public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/wiki/* /:splat
33
/Main_Page /
44

5+
/bool /boolean
56
/element /Element
67
/MTA_Classes /Element
78
/Element/:elementname /:elementname

web/src/content.config.ts

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

web/src/pages/[theType].astro

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3+
import { getCollection } from 'astro:content';
4+
import { marked } from 'marked';
5+
6+
export async function getStaticPaths() {
7+
const theTypes = await getCollection('types');
8+
// Remove types that don't have description
9+
const filteredTypes = theTypes.filter(theType => theType.data && theType.data.description && theType.data.description.trim() !== '');
10+
return filteredTypes.map(theType => ({
11+
params: { theType: theType.id },
12+
props: { theType },
13+
}));
14+
}
15+
16+
const { theType } = Astro.props;
17+
---
18+
19+
<StarlightPage frontmatter={{
20+
template: 'doc',
21+
title: theType.id,
22+
tableOfContents: false,
23+
}}>
24+
25+
<Fragment set:html={marked(theType.data.description)} />
26+
27+
</StarlightPage>

0 commit comments

Comments
 (0)