Skip to content

Commit

Permalink
Add function oop syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Jan 24, 2025
1 parent 6558c50 commit 58732f9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion functions/Element/getElementHealth.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
shared: &shared
name: 'getElementHealth'
oop:
entity: player
entity: element
method: getHealth
variable: health
pair: 'setElementHealth'
Expand Down
2 changes: 1 addition & 1 deletion functions/Element/getElementPosition.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
shared: &shared
name: 'getElementPosition'
oop:
entity: player
entity: element
method: getPosition
variable: position
pair: 'setElementPosition'
Expand Down
2 changes: 1 addition & 1 deletion functions/Element/setElementHealth.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
shared: &shared
name: 'setElementHealth'
oop:
entity: player
entity: element
method: setHealth
variable: health
pair: 'getElementHealth'
Expand Down
2 changes: 1 addition & 1 deletion functions/Element/setElementPosition.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
shared: &shared
name: 'setElementPosition'
oop:
entity: player
entity: element
method: setPosition
variable: position
pair: 'getElementPosition'
Expand Down
2 changes: 1 addition & 1 deletion web/resources/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div style="color: #fff; font-size: 1em;">
Article: <strong>{{ article.title }}</strong>
<a style="margin-left: 2px;" href="https://github.com/multitheftauto/mtasa-wiki/blob/main/CONTRIBUTING.md" rel="noopener" target="_blank">
<i class="fa-solid fa-pen-to-square"></i>
<i class="fa-regular fa-pen-to-square"></i>
</a>
</div>
<div style="color: #b5b5b5; font-size: 0.8em; margin-top: 0.5em;">
Expand Down
35 changes: 30 additions & 5 deletions web/resources/function.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="function-type-title" style="color: {{type_colors[function.type_name]}};">{{ function.type_name|capitalize }} function</div>
<h1 style="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.2em;">
<span {% if function.disabled %}style="text-decoration: line-through;"{% endif %}>{{ function.name }}</span>
<a class="small-fs" href="#" onclick="copyText('{{ function.name }}', 'copy-{{ function.name }}')"><i class="fa-solid fa-copy"></i> <span id="copy-{{ function.name }}">Copy</span> </a>
<a class="small-fs" href="#" onclick="copyText('{{ function.name }}', 'copy-{{ function.name }}')"><i class="fa-regular fa-copy"></i> <span id="copy-{{ function.name }}">Copy</span> </a>
</h1>

<!-- Disabled Warning -->
Expand Down Expand Up @@ -97,7 +97,7 @@ <h3>Pair: <a href="/{{ function[type_name].pair }}">{{ function[type_name].pair
<h2 id="syntax">Syntax <a href="#syntax"><i class="fa-solid fa-link"></i></a></h2>
{% if function.syntaxes.single %}
{% set syntax = function.syntaxes.single %}
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">

<pre><code class="language-lua">{{ syntax.returns.values_type or 'void' }} {{ function.name }} ( {% for parameter in syntax.arguments.required %}{{ parameter.type }} {{ parameter.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% for parameter in syntax.arguments.optional %}{% if syntax.arguments.required %}, {% endif %}{% if loop.first %}[ {% endif %}{{ parameter.type }} {{ parameter.name }} = {{ parameter.default }}{% if loop.last %} ]{% endif %}{% endfor %} )</code></pre>

Expand Down Expand Up @@ -129,12 +129,11 @@ <h3>Returns:</h3>
{% endfor %}
</ul>

</div>
{% else %}
{% for type_name in ['server', 'client'] %}
{% set syntax = function.syntaxes[type_name] %}
{% if syntax %}
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ type_colors[type_name] }}; border-radius: 5px;">
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ type_colors[type_name] }}; border-radius: 5px;">
<h3 style="color: {{ type_colors[type_name] }};">{{ type_name|capitalize }}:</h3>

<pre><code class="language-lua">{{ syntax.returns.values_type or 'void' }} {{ function.name }} ( {% for parameter in syntax.arguments.required %}{{ parameter.type }} {{ parameter.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% for parameter in syntax.arguments.optional %}{% if syntax.arguments.required %}, {% endif %}{% if loop.first %}[ {% endif %}{{ parameter.type }} {{ parameter.name }} = {{ parameter.default }}{% if loop.last %} ]{% endif %}{% endfor %} )</code></pre>
Expand Down Expand Up @@ -166,10 +165,36 @@ <h4>Returns:</h4>
<li>{{ item.type }} {{ item.name }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endfor %}
{% endif %}
<!-- OOP Syntax -->
{% for type_name in ['shared', 'client', 'server'] %}
{% if function[type_name] %}
{% if function[type_name].oop %}
<h3>OOP syntax: <a href="/OOP_Introduction" ><i class="fa-regular fa-circle-question"></i></a></h3>
{% if function[type_name].oop.note %}
<p>{{ function[type_name].oop.note }}</p>
{% endif %}
<!-- Method or constructor -->
<ul>
{% if function[type_name].oop.constructor %}
<li><strong>Constructor:</strong> <a href="/{{ function[type_name].oop.constructor|lower }}">{{ function[type_name].oop.constructor|capitalize }}</a>(...)</li>
{% else %}
{% if function[type_name].oop.static %}
<li><strong>Method:</strong> <a href="/{{ function[type_name].oop.entity|capitalize }}">{{ function[type_name].oop.entity|capitalize }}</a>.{{ function[type_name].oop.method }}(...)</li>
{% else %}
<li><strong>Method:</strong> <a href="/{{ function[type_name].oop.entity|lower }}">{{ function[type_name].oop.entity }}</a>:{{ function[type_name].oop.method }}(...)</li>
{% endif %}
{% if function[type_name].oop.variable %}
<li><strong>Variable:</strong> <a href="/{{ function[type_name].oop.entity|lower }}">{{ function[type_name].oop.entity }}</a>.{{ function[type_name].oop.variable }}</li>
{% endif %}
{% endif %}
</ul>
{% endif %}
{% endif %}
{% endfor %}
</div>

<!-- Preview Images -->
{% for type_name in ['shared', 'client', 'server'] %}
Expand Down
2 changes: 1 addition & 1 deletion web/resources/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<!-- Custom CSS -->
<link rel="stylesheet" href="/assets/style.css?v=1.5">
<link rel="stylesheet" href="/assets/style.css?v=1.6">
</head>
<body>
<nav id="mta-global-navbar">
Expand Down

0 comments on commit 58732f9

Please sign in to comment.