Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/03/25 in all areas

  1. When you set the property, it stays frozen. So for example if you call getWorldProperty and then pass its return value to setWorldProperty, that value will stay until you call resetWorldProperty. But some of those functions (including getSkyGradient) are limited because they can only return the values previously assigned by script - meaning you can't get the unmodified value and assign it to freeze it. It seems that smooth transition is possible for color filter, because getColorFilter has isOriginal argument, allowing you to take the values that would be there if they weren't overridden by script so you can know exactly what values to interpolate to. But it doesn't help much when the same can't be done to other parameters.
    1 point
  2. You can make your own functions that operate in terms of your custom concepts, and use dxDrawRectangle/dxDrawText under the hood for actual drawing. An example: function getCoords(coordSys, x, y) if coordSys then x, y = coordSys.x+x, coordSys.y+y end return x, y end function makeCoordSystem(parent, x, y) local finalX, finalY = getCoords(parent, x, y) return { x = finalX, y = finalY } end function drawText(coordSys, text, x, y) local finalX, finalY = getCoords(coordSys, x, y) dxDrawText(text, finalX, finalY) end function drawRectangle(coordSys, x, y, width, height, color) local finalX, finalY = getCoords(coordSys, x, y) dxDrawRectangle(finalX, finalY, width, height, color) end This implements a concept of coordinate system, the coordinate offset described by table with keys x and y. With this, you can do: local onScreenHud = makeCoordSystem(false, x*1200, y*120) -- false means onScreenHud will be placed in absolute coordinates function drawHUD() drawRectangle(onScreenHud, 0, 0, x*1400, y*400, tocolor(0, 0, 0, 150)) drawText(onScreenHud, "Text", x*20, y*10) end Since makeCoordSystem has parent as first argument, even coordinate systems themselves can be positioned with respect to other coordinate systems: local someInnerHud = makeCoordSystem(onScreenHud, x*20, x*40) function drawInnerHUD() drawText(someInnerHud, "Text in the inner HUD", x*20, y*10) end It's all about coming up with the right abstractions. As an example, you could modify this to add width and height properties to coordinate systems, and use them in calculations so you wouldn't have to write x* and y* everywhere.
    1 point
  3. You can save your coordinates to the variables, and the use them to build text. Like: local rectangleStartX = x*1200 local rectangleWidth = x*1400 dxDrawText(rectangleStartX + rectangleWidth + 10, etc...) But i'm not sure right now about your coordinates, because "width" for dxDrawRectangle - it's not the endpoint, if wiki is right And then code will be more easy, because for width you can use just "200". As for take coordinates from rectangle - well, looks like it can't be done in MTA. P.S. I'm not good in UI scripting, just trying to help with simple logic.
    1 point
×
×
  • Create New...