feat(lua-games): полный паритет для игры 12 «Дверь по коду»
JS:
- CODE=[3,1,4,2], showText 'Нажми кнопки в правильном порядке (E)'
- onMessage 'press' с {num} → click sound, push в entered, проверка
совпадения с CODE, ошибка → сброс + 'Неверно!' + lose sound
весь код → 'Код верный! Дверь открывается' + win sound + tween двери
- onMessage 'win' → 'Победа!' + win + confetti
- кнопка: onInteract (E, distance=3) → broadcast 'press' {num}
- финиш: onTouch → broadcast 'win'
Lua (паритет):
- __rbxl_show_text всех подсказок + Sound 'click'/'lose'/'win'
- BindableEvent ButtonPress (с num аргументом) + WinReached
- g12_main: tween двери (Position.Y+=6) + CanCollide=false
- 4 g12_btn_N: BillboardGui '[E] Нажать N' видим в радиусе 3
UserInputService.InputBegan E → ev:Fire(num)
Hint видимость через Heartbeat + __rbxl_player_x/z
- g12_finish: Touched → ev:Fire WinReached
- При win — confetti
This commit is contained in:
parent
b2f6b084df
commit
89baf23877
@ -917,31 +917,127 @@ end)`;
|
|||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
// ИГРА 12 — «Кодовая дверь»
|
// ИГРА 12 — «Кодовая дверь»
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
'code-door': {
|
'code-door': (function() {
|
||||||
g12_main: `-- === ИГРА «КОДОВАЯ ДВЕРЬ» — главный скрипт (Lua) ===
|
const overrides = {
|
||||||
|
g12_main: `-- === ИГРА «ДВЕРЬ ПО КОДУ» — главный скрипт (Lua) ===
|
||||||
${SNIPPET_BROADCAST}
|
${SNIPPET_BROADCAST}
|
||||||
|
|
||||||
local correctCode = "1234"
|
local TweenService = game:GetService("TweenService")
|
||||||
local currentInput = ""
|
local CODE = { 3, 1, 4, 2 }
|
||||||
|
local entered = {}
|
||||||
|
local opened = false
|
||||||
|
local won = false
|
||||||
|
|
||||||
print("Введи код 1234 (касайся кнопок по порядку)")
|
__rbxl_show_text("Нажми кнопки в правильном порядке (E)", 4)
|
||||||
|
|
||||||
local ev = getEvent("CodeButton")
|
local clickSound = Instance.new("Sound", workspace)
|
||||||
ev.Event:Connect(function(digit)
|
clickSound.SoundId = "click"; clickSound.Volume = 0.7
|
||||||
currentInput = currentInput .. tostring(digit)
|
local loseSound = Instance.new("Sound", workspace)
|
||||||
print("Ввод: " .. currentInput)
|
loseSound.SoundId = "lose"; loseSound.Volume = 0.8
|
||||||
if #currentInput == 4 then
|
local winSound = Instance.new("Sound", workspace)
|
||||||
if currentInput == correctCode then
|
winSound.SoundId = "win"; winSound.Volume = 1
|
||||||
print("Верно! Дверь открывается")
|
|
||||||
local doorEv = getEvent("DoorOpen")
|
local pressEvent = getEvent("ButtonPress")
|
||||||
doorEv:Fire()
|
pressEvent.Event:Connect(function(num)
|
||||||
else
|
if opened then return end
|
||||||
print("Неверный код, попробуй ещё")
|
clickSound:Play()
|
||||||
end
|
table.insert(entered, num)
|
||||||
currentInput = ""
|
local i = #entered
|
||||||
|
if entered[i] ~= CODE[i] then
|
||||||
|
-- ошибка — сброс
|
||||||
|
entered = {}
|
||||||
|
__rbxl_show_text("Неверно! Код сброшен.", 1.5)
|
||||||
|
loseSound:Play()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
if #entered == #CODE 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)`,
|
||||||
},
|
g12_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)`,
|
||||||
|
};
|
||||||
|
// 4 кнопки — каждая шлёт свой номер при нажатии E (если игрок рядом)
|
||||||
|
for (let num = 1; num <= 4; num++) {
|
||||||
|
overrides['g12_btn_' + num] = `-- === Скрипт кнопки-цифры ${num} (Lua) ===
|
||||||
|
local UserInputService = game:GetService("UserInputService")
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
|
local part = script.Parent
|
||||||
|
local hintVisible = false
|
||||||
|
|
||||||
|
-- Подсказка над кнопкой (виден когда игрок рядом)
|
||||||
|
local hintGui = Instance.new("BillboardGui", part)
|
||||||
|
hintGui.Size = UDim2.new(4, 0, 1, 0)
|
||||||
|
hintGui.StudsOffset = Vector3.new(0, 1.5, 0)
|
||||||
|
hintGui.AlwaysOnTop = true
|
||||||
|
local label = Instance.new("TextLabel", hintGui)
|
||||||
|
label.Size = UDim2.new(1, 0, 1, 0)
|
||||||
|
label.BackgroundTransparency = 1
|
||||||
|
label.TextColor3 = Color3.fromRGB(255, 255, 255)
|
||||||
|
label.TextStrokeTransparency = 0
|
||||||
|
label.TextScaled = true
|
||||||
|
label.Text = "[E] Нажать ${num}"
|
||||||
|
label.Visible = 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
|
||||||
|
label.Visible = near
|
||||||
|
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("ButtonPress")
|
||||||
|
if ev then ev:Fire(${num}) end
|
||||||
|
end)`;
|
||||||
|
}
|
||||||
|
return overrides;
|
||||||
|
})(),
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
// ИГРА 13 — «Торговец»
|
// ИГРА 13 — «Торговец»
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user