Skip to content

Commit af9f3e3

Browse files
Fix functions syntax
1 parent a0c33d9 commit af9f3e3

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

functions/Element/getElementHealth.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ shared: &shared
77
pair: 'setElementHealth'
88
description: |
99
This function returns the current health for the specified element. This can be a [[player]], [[ped]], [[vehicle]], or [[object]].
10+
parameters:
11+
- name: 'theElement'
12+
type: 'element'
13+
description: "The [[player]] or [[vehicle]] whose health you want to check."
1014
returns:
1115
description: |
1216
Returns a *float* indicating the element's health, *false* otherwise.

functions/Element/getElementPosition.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ shared: &shared
1616
- [[collision shape|Collision shapes]]
1717
- [[blip|Blips]]
1818
- [[radar area|Radar areas]]
19+
parameters:
20+
- name: 'theElement'
21+
type: 'element'
22+
description: "The element which you'd like to retrieve the location of"
1923
returns:
2024
description: |
2125
Returns three floats indicating the position of the element, x, y and z respectively.

functions/Element/setElementHealth.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ shared: &shared
1818
parameters:
1919
- name: 'theElement'
2020
type: 'element'
21-
description: 'The player, ped, vehicle or object element whose health you want to set.'
21+
description: 'The [[player]], [[ped]], [[vehicle]] or [[object]] element whose health you want to set.'
2222
- name: 'newHealth'
2323
type: 'float'
2424
description: 'A float indicating the new health to set for the element.'

functions/Element/setElementPosition.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ shared: &shared
1313
- |
1414
If you want to put a vehicle or player out of the water or simulate the position-resetting behaviour if CJ goes below the ground too far, then you need to retrieve a recommended coordinate on ground to place the element at. Take a look at this MTA forums post for steps in the right direction.
1515
https://forum.mtasa.com/topic/132891-important-helprespawn-vehicle/?do=findComment&comment=1003198
16+
parameters:
17+
- name: 'theElement'
18+
type: 'element'
19+
description: 'A valid [[element]] to be moved.'
20+
- name: 'x'
21+
type: 'float'
22+
description: 'The x coordinate of the destination.'
23+
- name: 'y'
24+
type: 'float'
25+
description: 'The y coordinate of the destination.'
26+
- name: 'y'
27+
type: 'float'
28+
description: 'The z coordinate of the destination.'
29+
- name: 'warp'
30+
type: 'bool'
31+
default: 'false'
32+
description: 'teleports players, resetting any animations they were doing. Setting this to false preserves the current animation.'
1633
returns:
1734
description: |
1835
Returns *true* if the function was successful, *false* otherwise.

schemas/function.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ $defs:
163163
description: |
164164
The default value for this parameter, if none was given in the call to the function.
165165
This property automatically implicitly marks this parameter as optional.
166-
optional:
167-
type: boolean
168-
default: false
169-
description: If set to true, this parameter will be marked as optional.
170166
171167
returns:
172168
type: object

web/resources/function.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@ <h1 style="border-bottom: 3px solid #FF7F00;">{{ function.name }}</h1>
1717
<h2>Syntax</h2>
1818
{% for type_name in ['shared', 'client', 'server'] %}
1919
{% if function[type_name] %}
20+
{% if function[type_name].returns %}
21+
{% set return_type = function[type_name].returns["values"][0].type %}
22+
{% else %}
23+
{% set return_type = 'void' %}
24+
{% endif %}
2025
{% if function[type_name].parameters %}
21-
<pre><code class="language-lua">{{ function[type_name].name }}( {% for item in function[type_name].parameters %}{{ item.type }} {{ item.name }}{% if not loop.last %}, {% endif %}{% endfor %} )</code></pre>
26+
<pre><code class="language-lua">{{ return_type }} {{ function[type_name].name }} ( {% for item in function[type_name].parameters %}{{ item.type }} {{ item.name }}{% if not loop.last %}, {% endif %}{% endfor %} )</code></pre>
2227
<ul>
2328
{% for item in function[type_name].parameters %}
2429
<li>{{ item.type }} <strong>{{ item.name }}</strong> : {{ item.description_html }}</li>
2530
{% endfor %}
2631
</ul>
32+
{% else %}
33+
<pre><code class="language-lua">{{ return_type }} {{ function[type_name].name }} ( )</code></pre>
2734
{% endif %}
2835

2936
{% endif %}
3037
{% endfor %}
3138

39+
<!-- Returns -->
3240
{% for type_name in ['shared', 'client', 'server'] %}
3341
{% if function[type_name] %}
3442
{% if function[type_name].returns %}

web/scripts/utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def to_html(markdown_text, single_paragraph=False):
2020
html = re.sub(r'<p>(.*?)</p>', r'\1', html)
2121

2222
# Custom link syntax
23-
# Replace all [[string|text]] with <a href="/string">text</a>
24-
html = re.sub(r'\[\[(.*?)\|(.*?)\]\]', r'<a href="/\1">\2</a>', html)
25-
# Replace all [[string]] with <a href="/string">string</a>
26-
html = re.sub(r'\[\[(.*?)\]\]', r'<a href="/\1">\1</a>', html)
23+
# Replace all [[string|text]] with <a href="/string_with_underscores">text</a>
24+
html = re.sub(r'\[\[(.*?)\|(.*?)\]\]', lambda m: f'<a href="/{m.group(1).replace(" ", "_")}">{m.group(2)}</a>', html)
25+
# Replace all [[string]] with <a href="/string_with_underscores">string</a>
26+
html = re.sub(r'\[\[(.*?)\]\]', lambda m: f'<a href="/{m.group(1).replace(" ", "_")}">{m.group(1)}</a>', html)
2727

2828
return html

0 commit comments

Comments
 (0)