feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39

Merged
min merged 215 commits from feat/lua-50-games-bundle into main 2026-06-09 21:59:25 +00:00
2 changed files with 90 additions and 3 deletions
Showing only changes of commit b0bdfb6e29 - Show all commits

View File

@ -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;

View File

@ -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> создаёт