docs(35) + feat(g36): «Головоломка с ящиками»
g35 docs: CodeBoth g35_main. g36 паритет: - onPlate[3] флаги, при всех true → win - BindableEvent BoxMoved(i, on) - g36_box_N: Heartbeat distance-check(3) → '[E] Двинуть ящик', E: cell++ (wrap), TweenService Position.Z=ROW[cell], 0.4с, Fire(i, newZ == 6)
This commit is contained in:
parent
92a9ef220d
commit
b0bdfb6e29
@ -3191,7 +3191,94 @@ end)`,
|
||||
},
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// ИГРЫ 36-50: явных Lua-версий пока нет.
|
||||
// ИГРА 36 — «Головоломка с ящиками»
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
'box-puzzle': (function() {
|
||||
const BOX_COUNT = 3;
|
||||
const overrides = {
|
||||
g36_main: `-- === ИГРА «ГОЛОВОЛОМКА С ЯЩИКАМИ» — главный скрипт (Lua) ===
|
||||
${SNIPPET_BROADCAST}
|
||||
|
||||
local onPlate = { false, false, false }
|
||||
local won = false
|
||||
|
||||
__rbxl_show_text("Поставь все 3 ящика на зелёные плиты!", 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
|
||||
|
||||
-- Ящики шлют BoxMoved:Fire(i, on)
|
||||
local boxEvent = getEvent("BoxMoved")
|
||||
boxEvent.Event:Connect(function(i, on)
|
||||
onPlate[i] = on
|
||||
if on then clickSound:Play() end
|
||||
if not won and onPlate[1] and onPlate[2] and onPlate[3] then
|
||||
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
|
||||
end)`,
|
||||
};
|
||||
// 3 ящика — E двигает по ряду Z=[-6,-3,0,3,6], плита на z=6
|
||||
for (let i = 1; i <= BOX_COUNT; i++) {
|
||||
overrides['g36_box_' + i] = `-- === Скрипт ящика ${i} (Lua) ===
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local part = script.Parent
|
||||
|
||||
local ROW = { -6, -3, 0, 3, 6 }
|
||||
local PLATE_Z = 6
|
||||
local cell = 1
|
||||
local hintVisible = false
|
||||
local moving = false
|
||||
|
||||
RunService.Heartbeat:Connect(function()
|
||||
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 <= 3
|
||||
if near ~= hintVisible then
|
||||
hintVisible = near
|
||||
if near then
|
||||
__rbxl_hud_set("g36_box_${i}_hint", "[E] Двинуть ящик", 50, 75, "#ffe44a", 20)
|
||||
else
|
||||
__rbxl_hud_set("g36_box_${i}_hint", nil)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
UserInputService.InputBegan:Connect(function(input, gp)
|
||||
if gp then return end
|
||||
if not hintVisible then return end
|
||||
if moving then return end
|
||||
if input.KeyCode ~= Enum.KeyCode.E then return end
|
||||
cell = cell + 1
|
||||
if cell > #ROW then cell = 1 end
|
||||
local newZ = ROW[cell]
|
||||
moving = true
|
||||
local goal = { Position = Vector3.new(part.Position.X, part.Position.Y, newZ) }
|
||||
local tween = TweenService:Create(part, TweenInfo.new(0.4), goal)
|
||||
tween:Play()
|
||||
tween.Completed:Connect(function() moving = false end)
|
||||
local ev = ReplicatedStorage:FindFirstChild("BoxMoved")
|
||||
if ev then ev:Fire(${i}, newZ == PLATE_Z) end
|
||||
end)`;
|
||||
}
|
||||
return overrides;
|
||||
})(),
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// ИГРЫ 37-50: явных Lua-версий пока нет.
|
||||
// buildGameProject в docsGamesBuilders.js использует generateFallbackLua
|
||||
// (главный скрипт → показ подсказки + слушает FinishReached →
|
||||
// победа+конфетти; скрипт на финиш-примитиве → шлёт FinishReached;
|
||||
|
||||
@ -4962,7 +4962,7 @@ game.self.onInteract(() => {
|
||||
<h3 className="lessonH">Шаг 2. Главный скрипт</h3>
|
||||
<p>Вся игра — в одном скрипте. Разберём его.</p>
|
||||
<ScriptKind kind="global" />
|
||||
<Code>{`// === ИГРА «ПРЯТКИ ОТ NPC» — главный скрипт ===
|
||||
<CodeBoth game="hide-from-npc" script="g35_main">{`// === ИГРА «ПРЯТКИ ОТ NPC» — главный скрипт ===
|
||||
|
||||
let time = 0;
|
||||
const SURVIVE = 40; // продержись 40 секунд
|
||||
@ -5001,7 +5001,7 @@ game.onTick((dt) => {
|
||||
game.scene.spawnParticles('confetti',
|
||||
{ x: p.x, y: p.y + 3, z: p.z }, { duration: 3, count: 3 });
|
||||
}
|
||||
});`}</Code>
|
||||
});`}</CodeBoth>
|
||||
<p>Разберём:</p>
|
||||
<ul>
|
||||
<li><code>game.scene.spawnNpc(...)</code> создаёт
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user