Bux fixes and cleanup
placeable_objects cleaned up white space and removed commented out code points: issue with teleporting outside of a cell. Does not fire onremove event functions. Fixed utility: Implemented fix for special characters for blips. dialogue: upped wait time on close. This allows use to reopen the menu right away without firing the animation to close
This commit is contained in:
1 parent
5791f89598
commit
a1901fc400
4 files changed
+18
-99
No files matched your search
@@ -134,63 +134,6 @@ local function getMouseWorldPos(depth)
|
|||||||
return playerPos + normal * depth
|
return playerPos + normal * depth
|
||||||
end
|
end
|
||||||
|
|
||||||
-- local function isInBoundary(pos, boundary)
|
|
||||||
-- if not boundary then return true end
|
|
||||||
|
|
||||||
-- local x, y, z = table.unpack(pos)
|
|
||||||
|
|
||||||
-- -- Handle legacy min/max boundary format for backwards compatibility
|
|
||||||
-- if boundary.min and boundary.max then
|
|
||||||
-- local minX, minY, minZ = table.unpack(boundary.min)
|
|
||||||
-- local maxX, maxY, maxZ = table.unpack(boundary.max)
|
|
||||||
-- return x >= minX and x <= maxX and y >= minY and y <= maxY and z >= minZ and z <= maxZ
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- -- Handle list of points (polygon boundary)
|
|
||||||
-- if boundary.points and #boundary.points > 0 then
|
|
||||||
-- local points = boundary.points
|
|
||||||
-- local minZ = boundary.minZ or -math.huge
|
|
||||||
-- local maxZ = boundary.maxZ or math.huge
|
|
||||||
|
|
||||||
-- -- Check Z bounds first
|
|
||||||
-- if z < minZ or z > maxZ then
|
|
||||||
-- return false
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- -- Point-in-polygon test using ray casting algorithm (improved version)
|
|
||||||
-- local inside = false
|
|
||||||
-- local n = #points
|
|
||||||
|
|
||||||
-- for i = 1, n do
|
|
||||||
-- local j = i == n and 1 or i + 1 -- Next point (wrap around)
|
|
||||||
|
|
||||||
-- local xi, yi = points[i].x or points[i][1], points[i].y or points[i][2]
|
|
||||||
-- local xj, yj = points[j].x or points[j][1], points[j].y or points[j][2]
|
|
||||||
|
|
||||||
-- -- Ensure xi, yi, xj, yj are numbers
|
|
||||||
-- if not (xi and yi and xj and yj) then
|
|
||||||
-- goto continue
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- -- Ray casting test
|
|
||||||
-- if ((yi > y) ~= (yj > y)) then
|
|
||||||
-- -- Calculate intersection point
|
|
||||||
-- local intersect = (xj - xi) * (y - yi) / (yj - yi) + xi
|
|
||||||
-- if x < intersect then
|
|
||||||
-- inside = not inside
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- ::continue::
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- return inside
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- -- Fallback to true if boundary format is not recognized
|
|
||||||
-- return true
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local function checkMaterialAndBoundary()
|
local function checkMaterialAndBoundary()
|
||||||
if not state.currentEntity then return true end
|
if not state.currentEntity then return true end
|
||||||
|
|
||||||
@@ -260,41 +203,6 @@ local function checkMaterialAndBoundaryDetailed()
|
|||||||
return inBounds, inBounds, customCheckPassed
|
return inBounds, inBounds, customCheckPassed
|
||||||
end
|
end
|
||||||
|
|
||||||
-- local function setupInstructionalButtons()
|
|
||||||
-- local buttons = {}
|
|
||||||
|
|
||||||
-- -- Common buttons
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = state.settings.config?.place_object?.name or 'Place Object:', keyIndex = state.settings.config?.place_object?.key or {223}, int = 5})
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = state.settings.config?.cancel_placement?.name or 'Cancel:', keyIndex = state.settings.config?.cancel_placement?.key or {25}, int = 4})
|
|
||||||
|
|
||||||
-- if state.mode == 'normal' then
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Rotate:', keyIndex = {241, 242}, int = 3})
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Depth:', keyIndex = {224}, int = 2})
|
|
||||||
-- if state.settings.allowVertical then
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Height:', keyIndex = {16, 17}, int = 1})
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Toggle Ground Snap:', keyIndex = {19}, int = 0})
|
|
||||||
-- end
|
|
||||||
-- if state.settings.allowMovement then
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Movement Mode:', keyIndex = {38}, int = 6})
|
|
||||||
-- end
|
|
||||||
-- elseif state.mode == 'movement' then
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Move:', keyIndex = {32, 33, 34, 35}, int = 3})
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Rotate:', keyIndex = {174, 175}, int = 2})
|
|
||||||
-- if state.settings.allowVertical then
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Up/Down:', keyIndex = {85, 48}, int = 1})
|
|
||||||
-- end
|
|
||||||
-- if state.settings.allowNormal then
|
|
||||||
-- table.insert(buttons, {type = "SET_DATA_SLOT", name = 'Normal Mode:', keyIndex = {38}, int = 0})
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- table.insert(buttons, {type = "DRAW_INSTRUCTIONAL_BUTTONS"})
|
|
||||||
-- table.insert(buttons, {type = "SET_BACKGROUND_COLOUR"})
|
|
||||||
|
|
||||||
-- -- return Scaleform.SetupInstructionalButtons(buttons)
|
|
||||||
-- return nil -- Scaleform disabled for now
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local function drawBoundaryBox(boundary)
|
local function drawBoundaryBox(boundary)
|
||||||
if not boundary then return end
|
if not boundary then return end
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Grid.Generated = false
|
|||||||
local Grids = {}
|
local Grids = {}
|
||||||
Point = {}
|
Point = {}
|
||||||
Point.All = {}
|
Point.All = {}
|
||||||
|
Point.LastInside = nil
|
||||||
|
|
||||||
function Grid.Generate()
|
function Grid.Generate()
|
||||||
if Grid.Generated then return end
|
if Grid.Generated then return end
|
||||||
@@ -39,13 +40,21 @@ Points.Started = false
|
|||||||
function Point.StartLoop()
|
function Point.StartLoop()
|
||||||
if Points.Started then return end
|
if Points.Started then return end
|
||||||
Points.Started = true
|
Points.Started = true
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while Points.Started do
|
while Points.Started do
|
||||||
local playerPed = PlayerPedId()
|
local playerPed = PlayerPedId()
|
||||||
if playerPed ~= -1 then
|
if playerPed ~= -1 then
|
||||||
local coords = GetEntityCoords(playerPed)
|
local coords = GetEntityCoords(playerPed)
|
||||||
local cell = Grid.GetCellByCoords(coords)
|
local cell = Grid.GetCellByCoords(coords)
|
||||||
|
if Point.LastInside ~= cell then
|
||||||
|
for _, point in pairs(Point.LastInside or {}) do
|
||||||
|
if point.inside then
|
||||||
|
point.inside = false
|
||||||
|
point.args = point?.onExit(point, point.args) or point.args
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Point.LastInside = cell
|
||||||
|
end
|
||||||
for _, point in pairs(cell or {}) do
|
for _, point in pairs(cell or {}) do
|
||||||
local entity = point.target
|
local entity = point.target
|
||||||
local targetCoords = point.isEntity and DoesEntityExist(entity) and GetEntityCoords(entity) or point.coords
|
local targetCoords = point.isEntity and DoesEntityExist(entity) and GetEntityCoords(entity) or point.coords
|
||||||
|
|||||||
@@ -120,12 +120,14 @@ end
|
|||||||
function Utility.CreateBlip(coords, sprite, color, scale, label, shortRange, displayType)
|
function Utility.CreateBlip(coords, sprite, color, scale, label, shortRange, displayType)
|
||||||
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
|
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
|
||||||
SetBlipSprite(blip, sprite or 8)
|
SetBlipSprite(blip, sprite or 8)
|
||||||
SetBlipColour(blip, color or 3)
|
SetTextFont(0)
|
||||||
SetBlipScale(blip, scale or 0.8)
|
|
||||||
SetBlipDisplay(blip, displayType or 2)
|
SetBlipDisplay(blip, displayType or 2)
|
||||||
|
SetBlipScale(blip, scale or 0.8)
|
||||||
|
SetBlipColour(blip, color or 3)
|
||||||
SetBlipAsShortRange(blip, shortRange)
|
SetBlipAsShortRange(blip, shortRange)
|
||||||
AddTextEntry(label, label)
|
BeginTextCommandSetBlipName("STRING")
|
||||||
BeginTextCommandSetBlipName(label)
|
--AddTextComponentSubstringPlayerName(label) -- switch to this if below line doesnt show da chinese
|
||||||
|
AddTextComponentString(label)
|
||||||
EndTextCommandSetBlipName(blip)
|
EndTextCommandSetBlipName(blip)
|
||||||
blipIDs[tostring(blip)] = blip
|
blipIDs[tostring(blip)] = blip
|
||||||
return blip
|
return blip
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function Dialogue.Close(name)
|
|||||||
|
|
||||||
-- Wait brief moment to see if new dialogue opens
|
-- Wait brief moment to see if new dialogue opens
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
Wait(50) -- Small delay to allow new dialogue to open
|
Wait(200) -- Small delay to allow new dialogue to open
|
||||||
if pendingCameraDestroy and not activeDialogue then
|
if pendingCameraDestroy and not activeDialogue then
|
||||||
-- No new dialogue opened, safe to destroy camera
|
-- No new dialogue opened, safe to destroy camera
|
||||||
RenderScriptCams(false, 1, 1000, 1, 0)
|
RenderScriptCams(false, 1, 1000, 1, 0)
|
||||||
@@ -56,7 +56,7 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
|||||||
-- camera magic!
|
-- camera magic!
|
||||||
if entity then
|
if entity then
|
||||||
Wait(500)
|
Wait(500)
|
||||||
local endLocation = GetOffsetFromEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z + 0.5)
|
local endLocation = GetOffsetFr omEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z)
|
||||||
local pedHeading = GetEntityHeading(entity)
|
local pedHeading = GetEntityHeading(entity)
|
||||||
-- Get position in front of ped based on their heading
|
-- Get position in front of ped based on their heading
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user