fix(g13): подсказки [E] через HUD ui.set — паритет с JS

Юзер: подсказка в 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) убирает.
This commit is contained in:
min 2026-06-09 19:34:32 +03:00
parent e8bfdda380
commit b7b3c1eb81
2 changed files with 25 additions and 32 deletions

View File

@ -1117,21 +1117,6 @@ local RunService = game:GetService("RunService")
local part = script.Parent local part = script.Parent
local hintVisible = false 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() RunService.Heartbeat:Connect(function()
local px = __rbxl_player_x() local px = __rbxl_player_x()
local pz = __rbxl_player_z() local pz = __rbxl_player_z()
@ -1141,7 +1126,11 @@ RunService.Heartbeat:Connect(function()
local near = dist <= 4 local near = dist <= 4
if near ~= hintVisible then if near ~= hintVisible then
hintVisible = near 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
end) end)
@ -1160,21 +1149,6 @@ local RunService = game:GetService("RunService")
local part = script.Parent local part = script.Parent
local hintVisible = false 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() RunService.Heartbeat:Connect(function()
local px = __rbxl_player_x() local px = __rbxl_player_x()
local pz = __rbxl_player_z() local pz = __rbxl_player_z()
@ -1184,7 +1158,11 @@ RunService.Heartbeat:Connect(function()
local near = dist <= 4 local near = dist <= 4
if near ~= hintVisible then if near ~= hintVisible then
hintVisible = near 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
end) end)

View File

@ -1816,6 +1816,21 @@ export function registerRobloxShim(lua, opts) {
color: color || '#ffffff', 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). // Спавн NPC — паритет с JS game.scene.spawnNpc(modelType, opts).
// Возвращает локальный ref (строку 'npc_lua_N'), который можно передавать // Возвращает локальный ref (строку 'npc_lua_N'), который можно передавать
// в __rbxl_npc_say(ref, text, duration). // в __rbxl_npc_say(ref, text, duration).