Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- JointConstructor:setActors
- JointConstructor:setJointTransforms
- addDifferential
- addForce
- addImpulse
- addTorque
- addTorqueImpulse
- addVehicleLink
- computeWheelShapeTireForces
- createCCT
- createWheelShape
- getAngularDamping
- getAngularVelocity
- getCCTCollisionFlags
- getCenterOfMass
- getCollisionMask
- getDensity
- getLinearDamping
- getLinearVelocity
- getMass
- getMotorRotationSpeed
- getRigidBodyType
- getVelocityAtLocalPos
- getVelocityAtWorldPos
- getVolume
- getWheelShapeAxleSpeed
- getWheelShapeContactForce
- getWheelShapeContactNormal
- getWheelShapeContactObject
- getWheelShapeContactPoint
- getWheelShapePosition
- getWheelShapeSlip
- moveCCT
- overlapBox
- overlapSphere
- raycastAll
- raycastClosest
- removeCCT
- setAngularDamping
- setAngularVelocity
- setCenterOfMass
- setCollisionMask
- setFrictionVelocity
- setJointDrive
- setLinearDamping
- setLinearVelocity
- setMass
- setRigidBodyType
- setSolverIterationCount
- setWheelShapeForcePoint
- setWheelShapeProps
- setWheelShapeTireFriction
- simulatePhysics
- simulatePhysicsTimeScale
- updateDifferential
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
Overlay
DescriptionImage display overlay. This class is used to display textures or usually parts thereof as rectangular panels in the UI or on the HUD. Example usages include button icons, showing images in the main menu or drawing the in-game map.Functions
- delete
- getPosition
- getScale
- new
- render
- resetDimensions
- setAlignment
- setColor
- setDimension
- setImage
- setInvertX
- setIsVisible
- setPosition
- setRotation
- setScale
- setUVs
delete
DescriptionDelete this overlay. Releases the texture file handle.Definition
delete()Code
76 | function Overlay:delete() |
77 | if self.overlayId ~= 0 then |
78 | delete(self.overlayId) |
79 | end |
80 | end |
getPosition
DescriptionGet this overlay's position.Definition
getPosition()Return Values
float | X | position in screen space |
float | Y | position in screen space |
121 | function Overlay:getPosition() |
122 | return self.x, self.y |
123 | end |
getScale
DescriptionGet this overlay's scale values.Definition
getScale()Return Values
float | Width | scale factor |
float | Height | scale factor |
192 | function Overlay:getScale() |
193 | return self.scaleWidth, self.scaleHeight |
194 | end |
new
DescriptionCreate a new Overlay.Definition
new(overlayFilename File, x Screen, y Screen, width Display, height Display)Arguments
overlayFilename | File | path of the source texture |
x | Screen | position x |
y | Screen | position y |
width | Display | width |
height | Display | height |
28 | function Overlay:new(overlayFilename, x, y, width, height) |
29 | local overlayId = 0 |
30 | if overlayFilename ~= nil then |
31 | overlayId = createImageOverlay(overlayFilename) |
32 | end |
33 | |
34 | local self = setmetatable({}, Overlay_mt) |
35 | |
36 | self.overlayId = overlayId |
37 | self.filename = overlayFilename |
38 | self.uvs = {1,0, 1,1, 0,0, 0,1} |
39 | |
40 | self.x = x |
41 | self.y = y |
42 | self.offsetX = 0 |
43 | self.offsetY = 0 |
44 | |
45 | self.defaultWidth = width |
46 | self.width = width |
47 | self.defaultHeight = height |
48 | self.height = height |
49 | |
50 | self.scaleWidth = 1.0 |
51 | self.scaleHeight = 1.0 |
52 | |
53 | self.visible = true |
54 | |
55 | self.alignmentVertical = Overlay.ALIGN_VERTICAL_BOTTOM |
56 | self.alignmentHorizontal = Overlay.ALIGN_HORIZONTAL_LEFT |
57 | |
58 | self.invertX = false |
59 | self.rotation = 0 |
60 | self.rotationCenterX = 0 |
61 | self.rotationCenterY = 0 |
62 | |
63 | self.r = 1.0 |
64 | self.g = 1.0 |
65 | self.b = 1.0 |
66 | self.a = 1.0 |
67 | |
68 | self.debugEnabled = false |
69 | |
70 | return self |
71 | end |
render
DescriptionRender this overlay.Definition
render()Code
198 | function Overlay:render() |
199 | if self.visible then |
200 | if self.overlayId ~= 0 and self.a > 0 then |
201 | renderOverlay(self.overlayId, self.x + self.offsetX, self.y + self.offsetY, self.width, self.height) |
202 | end |
203 | |
204 | if self.debugEnabled or g_uiDebugEnabled then |
205 | local xPixel = 1 / g_screenWidth |
206 | local yPixel = 1 / g_screenHeight |
207 | |
208 | setOverlayColor(GuiElement.debugOverlay, 0, 0, 1, 1) |
209 | |
210 | renderOverlay(GuiElement.debugOverlay, self.x + self.offsetX - xPixel, self.y + self.offsetY - yPixel, self.width + 2 * xPixel, yPixel) |
211 | renderOverlay(GuiElement.debugOverlay, self.x + self.offsetX - xPixel, self.y + self.offsetY + self.height, self.width + 2 * xPixel, yPixel) |
212 | renderOverlay(GuiElement.debugOverlay, self.x + self.offsetX - xPixel, self.y + self.offsetY, xPixel, self.height) |
213 | renderOverlay(GuiElement.debugOverlay, self.x + self.offsetX + self.width, self.y + self.offsetY, xPixel, self.height) |
214 | end |
215 | end |
216 | end |
resetDimensions
DescriptionReset width, height and scale to initial values set in the constructor.Definition
resetDimensions()Code
136 | function Overlay:resetDimensions() |
137 | self.scaleWidth = 1.0 |
138 | self.scaleHeight = 1.0 |
139 | self:setDimension(self.defaultWidth, self.defaultHeight) |
140 | end |
setAlignment
DescriptionSet this overlay's alignment.Definition
setAlignment(vertical Vertical, horizontal Horizontal)Arguments
vertical | Vertical | alignment value, one of Overlay.ALIGN_VERTICAL_[...] |
horizontal | Horizontal | alignment value, one of Overlay.ALIGN_HORIZONTAL_[...] |
222 | function Overlay:setAlignment(vertical, horizontal) |
223 | if vertical == Overlay.ALIGN_VERTICAL_TOP then |
224 | self.offsetY = -self.height |
225 | elseif vertical == Overlay.ALIGN_VERTICAL_MIDDLE then |
226 | self.offsetY = -self.height * 0.5 |
227 | else |
228 | self.offsetY = 0 |
229 | end |
230 | self.alignmentVertical = Utils.getNoNil(vertical, Overlay.ALIGN_VERTICAL_BOTTOM) |
231 | |
232 | if horizontal == Overlay.ALIGN_HORIZONTAL_RIGHT then |
233 | self.offsetX = -self.width |
234 | elseif horizontal == Overlay.ALIGN_HORIZONTAL_CENTER then |
235 | self.offsetX = -self.width * 0.5 |
236 | else |
237 | self.offsetX = 0 |
238 | end |
239 | self.alignmentHorizontal = Utils.getNoNil(horizontal, Overlay.ALIGN_HORIZONTAL_LEFT) |
240 | end |
setColor
DescriptionSet this overlay's color. The color is multiplied with the texture color. For no modification of the texture color, use full opaque white, i.e. {1, 1, 1, 1}.Definition
setColor(r Red, g Green, b Blue, a Alpha)Arguments
r | Red | channel |
g | Green | channel |
b | Blue | channel |
a | Alpha | channel |
90 | function Overlay:setColor(r, g, b, a) |
91 | self.r = Utils.getNoNil(r, self.r) |
92 | self.g = Utils.getNoNil(g, self.g) |
93 | self.b = Utils.getNoNil(b, self.b) |
94 | self.a = Utils.getNoNil(a, self.a) |
95 | if self.overlayId ~= 0 then |
96 | setOverlayColor(self.overlayId, self.r, self.g, self.b, self.a) |
97 | end |
98 | end |
setDimension
DescriptionSet this overlay's width and height. Either value can be omitted (== nil) for no change.Definition
setDimension()Code
128 | function Overlay:setDimension(width, height) |
129 | self.width = Utils.getNoNil(width, self.width) |
130 | self.height = Utils.getNoNil(height, self.height) |
131 | self:setAlignment(self.alignmentVertical, self.alignmentHorizontal) |
132 | end |
setImage
DescriptionSet a different image for this overlay. The previously targeted image's handle will be released.Definition
setImage(overlayFilename File)Arguments
overlayFilename | File | path to new target image |
252 | function Overlay:setImage(overlayFilename) |
253 | if self.filename ~= overlayFilename then |
254 | if self.overlayId ~= 0 then |
255 | delete(self.overlayId) |
256 | end |
257 | self.filename = overlayFilename |
258 | self.overlayId = createImageOverlay(overlayFilename) |
259 | end |
260 | end |
setInvertX
DescriptionSet horizontal flipping state.Definition
setInvertX(invertX If)Arguments
invertX | If | true, will set the overlay to display its image flipped horizontally |
145 | function Overlay:setInvertX(invertX) |
146 | if self.invertX ~= invertX then |
147 | self.invertX = invertX |
148 | if self.overlayId ~= 0 then |
149 | if invertX then |
150 | setOverlayUVs(self.overlayId, self.uvs[5],self.uvs[6], self.uvs[7],self.uvs[8], self.uvs[1],self.uvs[2], self.uvs[3], self.uvs[4]) |
151 | else |
152 | setOverlayUVs(self.overlayId, unpack(self.uvs)) |
153 | end |
154 | end |
155 | end |
156 | end |
setIsVisible
DescriptionSet this overlay's visibility.Definition
setIsVisible()Code
244 | function Overlay:setIsVisible(visible) |
245 | self.visible = visible |
246 | end |
setPosition
DescriptionSet this overlay's position.Definition
setPosition()Code
112 | function Overlay:setPosition(x, y) |
113 | self.x = Utils.getNoNil(x, self.x) |
114 | self.y = Utils.getNoNil(y, self.y) |
115 | end |
setRotation
DescriptionSet this overlay's rotation.Definition
setRotation(rotation Rotation, centerX Rotation, centerY Rotation)Arguments
rotation | Rotation | in radians |
centerX | Rotation | pivot X position offset from overlay position in screen space |
centerY | Rotation | pivot Y position offset from overlay position in screen space |
163 | function Overlay:setRotation(rotation, centerX, centerY) |
164 | if self.rotation ~= rotation or self.rotationCenterX ~= centerX or self.rotationCenterY ~= centerY then |
165 | self.rotation = rotation |
166 | self.rotationCenterX = centerX |
167 | self.rotationCenterY = centerY |
168 | if self.overlayId ~= 0 then |
169 | setOverlayRotation(self.overlayId, rotation, centerX, centerY) |
170 | end |
171 | end |
172 | end |
setScale
DescriptionSet this overlay's scale. Multiplies the scale values with the initial dimensions and sets those as the current dimensions.Definition
setScale(float scaleWidth, float scaleHeight)Arguments
float | scaleWidth | Width scale factor |
float | scaleHeight | Height scale factor |
179 | function Overlay:setScale(scaleWidth, scaleHeight) |
180 | self.width = self.defaultWidth * scaleWidth |
181 | self.height = self.defaultHeight * scaleHeight |
182 | self.scaleWidth = scaleWidth |
183 | self.scaleHeight = scaleHeight |
184 | -- update alignment offsets |
185 | self:setAlignment(self.alignmentVertical, self.alignmentHorizontal) |
186 | end |
setUVs
DescriptionSet this overlay's UVs which define the area to be displayed within the target texture.Definition
setUVs(uvs UV)Arguments
uvs | UV | coordinates in the form of {u1, v1, u2, v2, u3, v3, u4, v4} |
103 | function Overlay:setUVs(uvs) |
104 | if self.overlayId ~= 0 then |
105 | self.uvs = uvs |
106 | setOverlayUVs(self.overlayId, unpack(uvs)) |
107 | end |
108 | end |