Skip to content

Commit 5ced68d

Browse files
committed
2 parents f1a0017 + f9b77c8 commit 5ced68d

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

functions/Vehicle/createVehicle.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,12 @@ shared: &shared
7272
server:
7373
<<: *shared
7474

75+
examples:
76+
- path: 'examples/createVehicle-oop-1.lua'
77+
description: |
78+
Creates a vehicle using the OOP syntax. This example creates a vehicle at the specified position and with the specified rotation.
79+
oop: true
80+
title: 'Create Vehicle using Constructor Class'
81+
7582
client:
7683
<<: *shared
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function makeVehicle(model, x, y, z, rx, ry, rz)
2+
assert(type(model)=="number", "Model must be a number")
3+
assert(type(x)=="number", "X coordinate must be a number")
4+
assert(type(y)=="number", "Y coordinate must be a number")
5+
assert(type(z)=="number", "Z coordinate must be a number")
6+
if not rx then rx = 0 end
7+
if not ry then ry = 0 end
8+
if not rz then rz = 0 end
9+
assert(type(rx)=="number", "Rotation X must be a number")
10+
assert(type(ry)=="number", "Rotation Y must be a number")
11+
assert(type(rz)=="number", "Rotation Z must be a number")
12+
return Vehicle(model, x, y, z, rx, ry, rz)
13+
end

schemas/common-defs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ $defs:
118118
type: boolean
119119
default: false
120120
description: If set to true, this example will be appended to the previous example.
121+
oop:
122+
type: boolean
123+
default: false
124+
description: If set to true, this example will be marked as an OOP example.
121125
title:
122126
type: string
123127
description: Optional title displayed in the frame around the example.

web/src/components/CodeExamplesSection.astro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface CodeExample {
88
luaCode: string;
99
side: string;
1010
title?: string;
11+
oop?: boolean;
1112
}
1213
1314
export interface Props {
@@ -56,6 +57,11 @@ if (codeExamples.length === 0 && !examplesRequired) {
5657
>
5758
<div class={`tab-header side-${example.side} active`}>
5859
<strong>{example.side}</strong> {example.title && ` - ${example.title}`}
60+
{example.oop && (
61+
<div class="oop-indicator">
62+
<a href="/OOP_Introduction">OOP</a> Required
63+
</div>
64+
)}
5965
</div>
6066
<div class="tab-body">
6167
{example.description && <EnhancedMarkdown content={example.description} />}
@@ -70,6 +76,15 @@ if (codeExamples.length === 0 && !examplesRequired) {
7076
</div>
7177

7278
<style>
79+
.oop-indicator {
80+
display: inline-block;
81+
padding: 0.2rem 0.5rem;
82+
background-color: var(--sl-color-accent-low);
83+
border-radius: 0.5rem;
84+
font-size: 0.8rem;
85+
margin-left: 0.2rem;
86+
}
87+
7388
.tab-buttons {
7489
display: flex;
7590
gap: 1rem;

0 commit comments

Comments
 (0)