docs(38) + feat(g39): «Башня — стройка»

g38 docs: CodeBoth main+tile_1.

g39 паритет:
- STEPS=8, placed counter
- BindableEvent BlockPlaced(n)
- 8 g39_spot_N: Heartbeat distance(4) → '[E] Поставить блок'
  E → CanCollide=true, Transparency=0, Color коричневый,
  BlockPlaced:Fire(n)
- Главный: n=placed+1? placed++; иначе 'Сначала поставь ниже!'
- 8 → 'Победа!' + confetti
This commit is contained in:
min 2026-06-09 22:41:55 +03:00
parent 0fcc5b85d0
commit b42685521c
2 changed files with 94 additions and 5 deletions

View File

@ -3511,7 +3511,96 @@ end)`;
})(),
// ═══════════════════════════════════════════════════════════════
// ИГРЫ 39-50: явных Lua-версий пока нет.
// ИГРА 39 — «Башня — стройка»
// ═══════════════════════════════════════════════════════════════
'tower-build': (function() {
const STEPS = 8;
const overrides = {
g39_main: `-- === ИГРА «БАШНЯ — СТРОЙКА» — главный скрипт (Lua) ===
${SNIPPET_BROADCAST}
local STEPS = ${STEPS}
local placed = 0
__rbxl_score_set(0)
__rbxl_show_text("Подходи к местам и ставь блоки (E) снизу вверх", 4)
local clickSound = Instance.new("Sound", workspace)
clickSound.SoundId = "click"; clickSound.Volume = 0.6
local winSound = Instance.new("Sound", workspace)
winSound.SoundId = "win"; winSound.Volume = 1
-- Места шлют BlockPlaced:Fire(n)
local ev = getEvent("BlockPlaced")
ev.Event:Connect(function(n)
if n ~= placed + 1 then
__rbxl_show_text("Сначала поставь блок ниже!", 1.5)
return
end
placed = placed + 1
__rbxl_score_set(placed)
clickSound:Play()
if placed >= STEPS then
__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)
else
__rbxl_show_text("Блок " .. placed .. " из " .. STEPS, 1.5)
end
end)`,
};
// 8 мест-призраков — E делает блок «реальным»
for (let i = 1; i <= STEPS; i++) {
overrides['g39_spot_' + i] = `-- === Скрипт места под блок ${i} (Lua) ===
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local part = script.Parent
local built = false
local hintVisible = false
RunService.Heartbeat:Connect(function()
if built then return end
local px = __rbxl_player_x()
local pz = __rbxl_player_z()
local dx = part.Position.X - px
local dz = part.Position.Z - pz
local dist = math.sqrt(dx*dx + dz*dz)
local near = dist <= 4
if near ~= hintVisible then
hintVisible = near
if near then
__rbxl_hud_set("g39_spot_${i}_hint", "[E] Поставить блок", 50, 75, "#ffe44a", 20)
else
__rbxl_hud_set("g39_spot_${i}_hint", nil)
end
end
end)
UserInputService.InputBegan:Connect(function(input, gp)
if gp then return end
if not hintVisible then return end
if built then return end
if input.KeyCode ~= Enum.KeyCode.E then return end
built = true
-- Делаем блок «реальным»: твёрдым, непрозрачным, коричневым
part.CanCollide = true
part.Transparency = 0
part.Color = Color3.fromRGB(181, 101, 29)
__rbxl_hud_set("g39_spot_${i}_hint", nil)
local ev = ReplicatedStorage:FindFirstChild("BlockPlaced")
if ev then ev:Fire(${i}) end
end)`;
}
return overrides;
})(),
// ═══════════════════════════════════════════════════════════════
// ИГРЫ 40-50: явных Lua-версий пока нет.
// buildGameProject в docsGamesBuilders.js использует generateFallbackLua
// (главный скрипт → показ подсказки + слушает FinishReached →
// победа+конфетти; скрипт на финиш-примитиве → шлёт FinishReached;

View File

@ -5394,7 +5394,7 @@ game.self.onTouch(() => {
верно ли игрок повторяет.
</p>
<ScriptKind kind="global" />
<Code>{`// === ИГРА «МУЗЫКАЛЬНАЯ ИГРА» — главный скрипт ===
<CodeBoth game="music-game" script="g38_main">{`// === ИГРА «МУЗЫКАЛЬНАЯ ИГРА» — главный скрипт ===
const SOUNDS = ['coin', 'jump', 'click', 'hit']; // плитки 1..4
// загаданная последовательность из 5 нот
@ -5440,7 +5440,7 @@ game.onMessage('press', (d) => {
game.ui.showText('Ошибка! Слушай и пробуй снова.', 2);
game.sound.play('lose');
}
});`}</Code>
});`}</CodeBoth>
<p>Разберём:</p>
<ul>
<li><code>SEQ = [1, 3, 2, 4, 1]</code> загаданная мелодия:
@ -5463,13 +5463,13 @@ game.onMessage('press', (d) => {
для остальных поменяй звук и число в <code>press</code>.
</p>
<ScriptKind kind="object" on="каждую ноту-плитку" />
<Code>{`// === Скрипт ноты-плитки 1 ===
<CodeBoth game="music-game" script="g38_tile_1">{`// === Скрипт ноты-плитки 1 ===
game.self.onInteract(() => {
game.sound.play('coin');
game.scene.spawnParticles('sparks', game.self.position,
{ duration: 0.4, color: '#e23b3b' });
game.broadcast('press', { n: 1 });
}, { text: 'Сыграть ноту', distance: 3 });`}</Code>
}, { text: 'Сыграть ноту', distance: 3 });`}</CodeBoth>
<p>
При нажатии <kbd className="kbd">E</kbd> плитка играет
свой звук, вспыхивает искрами и шлёт