feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -3799,7 +3799,151 @@ end)`;
|
||||
})(),
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// ИГРЫ 42-50: явных Lua-версий пока нет.
|
||||
// ИГРА 42 — «RPG-деревня»
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
'rpg-village': {
|
||||
g42_main: `-- === ИГРА «RPG-ДЕРЕВНЯ» — главный скрипт (Lua) ===
|
||||
${SNIPPET_BROADCAST}
|
||||
|
||||
local stage = 0 -- 0=начало, 1=ищем амулет, 2=несём кузнецу, 3=готово
|
||||
local hasAmulet = false
|
||||
|
||||
__rbxl_show_text("Деревня. Поговори со старостой (E)", 4)
|
||||
|
||||
local elderRef = __rbxl_spawn_npc("character-a", 1.6, 1, 2, "Староста", 100, 0)
|
||||
local smithRef = __rbxl_spawn_npc("character-b", 12.6, 1, 7, "Кузнец", 100, 0)
|
||||
|
||||
local pickupSound = Instance.new("Sound", workspace)
|
||||
pickupSound.SoundId = "pickup"; pickupSound.Volume = 0.7
|
||||
local winSound = Instance.new("Sound", workspace)
|
||||
winSound.SoundId = "win"; winSound.Volume = 1
|
||||
|
||||
-- Староста
|
||||
local elderEvent = getEvent("ElderTalk")
|
||||
elderEvent.Event:Connect(function()
|
||||
if stage == 0 then
|
||||
stage = 1
|
||||
__rbxl_npc_say(elderRef, "Найди потерянный амулет за домом!", 4)
|
||||
__rbxl_show_text("Квест: найди фиолетовый амулет", 3)
|
||||
elseif stage == 1 then
|
||||
__rbxl_npc_say(elderRef, "Амулет всё ещё не у тебя...", 3)
|
||||
else
|
||||
__rbxl_npc_say(elderRef, "Спасибо за помощь деревне!", 3)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Амулет
|
||||
local amuletEvent = getEvent("TakeAmulet")
|
||||
amuletEvent.Event:Connect(function()
|
||||
if stage ~= 1 then return end
|
||||
stage = 2
|
||||
hasAmulet = true
|
||||
__rbxl_inventory_define("amulet", "Амулет", "#a855f7")
|
||||
__rbxl_inventory_add("amulet", 1)
|
||||
pickupSound:Play()
|
||||
__rbxl_show_text("Амулет найден! Отнеси кузнецу.", 3)
|
||||
end)
|
||||
|
||||
-- Кузнец
|
||||
local smithEvent = getEvent("SmithTalk")
|
||||
smithEvent.Event:Connect(function()
|
||||
if stage == 2 and hasAmulet then
|
||||
stage = 3
|
||||
hasAmulet = false
|
||||
__rbxl_inventory_remove("amulet", 1)
|
||||
__rbxl_npc_say(smithRef, "Отличный амулет! Вот награда, герой!", 4)
|
||||
__rbxl_show_text("Победа! Квест RPG-деревни выполнен!", 6)
|
||||
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)
|
||||
elseif stage == 3 then
|
||||
__rbxl_npc_say(smithRef, "Доброго пути!", 3)
|
||||
else
|
||||
__rbxl_npc_say(smithRef, "Принеси мне амулет — поговори со старостой.", 4)
|
||||
end
|
||||
end)`,
|
||||
g42_elder: `-- === Скрипт старосты (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 <= 4
|
||||
if near ~= hintVisible then
|
||||
hintVisible = near
|
||||
if near then
|
||||
__rbxl_hud_set("g42_elder_hint", "[E] Поговорить со старостой", 50, 75, "#ffe44a", 20)
|
||||
else
|
||||
__rbxl_hud_set("g42_elder_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("ElderTalk")
|
||||
if ev then ev:Fire() end
|
||||
end)`,
|
||||
g42_smith: `-- === Скрипт кузнеца (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 <= 4
|
||||
if near ~= hintVisible then
|
||||
hintVisible = near
|
||||
if near then
|
||||
__rbxl_hud_set("g42_smith_hint", "[E] Поговорить с кузнецом", 50, 75, "#ffe44a", 20)
|
||||
else
|
||||
__rbxl_hud_set("g42_smith_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("SmithTalk")
|
||||
if ev then ev:Fire() end
|
||||
end)`,
|
||||
g42_amulet: `-- === Скрипт амулета (Lua) ===
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local part = script.Parent
|
||||
local taken = false
|
||||
|
||||
part.Touched:Connect(function(hit)
|
||||
if taken then return end
|
||||
local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
|
||||
if not h then return end
|
||||
taken = true
|
||||
local ev = ReplicatedStorage:FindFirstChild("TakeAmulet")
|
||||
if ev then ev:Fire() end
|
||||
part:Destroy()
|
||||
end)`,
|
||||
},
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// ИГРЫ 43-50: явных Lua-версий пока нет.
|
||||
// buildGameProject в docsGamesBuilders.js использует generateFallbackLua
|
||||
// (главный скрипт → показ подсказки + слушает FinishReached →
|
||||
// победа+конфетти; скрипт на финиш-примитиве → шлёт FinishReached;
|
||||
|
||||
@ -5837,7 +5837,7 @@ game.after(2, startWave); // первая волна через 2 секунд
|
||||
|
||||
<h3 className="lessonH">Шаг 2. Главный скрипт</h3>
|
||||
<ScriptKind kind="global" />
|
||||
<Code>{`// === ИГРА «ПЛАТФОРМЕР-ПРИКЛЮЧЕНИЕ» — главный скрипт ===
|
||||
<CodeBoth game="adventure-platformer" script="g41_main">{`// === ИГРА «ПЛАТФОРМЕР-ПРИКЛЮЧЕНИЕ» — главный скрипт ===
|
||||
|
||||
let coins = 0;
|
||||
let won = false;
|
||||
@ -5879,7 +5879,7 @@ game.onMessage('treasure', () => {
|
||||
const p = game.player.position;
|
||||
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.onMessage('coin', ...)</code> — пришла
|
||||
@ -5899,21 +5899,21 @@ game.onMessage('treasure', () => {
|
||||
|
||||
<h3 className="lessonH">Шаг 3. Скрипты монетки, чекпоинта и сокровища</h3>
|
||||
<ScriptKind kind="object" on="каждую монетку" />
|
||||
<Code>{`// === Скрипт монетки ===
|
||||
<CodeBoth game="adventure-platformer" script="g41_coin_10">{`// === Скрипт монетки ===
|
||||
game.self.onTouch(() => {
|
||||
game.broadcast('coin');
|
||||
game.self.delete();
|
||||
});`}</Code>
|
||||
});`}</CodeBoth>
|
||||
<ScriptKind kind="object" on="жёлтый чекпоинт" />
|
||||
<Code>{`// === Скрипт чекпоинта ===
|
||||
<CodeBoth game="adventure-platformer" script="g41_cp">{`// === Скрипт чекпоинта ===
|
||||
game.self.onTouch(() => {
|
||||
game.broadcast('checkpoint');
|
||||
});`}</Code>
|
||||
});`}</CodeBoth>
|
||||
<ScriptKind kind="object" on="золотое сокровище" />
|
||||
<Code>{`// === Скрипт сокровища ===
|
||||
<CodeBoth game="adventure-platformer" script="g41_finish">{`// === Скрипт сокровища ===
|
||||
game.self.onTouch(() => {
|
||||
game.broadcast('treasure');
|
||||
});`}</Code>
|
||||
});`}</CodeBoth>
|
||||
<p>
|
||||
Монетка при касании засчитывается и исчезает. Чекпоинт
|
||||
сохраняет место. Сокровище зовёт победу.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user