From f0025f0dadae8e3532982564442bd3e59cd6abcc Mon Sep 17 00:00:00 2001
From: min
Date: Tue, 9 Jun 2026 22:32:55 +0300
Subject: [PATCH] =?UTF-8?q?docs(36)=20+=20feat(g37):=20=C2=AB=D0=9F=D0=BE?=
=?UTF-8?q?=D0=BB=D0=BE=D1=81=D0=B0=20=D0=BF=D1=80=D0=B5=D0=BF=D1=8F=D1=82?=
=?UTF-8?q?=D1=81=D1=82=D0=B2=D0=B8=D0=B9=C2=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
g36 docs: CodeBoth main+box_1.
g37 паритет:
- task.delay 0.2 ДвижПлатформа yoyo loop (x: -0.5 ↔ 3, 2с)
- Heartbeat: py<-3 → LoadCharacter + lose
- BindableEvents CheckpointReached/FinishReached
- 6 g37_spike_N: Touched → damage(25) + hit sound (i-frames 0.5с)
- g37_cp: Touched → CheckpointReached:Fire → setSpawn(-0.5,1,24)
- g37_finish: Touched → FinishReached:Fire → win + confetti
Shim: __rbxl_set_spawn(x,y,z).
---
src/community/docsGamesBuildersLua.js | 126 +++++++++++++++++++++++++-
src/community/docsLessons.jsx | 8 +-
src/editor/engine/lua/RobloxShim.js | 4 +
3 files changed, 133 insertions(+), 5 deletions(-)
diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js
index 3248cec..2fcc493 100644
--- a/src/community/docsGamesBuildersLua.js
+++ b/src/community/docsGamesBuildersLua.js
@@ -3278,7 +3278,131 @@ end)`;
})(),
// ═══════════════════════════════════════════════════════════════
- // ИГРЫ 37-50: явных Lua-версий пока нет.
+ // ИГРА 37 — «Полоса препятствий»
+ // ═══════════════════════════════════════════════════════════════
+ 'obstacle-course': (function() {
+ const SPIKE_IDS = [1, 2, 3, 4, 5, 6]; // id 1-6 — шипы
+ const overrides = {
+ g37_main: `-- === ИГРА «ПОЛОСА ПРЕПЯТСТВИЙ» — главный скрипт (Lua) ===
+${SNIPPET_BROADCAST}
+
+local TweenService = game:GetService("TweenService")
+local Players = game:GetService("Players")
+local RunService = game:GetService("RunService")
+local player = Players.LocalPlayer
+local won = false
+
+__rbxl_show_text("Пройди полосу: шипы, ямы, платформа!", 4)
+
+local loseSound = Instance.new("Sound", workspace)
+loseSound.SoundId = "lose"; loseSound.Volume = 0.7
+local pickupSound = Instance.new("Sound", workspace)
+pickupSound.SoundId = "pickup"; pickupSound.Volume = 0.7
+local winSound = Instance.new("Sound", workspace)
+winSound.SoundId = "win"; winSound.Volume = 1
+
+-- Движущаяся платформа: tween yoyo x: -0.5 ↔ 3, 2с
+task.delay(0.2, function()
+ local mover = workspace:FindFirstChild("ДвижПлатформа")
+ if mover then
+ local mp = mover.Position
+ local startX = mp.X
+ local function loopMove()
+ local g1 = { Position = Vector3.new(3, mp.Y, mp.Z) }
+ local t1 = TweenService:Create(mover, TweenInfo.new(2), g1)
+ t1:Play()
+ t1.Completed:Connect(function()
+ local g2 = { Position = Vector3.new(startX, mp.Y, mp.Z) }
+ local t2 = TweenService:Create(mover, TweenInfo.new(2), g2)
+ t2:Play()
+ t2.Completed:Connect(loopMove)
+ end)
+ end
+ loopMove()
+ end
+end)
+
+-- Респаун при падении
+RunService.Heartbeat:Connect(function()
+ if won then return end
+ local py = __rbxl_player_y()
+ if py < -3 then
+ player:LoadCharacter()
+ loseSound:Play()
+ end
+end)
+
+-- Чекпоинт — обновляем точку возрождения
+local cpEvent = getEvent("CheckpointReached")
+cpEvent.Event:Connect(function()
+ __rbxl_set_spawn(-0.5, 1, 24)
+ __rbxl_show_text("Чекпоинт сохранён!", 2)
+ pickupSound:Play()
+end)
+
+-- Финиш
+local winEvent = getEvent("FinishReached")
+winEvent.Event:Connect(function()
+ if won then return end
+ won = true
+ __rbxl_show_text("Победа! Полоса пройдена!", 5)
+ winSound:Play()
+ local px = __rbxl_player_x()
+ local py = __rbxl_player_y()
+ local pz = __rbxl_player_z()
+ __rbxl_spawn_particles("confetti", px, py + 3, pz, 3, 3)
+end)`,
+ g37_cp: `-- === Скрипт чекпоинта (Lua) ===
+local ReplicatedStorage = game:GetService("ReplicatedStorage")
+local part = script.Parent
+local fired = false
+
+part.Touched:Connect(function(hit)
+ if fired then return end
+ local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
+ if not h then return end
+ fired = true
+ local ev = ReplicatedStorage:FindFirstChild("CheckpointReached")
+ if ev then ev:Fire() end
+end)`,
+ g37_finish: `-- === Скрипт финиш-зоны (Lua) ===
+local ReplicatedStorage = game:GetService("ReplicatedStorage")
+local part = script.Parent
+local fired = false
+
+part.Touched:Connect(function(hit)
+ if fired then return end
+ local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
+ if not h then return end
+ fired = true
+ local ev = ReplicatedStorage:FindFirstChild("FinishReached")
+ if ev then ev:Fire() end
+end)`,
+ };
+ // Шипы — Touched → damage 25 + hit
+ const spikeScript = `-- === Скрипт шипа (Lua) ===
+local part = script.Parent
+local lastHit = 0
+local hitSound = Instance.new("Sound", part)
+hitSound.SoundId = "hit"; hitSound.Volume = 0.6
+
+part.Touched:Connect(function(hit)
+ local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
+ if not h then return end
+ local now = tick()
+ if now - lastHit < 0.5 then return end -- i-frames
+ lastHit = now
+ __rbxl_damage_player(25)
+ hitSound:Play()
+end)`;
+ for (const sid of SPIKE_IDS) {
+ overrides['g37_spike_' + sid] = spikeScript;
+ }
+ return overrides;
+ })(),
+
+ // ═══════════════════════════════════════════════════════════════
+ // ИГРЫ 38-50: явных Lua-версий пока нет.
// buildGameProject в docsGamesBuilders.js использует generateFallbackLua
// (главный скрипт → показ подсказки + слушает FinishReached →
// победа+конфетти; скрипт на финиш-примитиве → шлёт FinishReached;
diff --git a/src/community/docsLessons.jsx b/src/community/docsLessons.jsx
index 8bef888..e383220 100644
--- a/src/community/docsLessons.jsx
+++ b/src/community/docsLessons.jsx
@@ -5095,7 +5095,7 @@ game.onTick((dt) => {
момент победы.
- {`// === ИГРА «ГОЛОВОЛОМКА С ЯЩИКАМИ» — главный скрипт ===
+ {`// === ИГРА «ГОЛОВОЛОМКА С ЯЩИКАМИ» — главный скрипт ===
// для каждого ящика — на какой плите он сейчас (true/false)
const onPlate = [false, false, false];
@@ -5119,7 +5119,7 @@ game.onMessage('box', (d) => {
game.scene.spawnParticles('confetti',
{ x: p.x, y: p.y + 3, z: p.z }, { duration: 3, count: 3 });
}
-});`}
+});`}
Разберём:
onPlate — массив из трёх «галочек»: стоит
@@ -5138,7 +5138,7 @@ game.onMessage('box', (d) => {
поменяй число i в сообщении на 1 и 2).
- {`// === Скрипт ящика 1 ===
+ {`// === Скрипт ящика 1 ===
// ряд позиций по Z, по которым прыгает ящик
const ROW = [-6, -3, 0, 3, 6];
@@ -5152,7 +5152,7 @@ game.self.onInteract(() => {
game.tween(game.self.ref, { z: z }, { duration: 0.4, easing: 'ease' });
// сообщаем главному скрипту — стоит ли ящик на плите
game.broadcast('box', { i: 0, on: z === PLATE_Z });
-}, { text: 'Двинуть ящик', distance: 3 });`}
+}, { text: 'Двинуть ящик', distance: 3 });`}
Что происходит:
ROW — пять клеток ряда (значения Z);
diff --git a/src/editor/engine/lua/RobloxShim.js b/src/editor/engine/lua/RobloxShim.js
index 3e11c13..8fa13a5 100644
--- a/src/editor/engine/lua/RobloxShim.js
+++ b/src/editor/engine/lua/RobloxShim.js
@@ -1996,6 +1996,10 @@ export function registerRobloxShim(lua, opts) {
global.set('__rbxl_set_double_jump', (enabled) => {
send('player.setDoubleJump', { enabled: !!enabled });
});
+ // Точка возрождения — паритет с JS game.player.setSpawn({x,y,z}).
+ global.set('__rbxl_set_spawn', (x, y, z) => {
+ send('player.setSpawn', { x: +x || 0, y: +y || 1, z: +z || 0 });
+ });
// Камера-облёт — паритет с JS game.camera.cutscene(points, opts).
// pointsFlat/lookAtFlat: x1,y1,z1,x2,y2,z2,... — потому что массив
// объектов в wasmoon через C-boundary неудобен.