feat(g23): полный паритет «Переключатели»
JS:
- showText 'Дёрни рычаги в нужном порядке (E)'
- onMessage 'lever' с {num} → click sound + pressed.push + проверка
совпадения с ORDER=[2,3,1]. Ошибка → reset + 'Неверно!' + lose
Полная последовательность → 'Верно! Дверь открыта' + win + tween двери
- onMessage 'win' → 'Победа!' + win + confetti
- лычаги: onInteract E (distance=3) → broadcast 'lever' {num}
- финиш: onTouch → broadcast 'win'
Lua (паритет):
- __rbxl_show_text + Sounds
- BindableEvents LeverPulled (с num аргументом) + WinReached
- g23_main: проверка порядка + tween двери (Position.Y+6) + CanCollide=false
- 3 g23_lever_N: Heartbeat distance-check (3), __rbxl_hud_set
'[E] Дёрнуть рычаг N' в нижней части экрана.
UserInputService.InputBegan E → LeverPulled:Fire(n)
- g23_finish: Touched → WinReached:Fire (fired-флаг)
This commit is contained in:
parent
791cf2cde5
commit
eb04da6348
@ -1963,22 +1963,117 @@ end)`,
|
|||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
// ИГРА 23 — «3 переключателя»
|
// ИГРА 23 — «3 переключателя»
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
'switches': {
|
'switches': (function() {
|
||||||
g23_main: `-- === ИГРА «3 ПЕРЕКЛЮЧАТЕЛЯ» (Lua) ===
|
const overrides = {
|
||||||
|
g23_main: `-- === ИГРА «ПЕРЕКЛЮЧАТЕЛИ» — главный скрипт (Lua) ===
|
||||||
${SNIPPET_BROADCAST}
|
${SNIPPET_BROADCAST}
|
||||||
|
|
||||||
local activated = {false, false, false}
|
local TweenService = game:GetService("TweenService")
|
||||||
print("Активируй все 3 переключателя!")
|
local ORDER = { 2, 3, 1 } -- правильный порядок рычагов
|
||||||
|
local pressed = {}
|
||||||
|
local opened = false
|
||||||
|
local won = false
|
||||||
|
|
||||||
local ev = getEvent("SwitchToggled")
|
__rbxl_show_text("Дёрни рычаги в нужном порядке (E)", 4)
|
||||||
ev.Event:Connect(function(idx)
|
|
||||||
activated[idx] = true
|
local clickSound = Instance.new("Sound", workspace)
|
||||||
print("Переключатель " .. idx .. " активирован")
|
clickSound.SoundId = "click"; clickSound.Volume = 0.7
|
||||||
if activated[1] and activated[2] and activated[3] then
|
local loseSound = Instance.new("Sound", workspace)
|
||||||
print("ПОБЕДА! Все 3 активированы!")
|
loseSound.SoundId = "lose"; loseSound.Volume = 0.7
|
||||||
|
local winSound = Instance.new("Sound", workspace)
|
||||||
|
winSound.SoundId = "win"; winSound.Volume = 1
|
||||||
|
|
||||||
|
-- Рычаги шлют ev:Fire(num) с номером
|
||||||
|
local leverEvent = getEvent("LeverPulled")
|
||||||
|
leverEvent.Event:Connect(function(num)
|
||||||
|
if opened then return end
|
||||||
|
clickSound:Play()
|
||||||
|
table.insert(pressed, num)
|
||||||
|
local i = #pressed
|
||||||
|
if pressed[i] ~= ORDER[i] then
|
||||||
|
pressed = {}
|
||||||
|
__rbxl_show_text("Неверно! Рычаги сброшены.", 1.5)
|
||||||
|
loseSound:Play()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
if #pressed == #ORDER then
|
||||||
|
opened = true
|
||||||
|
__rbxl_show_text("Верно! Дверь открыта.", 3)
|
||||||
|
winSound:Play()
|
||||||
|
local door = workspace:FindFirstChild("Дверь")
|
||||||
|
if door then
|
||||||
|
local dp = door.Position
|
||||||
|
local goal = { Position = Vector3.new(dp.X, dp.Y + 6, dp.Z) }
|
||||||
|
TweenService:Create(door, TweenInfo.new(1.2), goal):Play()
|
||||||
|
door.CanCollide = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
__rbxl_show_text("Так держать!", 1)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Финиш
|
||||||
|
local winEvent = getEvent("WinReached")
|
||||||
|
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)`,
|
end)`,
|
||||||
},
|
g23_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("WinReached")
|
||||||
|
if ev then ev:Fire() end
|
||||||
|
end)`,
|
||||||
|
};
|
||||||
|
// 3 рычага — каждый ждёт E когда игрок рядом, шлёт свой номер
|
||||||
|
for (let n = 1; n <= 3; n++) {
|
||||||
|
overrides['g23_lever_' + n] = `-- === Скрипт рычага ${n} (Lua) ===
|
||||||
|
local UserInputService = game:GetService("UserInputService")
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
|
local part = script.Parent
|
||||||
|
local hintVisible = 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("g23_lever_${n}_hint", "[E] Дёрнуть рычаг ${n}", 50, 75, "#ffe44a", 20)
|
||||||
|
else
|
||||||
|
__rbxl_hud_set("g23_lever_${n}_hint", nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
UserInputService.InputBegan:Connect(function(input, gp)
|
||||||
|
if gp then return end
|
||||||
|
if not hintVisible then return end
|
||||||
|
if input.KeyCode ~= Enum.KeyCode.E then return end
|
||||||
|
local ev = ReplicatedStorage:FindFirstChild("LeverPulled")
|
||||||
|
if ev then ev:Fire(${n}) end
|
||||||
|
end)`;
|
||||||
|
}
|
||||||
|
return overrides;
|
||||||
|
})(),
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
// ИГРА 24 — «Падающий мост»
|
// ИГРА 24 — «Падающий мост»
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user