Skip to content

Commit

Permalink
Fix functions syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Jan 22, 2025
1 parent a0c33d9 commit af9f3e3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 10 deletions.
4 changes: 4 additions & 0 deletions functions/Element/getElementHealth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ shared: &shared
pair: 'setElementHealth'
description: |
This function returns the current health for the specified element. This can be a [[player]], [[ped]], [[vehicle]], or [[object]].
parameters:
- name: 'theElement'
type: 'element'
description: "The [[player]] or [[vehicle]] whose health you want to check."
returns:
description: |
Returns a *float* indicating the element's health, *false* otherwise.
Expand Down
4 changes: 4 additions & 0 deletions functions/Element/getElementPosition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ shared: &shared
- [[collision shape|Collision shapes]]
- [[blip|Blips]]
- [[radar area|Radar areas]]
parameters:
- name: 'theElement'
type: 'element'
description: "The element which you'd like to retrieve the location of"
returns:
description: |
Returns three floats indicating the position of the element, x, y and z respectively.
Expand Down
2 changes: 1 addition & 1 deletion functions/Element/setElementHealth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ shared: &shared
parameters:
- name: 'theElement'
type: 'element'
description: 'The player, ped, vehicle or object element whose health you want to set.'
description: 'The [[player]], [[ped]], [[vehicle]] or [[object]] element whose health you want to set.'
- name: 'newHealth'
type: 'float'
description: 'A float indicating the new health to set for the element.'
Expand Down
17 changes: 17 additions & 0 deletions functions/Element/setElementPosition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ shared: &shared
- |
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.
https://forum.mtasa.com/topic/132891-important-helprespawn-vehicle/?do=findComment&comment=1003198
parameters:
- name: 'theElement'
type: 'element'
description: 'A valid [[element]] to be moved.'
- name: 'x'
type: 'float'
description: 'The x coordinate of the destination.'
- name: 'y'
type: 'float'
description: 'The y coordinate of the destination.'
- name: 'y'
type: 'float'
description: 'The z coordinate of the destination.'
- name: 'warp'
type: 'bool'
default: 'false'
description: 'teleports players, resetting any animations they were doing. Setting this to false preserves the current animation.'
returns:
description: |
Returns *true* if the function was successful, *false* otherwise.
Expand Down
4 changes: 0 additions & 4 deletions schemas/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ $defs:
description: |
The default value for this parameter, if none was given in the call to the function.
This property automatically implicitly marks this parameter as optional.
optional:
type: boolean
default: false
description: If set to true, this parameter will be marked as optional.
returns:
type: object
Expand Down
10 changes: 9 additions & 1 deletion web/resources/function.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ <h1 style="border-bottom: 3px solid #FF7F00;">{{ function.name }}</h1>
<h2>Syntax</h2>
{% for type_name in ['shared', 'client', 'server'] %}
{% if function[type_name] %}
{% if function[type_name].returns %}
{% set return_type = function[type_name].returns["values"][0].type %}
{% else %}
{% set return_type = 'void' %}
{% endif %}
{% if function[type_name].parameters %}
<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>
<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>
<ul>
{% for item in function[type_name].parameters %}
<li>{{ item.type }} <strong>{{ item.name }}</strong> : {{ item.description_html }}</li>
{% endfor %}
</ul>
{% else %}
<pre><code class="language-lua">{{ return_type }} {{ function[type_name].name }} ( )</code></pre>
{% endif %}

{% endif %}
{% endfor %}

<!-- Returns -->
{% for type_name in ['shared', 'client', 'server'] %}
{% if function[type_name] %}
{% if function[type_name].returns %}
Expand Down
8 changes: 4 additions & 4 deletions web/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def to_html(markdown_text, single_paragraph=False):
html = re.sub(r'<p>(.*?)</p>', r'\1', html)

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

return html

0 comments on commit af9f3e3

Please sign in to comment.