From b7b3c1eb810d4ec8a98f9280de5efeafb3cdf387 Mon Sep 17 00:00:00 2001 From: min Date: Tue, 9 Jun 2026 19:34:32 +0300 Subject: [PATCH] =?UTF-8?q?fix(g13):=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D0=BA=D0=B8=20[E]=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=20HUD=20ui.set=20=E2=80=94=20=D0=BF=D0=B0=D1=80=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D1=82=20=D1=81=20JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Юзер: подсказка в Lua была слева от центра, белая. В JS — точно по центру внизу, жёлтая. Корень: я использовал BillboardGui+TextLabel с явной Position, но GUI-shim позиционирует label некорректно (UDim2 offset плохо интерпретируется → плашка плыла). Фикс: используем тот же механизм что JS — game.ui.set (HUD через React). Добавил хелпер __rbxl_hud_set(id, text, x, y, color, size) шлющий 'ui.set' cmd, GameRuntime пробрасывает в _onHud → GameHud.jsx рендерит точно как для JS-скриптов. В g13_counter/g13_door: при near=true → hud_set с (50, 75, #ffe44a, 20) (центр по X, ниже центра по Y, жёлтый — точно как JS interact hint). При выходе из зоны → hud_set(id, nil) убирает. --- src/community/docsGamesBuildersLua.js | 42 +++++++-------------------- src/editor/engine/lua/RobloxShim.js | 15 ++++++++++ 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 5e776f9..400e659 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -1117,21 +1117,6 @@ local RunService = game:GetService("RunService") local part = script.Parent local hintVisible = false -local hintGui = Instance.new("BillboardGui", part) -hintGui.Size = UDim2.new(5, 0, 1, 0) -hintGui.StudsOffset = Vector3.new(0, 2.5, 0) -hintGui.AlwaysOnTop = true -local label = Instance.new("TextLabel", hintGui) -label.Size = UDim2.new(0, 320, 0, 50) -label.Position = UDim2.new(0.5, -160, 0.6, 0) -- ниже центра, над хотбаром -label.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -label.BackgroundTransparency = 0.4 -label.TextColor3 = Color3.fromRGB(255, 255, 255) -label.TextStrokeTransparency = 0 -label.TextScaled = true -label.Text = "[E] Поговорить с торговцем" -label.Visible = false - RunService.Heartbeat:Connect(function() local px = __rbxl_player_x() local pz = __rbxl_player_z() @@ -1141,7 +1126,11 @@ RunService.Heartbeat:Connect(function() local near = dist <= 4 if near ~= hintVisible then hintVisible = near - label.Visible = near + if near then + __rbxl_hud_set("g13_counter_hint", "[E] Поговорить с торговцем", 50, 75, "#ffe44a", 20) + else + __rbxl_hud_set("g13_counter_hint", nil) + end end end) @@ -1160,21 +1149,6 @@ 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, 3.5, 0) -hintGui.AlwaysOnTop = true -local label = Instance.new("TextLabel", hintGui) -label.Size = UDim2.new(0, 280, 0, 50) -label.Position = UDim2.new(0.5, -140, 0.6, 0) -- ниже центра, над хотбаром -label.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -label.BackgroundTransparency = 0.4 -label.TextColor3 = Color3.fromRGB(255, 255, 255) -label.TextStrokeTransparency = 0 -label.TextScaled = true -label.Text = "[E] Открыть дверь" -label.Visible = false - RunService.Heartbeat:Connect(function() local px = __rbxl_player_x() local pz = __rbxl_player_z() @@ -1184,7 +1158,11 @@ RunService.Heartbeat:Connect(function() local near = dist <= 4 if near ~= hintVisible then hintVisible = near - label.Visible = near + if near then + __rbxl_hud_set("g13_door_hint", "[E] Открыть дверь", 50, 75, "#ffe44a", 20) + else + __rbxl_hud_set("g13_door_hint", nil) + end end end) diff --git a/src/editor/engine/lua/RobloxShim.js b/src/editor/engine/lua/RobloxShim.js index e148a77..72d05a5 100644 --- a/src/editor/engine/lua/RobloxShim.js +++ b/src/editor/engine/lua/RobloxShim.js @@ -1816,6 +1816,21 @@ export function registerRobloxShim(lua, opts) { color: color || '#ffffff', }); }); + // Установка/удаление HUD-плашки в фиксированной позиции — паритет с + // JS game.ui.set / game.ui.showInteractHint и аналогами. + // opts = {x, y, color, size} (x,y в процентах 0-100; color — hex) + global.set('__rbxl_hud_set', (id, text, x, y, color, size) => { + const payload = { id: String(id || ''), text: text || null }; + if (text != null) { + payload.opts = { + x: Number(x) || 50, + y: Number(y) || 75, + color: color || '#ffe44a', + size: Number(size) || 20, + }; + } + send('ui.set', payload); + }); // Спавн NPC — паритет с JS game.scene.spawnNpc(modelType, opts). // Возвращает локальный ref (строку 'npc_lua_N'), который можно передавать // в __rbxl_npc_say(ref, text, duration).