Skip to content

Commit 1e25208

Browse files
committed
Change homepage example code and fix playground metadata
1 parent 82d2724 commit 1e25208

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/pages/index.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,29 @@ const features: Feature[] = [
4444
];
4545

4646
const exampleSource = `
47+
// Give points to all friends around the target position
4748
function onAbilityCast(caster: Unit, targetPos: Vector) {
4849
const units = findUnitsInRadius(targetPos, 500);
4950
50-
const enemies = units.filter(unit => caster.isEnemy(unit));
51+
const friends = units.filter(unit => caster.isFriend(unit));
5152
52-
for (const enemy of enemies) {
53-
enemy.kill();
53+
for (const friend of friends) {
54+
friend.givePoints(50);
5455
}
5556
5657
}
5758
`.trim();
5859

5960
const exampleOutput = `
61+
-- Give points to all friends around the target position
6062
function onAbilityCast(caster, targetPos)
6163
local units = findUnitsInRadius(targetPos, 500)
62-
local enemies = __TS__ArrayFilter(
64+
local friends = __TS__ArrayFilter(
6365
units,
64-
function(____, unit) return caster:isEnemy(unit) end
66+
function(____, unit) return caster:isFriend(unit) end
6567
)
66-
for ____, enemy in ipairs(enemies) do
67-
enemy:kill()
68+
for ____, friend in ipairs(friends) do
69+
friend:givePoints(50)
6870
end
6971
end
7072
`.trim();

src/pages/play/code.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ type Vector = [number, number, number];
55
66
declare function findUnitsInRadius(this: void, center: Vector, radius: number): Unit[];
77
declare interface Unit {
8-
isEnemy(other: Unit): boolean;
9-
kill(): void;
8+
isFriend(other: Unit): boolean;
9+
givePoints(pointsAmount: number): void;
1010
}
1111
1212
1313
// Use declared API in code
1414
function onAbilityCast(this: void, caster: Unit, targetLocation: Vector) {
1515
const units = findUnitsInRadius(targetLocation, 500);
16-
const enemies = units.filter(unit => caster.isEnemy(unit));
16+
const friends = units.filter(unit => caster.isFriend(unit));
1717
18-
for (const enemy of enemies) {
19-
enemy.kill();
18+
for (const friend of friends) {
19+
friend.givePoints(50);
2020
}
2121
}
2222
`;

src/pages/play/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import Layout from "@theme/Layout";
22
import React from "react";
3+
import Head from "@docusaurus/Head";
34

45
const Playground = React.lazy(() => import("./Playground"));
56
export default function Play() {
67
const isSSR = typeof window === "undefined";
78
return (
89
<Layout>
10+
<Head>
11+
<title>Playground | TypeScriptToLua</title>
12+
<meta name="description" content="Try and share TypeScriptToLua in the online editor."></meta>
13+
</Head>
914
{!isSSR && (
1015
<React.Suspense fallback={<div />}>
1116
<Playground />

0 commit comments

Comments
 (0)