53 lines
2.2 KiB
Lua
53 lines
2.2 KiB
Lua
-- Предпросмотр NPC в режиме редактирования Studio (Command Bar или Studio MCP).
|
||
-- В игре NPC собираются сами при запуске: WorldBuilder.prepareRuntime → spawnNpc → образ из
|
||
-- ServerScriptService.NpcLooks. Этот скрипт ставит такие же фигуры на их места в папку
|
||
-- Workspace._NpcPreview, чтобы посмотреть и настроить образы без Play. Повторный запуск пересобирает.
|
||
-- Перед сохранением плейса удалите превью: workspace._NpcPreview:Destroy() (или запустите с ONLY = "off").
|
||
--
|
||
-- ONLY = nil — все NPC; ONLY = "Скупщик Гриша" — один; ONLY = "off" — только убрать превью.
|
||
|
||
local ONLY = nil
|
||
|
||
local ServerScriptService = game:GetService("ServerScriptService")
|
||
-- свежие копии модулей (require кэширует, а правки из Rojo/MCP должны подхватываться)
|
||
local function load(module)
|
||
local copy = module:Clone()
|
||
copy.Parent = module.Parent
|
||
local ok, result = pcall(require, copy)
|
||
copy:Destroy()
|
||
if not ok then
|
||
error(result, 0)
|
||
end
|
||
return result
|
||
end
|
||
|
||
local old = workspace:FindFirstChild("_NpcPreview")
|
||
if old then
|
||
old:Destroy()
|
||
end
|
||
if ONLY == "off" then
|
||
return "превью убрано"
|
||
end
|
||
|
||
local WorldBuilder = load(ServerScriptService.WorldBuilder)
|
||
local folder = Instance.new("Folder")
|
||
folder.Name = "_NpcPreview"
|
||
folder.Parent = workspace
|
||
|
||
local made = {}
|
||
for _, spot in ipairs(workspace.FishingMap:GetDescendants()) do
|
||
if spot:IsA("BasePart") and spot:GetAttribute("NpcName") and (ONLY == nil or spot:GetAttribute("NpcName") == ONLY) then
|
||
local rig = WorldBuilder.spawnNpc(spot, folder)
|
||
if rig then
|
||
-- в превью подсказки не нужны (иначе в редакторе продаже мешали бы две подсказки)
|
||
for _, pp in ipairs(rig:GetDescendants()) do
|
||
if pp:IsA("ProximityPrompt") then
|
||
pp:Destroy()
|
||
end
|
||
end
|
||
table.insert(made, rig.Name)
|
||
end
|
||
end
|
||
end
|
||
return "превью: " .. table.concat(made, ", ")
|